[Libav-user] Repeating frame while encoding using ffmpeg api
brado at bighillsoftware.com
Thu Oct 2 23:55:35 CEST 2014
On Oct 2, 2014, at 10:44 AM, Nicolas George <george at nsup.org> wrote:
> L'octidi 8 vendémiaire, an CCXXIII, Bradley O'Hearne a écrit :
>> As soon as an actual working code sample emerges which proves that you can
>> feed varying FPS to the encoder
> There is no need for it to emerge, it already exists. Look at ffmpeg.c. You
> can see for yourself:
> ffmpeg -lavfi \
> 'testsrc=r=1:d=60,settb=1/1000,setpts=N*1000+400*cos(PI*N)-400,showinfo' \
> -avoid_negative_ts 0 -r 1000 -y test.mkv
> You can see the variable timestamps using ffprobe on the output file, and
> you can see that MPlayer and ffplay both respect it.
> You just did something wrong in your program.
Very well, I’ll bite. Here is a working Mac app demonstrating the very thing I described, and a very similar codebase to the one submitted to this mailing list over a year ago, which netted no answer to the question (as did my own testing):
You can change configuration settings in the QTFFAVConfig.m file. The code in question is in QTFFAVStreamer.h and QTFFAVStreamer.m files. Here is what the app does:
- Captures video using the computer’s video camera, using the QTKit framework.
- Feeds captured video frames to an FLV encoder (FFmpeg), which has been configured with a time_base.den of 30 (30fps).
- Streams encoded video frames over RTMP (with the current configuration) to an external server. (You can change the URL — this is all also accomplished with FFmpeg).
What you are likely to find is that QTKit is going to deliver frames at 15fps with double duration. In the past (I haven’t tested various configurations lately), feeding 15fps to the encoder with the pts dts and duration received will render playback (tested on multiple players with identical results) be out of sync.
If you can identify what the problem is, and demonstrate that variable frame rates works, I will be greatly appreciative. In the meantime, I’ll take a look at what ffmpeg.c is looking like these days, and see if I can’t glean a solution there.
More information about the Libav-user