[FFmpeg-devel] [PATCH] Sync the NTP timestamps for RTP streams

Martin Storsjö martin
Mon Mar 8 10:34:02 CET 2010


Hi,

As discussed earlier, the NTP timestamps in RTCP sender reports are used 
to sync multiple RTP streams together. If first_rtcp_ntp_time in RTP 
muxers differ, though, the individual streams get out of sync.

Earlier, the problem was eased by initializing first_rtcp_ntp_time in 
rtp_write_header instead of initializing it when sending the first RTCP 
sender report. The correct solution would be to coordinate a common value 
for this field to all RTP muxers that belong to the same session.

The attached patch series is an attempt at this. First the ntp_time 
function is made public, since the caller (be it the RTSP muxer or an 
external libavformat user) will need it to set coordinated NTP start 
timestamps. Is this ok, or should it be ff_ prefixed and left internal to 
libavformat for now?

Then the RTP muxer is made to check for a metadata with the key 
"ntp_start_time", and set the first_rtcp_ntp_time with the value in that 
key, if present. Is this acceptable, or should another field be added to 
AVFormatContext for this?

Lastly, the RTSP muxer uses this to coordinate the start NTP time for all 
RTP sessions. Is adding a field to RTSPState for this ok? This needs to be 
set once for the whole RTSP session, but is needed deep within the call 
stack, in rtsp_rtp_mux_open, so passing it through as an argument isn't 
awkward. Another option would be to store it in metadata for the RTSP 
AVFormatContext.

Without this, the individual RTP streams of an RTSP muxer session are out 
of sync by the amount of time it takes to do the RTSP SETUP for the later 
streams, which can be very noticeable.

// Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Make-av_ntp_time-a-publicly-available-function.patch
Type: text/x-diff
Size: 2823 bytes
Desc: 
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100308/0cb5bf90/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Allow-specifying-the-start-ntp-time-through-the-ntp_.patch
Type: text/x-diff
Size: 1187 bytes
Desc: 
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100308/0cb5bf90/attachment-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Set-the-ntp_start_time-metadata-key-for-output-RTP-m.patch
Type: text/x-diff
Size: 2210 bytes
Desc: 
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100308/0cb5bf90/attachment-0002.patch>



More information about the ffmpeg-devel mailing list