GNOME Bugzilla – Bug 796540
x264enc destroying pts
Last modified: 2018-06-08 11:13:43 UTC
If I run gst-launch-1.0 videotestsrc is-live=true do-timestamp=true num-buffers=1 ! video/x-raw ! identity silent=false name=first ! x264enc ! video/x-h264 ! identity name=second silent=false ! fakesink -v then the dts and pts are changed and reset by the x264enc. I don't think this is correct as I would have thought that the pts should stay the same. The output of identity "first" is: ******* (first:sink) (115200 bytes, dts: 0:00:00.011741158, pts: 0:00:00.005870579, duration: 0:00:00.033333333 The output of identity "second" which is post x264enc is: ******* (second:sink) (5795 bytes, dts: 1000:00:00.000000000, pts: 1000:00:00.000000000, duration: 0:00:00.033333333 I've looked at other encoders and they keep the pts as you would expect.
pts/dts values don't have any meaning in themselves, they only make sense in connection with the GstSegment that goes with them. x264enc will also adjust the GstSegment accordingly to make sure the frames don't end up shifted despite the timestamp offset. This is needed to handle negative dts properly, see bug #731351. So this is intentional.
Thanks Tim - I didn't realise that. So how do I sync 2 x264enc streams from different machines? If one is encoded with zerolatency and the other not, they don't sync correctly - they're around a second out.
You sync using the "running time" which you can calculate from the segment and the timestamps: https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstSegment.html#gst-segment-to-running-time https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstSegment.html#gst-segment-position-from-running-time-full
Thanks again Tim. But if both machines have synced ntp clocks, but start at different absolute times, using rtpbin to send to a central machine, should not the remote rtpbin automatically collect and reassemble using rtcp-sync-send-time=false. I realise this is probably not the place to have this discussion but I've had no response on the gstreamer-devel mails.
Indeed, this is not really the place for that, sorry :) You might find some useful info in this talk: https://gstconf.ubicast.tv/videos/synchronised-multi-room-media-playback-and-distributed-live-media-processing-and-mixing-with-gstreamer/