[Libav-user] strange H264 audio sync behavior
Bradley O'Hearne
brado at bighillsoftware.com
Thu Jun 26 17:26:34 CEST 2014
On Jun 25, 2014, at 4:29 AM, Marco Sieber <l-spy at web.de> wrote:
> I'm topposting because its my own.... i cant wait months for solutions, so because nobody had some crisp thoughts on that or even solutions....
> So this is considered as a "push"....
>
> it didnt work with ffmpeg 2.x, like i thought... i guess i have to calculate pts/dts differently. i feel like the defaults in all the example arent enough.
> maybe i will start to figure out how quicktime decodes or plays the video... how it reads the pts/dts, if it reads them..
>
> im clueless... but i dont want to discard all or using another framework.
Marco — I empathize with your difficulties, I had similar. All I can pass on is my experience. My use case was real-time webcam capture, encoding, and streaming frames to a server — I had sync and playback problems too. I inquired on this mailing list, and was told setting pts / dts would correct the problem. Weeks of testing didn’t prove that to be true in my case. The only way to make syncing and playback work was that you absolutely had to provide whatever # of frames was set in the codec’s time_base to the encoder *whether you received them or not*. In other words, if the time base indicated 30fps, you couldn’t provide 15fps with proper pts and dts (double duration). Playback (on any number of video players) would try to process half the frames at 30fps, and thus the video played at double the speed (half the proper time).
I had this exact scenario — I was receiving exact pts / dts from the capture source, but feeding that to the encoder didn’t work. The only way I could get this to work was to force-feed 30 fps to the encoder. In other words, if receiving 15 fps from the source, I had to feed each frame to the encoder twice with modified pts / dts so that the encoder got its 30fps. Again, I was working real-time, so if you are not, then perhaps your situation is different.
That’s the only light I can shed on experience with FFmpeg and pts / dts — I read all the recommended docs on it, read through source code, and though I tried every way I knew how, fixing those two things only doesn’t solve all sync and playback issues. I know (well) that others will dispute this. But at the end of the day, I produced code which proved otherwise, and posted it to this list, and that was never demonstrated to be wrong. And for what its worth, I had several people contact me off-list after I posted this to confirm they were seeing the same behavior in their code. So take it for what it is — if there is another explanation as to why this is, I am unaware, but if one does surface, suffice to say I’ll be as interested as you.
I don’t know if that helps, but that’s the best I can do to help. At the very least, I hope it leads to a good direction to getting things solved.
Good Luck.
Brad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140626/336cd698/attachment.html>
More information about the Libav-user
mailing list