【发布时间】:2011-03-23 14:53:49
【问题描述】:
我尝试使用 MediaRecorder 类录制视频。
但我发现我未能降低视频流的帧率。
我使用 H.264 作为我的视频编码器和 AAC 作为我的音频编码器(是的,它在 API LEVEL 10 及更高版本,AKA Android 2.3.3+ 中受支持) 主要来源如下。
recorder = new MediaRecorder();
recorder.setPreviewDisplay(surfaceHolder.getSurface());
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
//set the Output Format
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
//set the Video Size
recorder.setVideoSize(176,144);
//set the Frame rate
recorder.setVideoFrameRate(15);
//Set the Video Encoder
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
//Set the Audio Encoder
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
recorder.setOutputFile(myRecAudioFile.getAbsolutePath());
recorder.prepare();
recorder.start();
但是我得到的调试信息是:
03-22 22:39:41.120: WARN/StagefrightRecorder(662): Intended video encoding frame rate (15 fps) is too small and will be set to (27 fps)
很奇怪,我还收到一条错误消息:
03-22 22:39:41.380: ERROR/VENC_ENC(662): Bitrate 192000
最后,我得到了一个帧率接近28fps的mp4文件。
我也尝试使用最低的 CamcorderProfile
recorder = new MediaRecorder();
recorder.setPreviewDisplay(surfaceHolder.getSurface());
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
//replacement
CamcorderProfile cpLow = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
recorder.setProfile(cpLow);
recorder.setOutputFile(myRecAudioFile.getAbsolutePath());
recorder.prepare();
recorder.start();
并注释记录器的详细配置。
Pro Android Media 这本书的第 242 页说我会得到 15fps 的视频文件。但是,我再次获得了大约 27fps 的视频文件。
那么如何降低视频的帧率?我正在构建一个直播系统,因此降低比特率对我来说非常重要。 感谢您的宝贵时间!
【问题讨论】:
标签: android video-streaming frame-rate mediarecorder