[FFmpeg-devel] [PATCH] ffmpeg: apply discontinuity adjustment per-stream
Gyan Doshi
ffmpeg at gyani.pro
Tue Jan 10 18:02:28 EET 2023
On 2023-01-10 04:32 pm, Anton Khirnov wrote:
> Quoting Gyan Doshi (2023-01-03 11:22:17)
>> At present, the offset for discontinuity adjustment is applied per-file but
>> the check for discontinuity is intra-stream so the same discontinuity when
>> seen in multiple streams with copyts, leads to compounded adjustment of the
>> discontinuity offset. This introduces gaps in streams, leading to loss of sync
>> or even de facto loss of stream.
>>
>> The ts_offset_discont parameter is transferred to InputStream and adjusted
>> based on intra-stream gaps.
> I never had much use for this feature, but I wonder if adding different
> offsets to different streams isn't going against the whole point of
> timestamps, which is synchronizing them.
A robust method would have to look at the inter-stream delta among first
packets in each stream after the jump,
which neither the existing code nor my changes do.
The existing code compares dts against next_dts for the stream where the
jump is first seen, and derives the offset from that.
That offset adjustment applied to all other streams may not preserve the
inter-stream deltas for the packets after the jump
since inter-frame intervals in each stream will be different. In
practice, the discrepancy is going to be minor, except for pathological
inputs.
But this patch avoids the compounded adjustment currently being applied,
which makes the output defunct, or worse frozen and
a CPU/memory hog if video encoding is CFR.
Regards,
Gyan
More information about the ffmpeg-devel
mailing list