Android MediaRecorder API不断裁切视频比特率 [英] Android MediaRecorder API keeps cropping the video bitrate

查看:143
本文介绍了Android MediaRecorder API不断裁切视频比特率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MediaRecorder API已有一段时间,我以为所有问题都在我身后,但我想我错了.

I'm working with the MediaRecorder API for a while, I thought all problems are behind me but I guess I was wrong.

我正在使用MediaRecorder API将视频录制到文件中. 当我以高质量使用setProfile时,质量会很好,但是当我尝试手动设置参数时(如下面的代码所示),质量会很差(由于某种原因,比特率被裁剪). 我想以1fps获得720p.

I'm using the MediaRecorder API for recording video to a file. When I use the setProfile with high quality I get good quality but when I try to set the parameters manually (as in the code below) the quality is bad (since for some reason the bitrate is cropped). I want to get 720p with 1fps.

我不断收到以下警告: WARN/AuthorDriver(268):视频编码比特率设置为480000 bps

I keep getting the following warning: WARN/AuthorDriver(268): Video encoding bit rate is set to 480000 bps

我正在运行的代码:

m_MediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
m_MediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
m_MediaRecorder.setVideoSize(1280, 720);
m_MediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
m_MediaRecorder.setVideoFrameRate(1);
m_MediaRecorder.setVideoEncodingBitRate(8000000);

有什么主意吗? 非常感谢.

Any idea? Thanks a lot.

推荐答案

找到了解决方案……但是很奇怪. 在设置压缩类型之前先设置比特率可以解决该问题. 唯一的问题是,这是Google代码中的错误还是其他我不理解的错误.

Found the solution...very weird however. Setting the bit-rate before setting the compression type somehow solved the problem. The only question is whether it is a bug in google's code or something else that I don't understand.

原文:

m_MediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
m_MediaRecorder.setVideoFrameRate(1);
m_MediaRecorder.setVideoEncodingBitRate(8000000);

解决方案:

m_MediaRecorder.setVideoEncodingBitRate(8000000);
m_MediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
m_MediaRecorder.setVideoFrameRate(1);

这篇关于Android MediaRecorder API不断裁切视频比特率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆