Record video with MediaCodec and MediaMuxer, but the bitrate and framerate are incorrect

前端 未结 1 457
轮回少年
轮回少年 2020-12-05 21:51

I wrote a demo to record a video using MediaCodec and MediaMuxer.

I record a video with my demo and use ffprobe to check the video, the result is as follows:

相关标签:
1条回答
  • 2020-12-05 22:19

    It looks like your expected frame rate (19fps) doesn't match the actual frame rate (30fps). The encoder is attempting to meet the bit rate requirements for frames submitted at 19fps, but they're coming in faster, so it misses and the actual bit rate is higher. I'm assuming the 30fps value is determined from the actual presentation time stamps in the video file, which are set by the presentation time stamps passed into MediaMuxer. If you want 19fps video, you need to generate time stamps that are (1000/19) milliseconds apart.

    If your input video is 30fps, you will need to drop frames during the encoding process to get to 19fps. MediaCodec does not drop frames for you -- it encodes everything you pass in.

    I don't know why you'd be getting a broken section at the start of the video.

    0 讨论(0)
提交回复
热议问题