[Libav-user] Repeating frame while encoding using ffmpeg api

Bradley O'Hearne brado at bighillsoftware.com
Fri Oct 3 17:48:29 CEST 2014

On Oct 3, 2014, at 5:53 AM, Nicolas George <george at nsup.org> wrote:

> I may be wrong, but I find very unlikely that anyone here would help you
> debug hundreds of lines of code in a fringe language for a proprietary
> operating system.

I do believe there are claims to support OS X, which is Darwin, which is a essentially a *nix derivative. If FFmpeg doesn’t work as intended on or support OS X, then it would be a good idea to update the FFmpeg web site and doc to state this explicitly.

> If you want to be able to expect help realistically, I
> believe you need to trim down your code to the bare minimum exhibiting the

I already did so — I directed you toward QTFFAVStreamer.m, where the relevant FFmpeg code resides. If you want a further narrowing of the code, see the 

- (BOOL)streamVideoFrame:(CVImageBufferRef)frameBuffer
            sampleBuffer:(QTSampleBuffer *)sampleBuffer
                   error:(NSError **)error;

method in the QTFFAVStreamer.m file. That method takes a captured frame, encodes the frame, and streams the frame. That method is where the issue resides. Note — previous requests on this list desired a fully working code example. What I have posted satisfies this requirement as well. So either way, requisite code is provided. 


As an alternative, to support the claim that FFmpeg supports variable FPS encoding, you could provide a working code sample which shows this, or the FFmpeg developers could (should) add this to the examples accompanying the source. I’d jump on revisiting the code I posted provided that there was some example to follow which demonstrated this. I reviewed FFmpeg.c, and I couldn’t put my finger on where exactly this was shown. This code isn’t documented, and there’s no explanation for what the lines of code inside this file are doing (or attempting to), so without some further resource, I didn’t find the answer readily available there. 

Long story short — if I feed 15fps (or anything lower than 30fps) to an encoder with a time_base.den of 30, playback is at double the speed, regardless of what else I do. I have tried: 

- Changing pts, dts, and duration. 

- Changing time_base.den. 

None of those worked. Only encoding each frame multiple times, with consistent pts and dts (in other words, giving the codec exactly time_base.den frames) worked. This also wasn’t an issue of the player either. I tested playback on VLC, Wondershare, and Adobe Flash player — all with identical results. This is an encoder issue. 

In addition to my own issues, since I posted this ~ a year ago, I’ve had several contact me off-list with exactly the same problem, seeing exactly the same results. So given that this isn’t an issue only I am experiencing, this whole thing can be made a moot point if sample code is provided (please at least minimally document it so that someone who reads it has some inkling of what it does) which just demonstrates the functionality. I understand that some claim FFmpeg - (libraries, not the binary) can handle this, and I don’t even doubt it, but to date, I’ve seen no code anywhere which shows this. I’ll be the first one to laud and believe. Just post the code. 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20141003/b30654ca/attachment.html>

More information about the Libav-user mailing list