x264enc: Segment changes can cause invalid DTS to be generated
See below log of mp4mux
. in
is the PTS/DTS from x264enc
, out
is the corresponding running time with the currently configured segment.
in: pts 1000:00:01.666666667 dts 1000:00:01.600000000 dur 0:00:00.033333333
segment: time segment start=999:59:58.858892452, offset=0:00:01.141107548, stop=99:99:99.999999999, rate=1.000000, applied_rate=1.000000, flags=0x00, time=0:00:00.000000000, base=0:00:00.000000000, position 999:59:58.858892452, duration 99:99:99.999999999
out: pts 0:00:01.666666667 dts 0:00:01.600000000 dur 0:00:00.033333333
in: pts 1000:00:01.633333333 dts 1000:00:01.633333333 dur 0:00:00.033333333
segment: time segment start=999:59:58.858892452, offset=0:00:01.141107548, stop=99:99:99.999999999, rate=1.000000, applied_rate=1.000000, flags=0x00, time=0:00:00.000000000, base=0:00:00.000000000, position 999:59:58.858892452, duration 99:99:99.999999999
out: pts 0:00:01.633333333 dts 0:00:01.633333333 dur 0:00:00.033333333
in: pts 1000:00:01.700000000 dts 1000:00:01.666666667 dur 0:00:00.033333333
segment: time segment start=999:59:58.858892452, offset=0:00:01.141107548, stop=99:99:99.999999999, rate=1.000000, applied_rate=1.000000, flags=0x00, time=0:00:00.000000000, base=0:00:00.000000000, position 999:59:58.858892452, duration 99:99:99.999999999
out: pts 0:00:01.700000000 dts 0:00:01.666666667 dur 0:00:00.033333333
[new segment -- shifted by about 3s]
in: pts 1000:00:03.733333333 dts 1000:00:01.700000000 dur 0:00:00.033333333
segment: time segment start=999:59:58.858892452, offset=0:00:03.041107548, stop=99:99:99.999999999, rate=1.000000, applied_rate=1.000000, flags=0x00, time=0:00:00.000000000, base=0:00:00.000000000, position 999:59:58.858892452, duration 99:99:99.999999999
out: pts 0:00:01.833333333 dts 99:99:99.999999999 dur 0:00:00.033333333
in: pts 1000:00:03.833333333 dts 1000:00:01.800000000 dur 0:00:00.033333333
segment: time segment start=999:59:58.858892452, offset=0:00:03.041107548, stop=99:99:99.999999999, rate=1.000000, applied_rate=1.000000, flags=0x00, time=0:00:00.000000000, base=0:00:00.000000000, position 999:59:58.858892452, duration 99:99:99.999999999
out: pts 0:00:01.933333333 dts 99:99:99.999999999 dur 0:00:00.033333333
[DTS has caught up]
in: pts 1000:00:03.766666667 dts 1000:00:03.733333333 dur 0:00:00.033333333
segment: time segment start=999:59:58.858892452, offset=0:00:03.041107548, stop=99:99:99.999999999, rate=1.000000, applied_rate=1.000000, flags=0x00, time=0:00:00.000000000, base=0:00:00.000000000, position 999:59:58.858892452, duration 99:99:99.999999999
out: pts 0:00:01.866666667 dts 0:00:01.833333333 dur 0:00:00.033333333
Maybe the correct behaviour of x264enc
would be to always drain on segment changes to avoid this?