[Libav-user] Filesize difference between using ffmpeg command line and C API
gabriele.greco at hudl.com
Wed Apr 7 15:49:00 EEST 2021
> Still investigating the problem, by constraining my application with -qmin=10 -qmax=10, and doing the same using ffmpeg command line I have the exact same bitrate and file size.
I had similar problems and I found that the problem was my video stream time_base.
When you call avformat_write_header() avformat silently change your stream time_base to some values that it likes, so you cannot assume that the video stream time_base was the one you have configured on the stream creation but you need to do before encoding every frame:
av_packet_rescale_ts(pkt_, vc_->time_base, vs_->time_base);
if you don't do that x264 (and other encoders) will think that the frame duration is different from the real one and will behave accordingly.
The problem was more evident when encoding with videotoolbox on macOS that has a fixed bitrate mode.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libav-user