Android MediaRecorder API continues to trim video bitrate

I have been working with the MediaRecorder API for a while, I thought that all the problems were behind me, but I think that I was wrong.

I use the MediaRecorder API to write video to a file. When I use 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 poor (because for some reason the bitrate is cut off). I want to get 720p with 1fps.

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

The code I run is:

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? Many thanks.

+6
source share
2 answers

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

Original:

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

Decision:

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

The documentation for setVideoEncodingBitRate () says:

Sets the encoding rate of the video signal for recording. Call this method before preparing (). Prepare () can perform additional checks on the parameter to ensure that the specified data transfer rate is applicable, and sometimes the transmitted bit Rate will be trimmed inside to ensure the video recording can proceed smoothly, based on the capabilities of the platform.

Since the MediaRecorder API deals with a hardware encoding chip that differs from device to device, it may not always be able to provide you with every combination of codec, frame size, frame rate, and encoding bitrate you are asking for.

Your needs are somewhat unusual as you try to record at 1 fps. If you are developing your application for Honeycomb, an “API” for MediaRecorder along with the associated setCaptureRate() call , which may be useful.

+2
source

Source: https://habr.com/ru/post/892946/


All Articles