[Libav-user] Setting audio Stream TS offset to correct AV sync

Ameya Tambekar ameya at cammy.com
Wed May 31 03:26:04 EEST 2017


Hi There,

I am trying to MUX H264 video and AAC audio into a TS file. The sources of these streams are separate and provide NTP timestamps for each frame.

I have decided to go with video master TS mode to use NTP timestamp of first video frame as reference to calculate PTS values before MUXing. I also drop all the audio frames received before first video frame.

I am not able to achieve proper AV sync and my audio is leading by the difference in NTP timestamps of respective first frames.

e.g. 

1. First Video Frame - 	NTP 11:00:00:000 	- Duration 30mSec 		- PTS=0 		timebase{1,90000}
2. First Audio Frame - 	NTP 11:00:00:040 	- Duration 70 mSec 	- PTS= 3600 	timebase{1,90000}
3. Second V Frame	  -	NTP  11:00:00:030 	- Duration 30mSec 		- PTS= 2700 	timebase{1,90000}
4. Third V Frame       -	NTP  11:00:00:060 	- Duration 30mSec 		- PTS= 7200 	timebase{1,90000}
5. Forth V Frame       -	NTP  11:00:00:090 	- Duration 30mSec 		- PTS= 8100 	timebase{1,90000}
6. Second  A Fram     -	NTP  11:00:00:110 	- Duration 70mSec 		- PTS= 9900 	timebase{1,90000}
7. Fifth V Frame         -	NTP  11:00:00:120 	- Duration 30mSec 		- PTS= 10800 	timebase{1,90000}


For the above case the drift is 40mSec. If I correct Audio sync by -40mSec VLC plays the video just fine.

Please let me know if my logic is right and if not suggest a correction. Am I supposed to set an output_ts_offset to correct the drift and if yes how to do that?

Regards,
Ameya Tambekar

_______________________________________________
Libav-user mailing list
Libav-user at ffmpeg.org <mailto:Libav-user at ffmpeg.org>
http://ffmpeg.org/mailman/listinfo/libav-user <http://ffmpeg.org/mailman/listinfo/libav-user>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20170531/b23528a8/attachment.html>


More information about the Libav-user mailing list