[Libav-user] Video and audio timing / syncing
brado at bighillsoftware.com
Mon Apr 1 08:36:51 CEST 2013
On Mar 31, 2013, at 10:40 PM, Brad O'Hearne <brado at bighillsoftware.com> wrote:
> On Mar 31, 2013, at 10:37 PM, Kalileo <kalileo at universalx.net> wrote:
>> Being able to change the fps value on the fly might be a simpler way than to give each frame a duration.
> Can that be done? I was under the impression that time_base.den had to be set up front and couldn't be changed mid-encoding. If changing the time_base.den every frame is perfectly fine, and won't corrupt things, then that certainly would be the way to go.
Presuming there's no unknowns about changing the time_base.den on the fly throughout encoding, problem solved. Throughout the weeks of Googling and reading endless source code, forum / mailing list posts, blogs, etc. on this, I had picked up the impression that time_base.den was to be set once prior to encoding and not mucked with thereafter. However, I just used the duration to calculate the frame rate and now I'm setting the time_base.den prior to pts and dts for every frame. Works great.
Provided that there aren't any surprises in returning back to outputting over a network stream (I had changed my original need to outputting to a file for simpler testing), it appears I've bested this use case. I want to thank everyone who took time to dialog and lend their knowledge and assistance with my questions, it is greatly appreciated.
While it was moderately easy to get an initial body of source code together for solving this problem, this was a fairly difficult problem to solve. There were many nuances and things to figure out which never surfaced in questions I posted to this mailing list. Answers to questions were not easy to find -- I'm not sure about the history of the source code, but the examples and posts around the Internet seemed to present a fair number of red herrings and disinformation (perhaps unintended). Anyway, this is all to say that the source code I used to prototype this pipeline is out on Github, free for anyone else's reference:
Hopefully this will help any new travelers using FFmpeg on a Mac, encoding with QTKit, and perhaps save them a little time down the road.
Thanks again to everyone who helped,
More information about the Libav-user