Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

android - CamcorderProfile.QUALITY_HIGH resolution produces green flickering video

I haven't found any explanation for this so far. Basically I have a video recording class which works splendidly when setVideoSize() is set to 720 x 480 on my Samsung Galaxy S2.

I want it to record in the highest possible resolution so using CamcorderProfile.QUALITY_HIGH I can get the various highest quality recording properties and set them within my class. This works for file format, video frame rate, encoders and bit rate, however when I attempt to set the video size to the width and height returned by the CamcorderProfile (1920 x 1080), the video recorded is just a green flicker.

I noticed if I changed 720 x 480 to 720 x 481 it did the same thing. Therefore I can only assume this happens when the resolution isn't supported by the phone. However, the camcorder the phone came with can record in 1920 x 1080 and it produces an excellent recording.

I can only assume with such a high resolution I need to set some other parameters differently, but I just cant figure out what they might be.

Has anyone else had this problem?

Thanks in advance for any replies.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I came across this question trying to solve the same problem.

A solution is given over on xda developer http://forum.xda-developers.com/showthread.php?t=1104970&page=8. It seems that you need to set an obscure parameter "cam_mode" for high definition recording to work:

camera = Camera.open();
Camera.Parameters param = camera.getParameters();
param.set( "cam_mode", 1 );     
camera.setParameters( param );

In mediarecorder, you can then use

mediarecorder.setVideoSize(1920, 1080);

although this will now also work:

mediarecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));

(The latter seems to have a video bitrate of 20Mb/s, so you might want to take that down a bit!) I found that I didn't have to set the preview size to 1920x1080.

(edit) You also need to set

parame.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);

or

param.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY);

otherwise you get a delay of a few seconds before the camera starts!

As to why Samsung has implemented the Camera in this way, I have no idea. It's certainly not developer friendly!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...