Fix A/V desync when resuming HLS with video transcode + audio copy - #16580
Conversation
|
I'd considered this when writing my own PR, but came to the conclusion that this actually disables audio stream copy. From the ffmpeg docs for
The important word here is decodes - AFAIU this means that ffmpeg is doing a decode-encode round trip on the audio stream, which is exactly what we wanted to avoid. Is my understanding incorrect? If my understanding is correct, then this PR is only adding another way of doing what |
take a look at the part I think in that case ffmpeg is doing copy, no decode-encode round trip. When we force it you will get and here we can see round-trip and there is with copy mode there is no mention of |
9e77023 to
fb66760
Compare
|
Is there any reason to not revert #15926 if this is merged? This PR just appears like a better fix for the problems that PR fixes. A full revert probably wouldn't be desirable as #15926 also removed some outdated parameters and fixed up some cases in the HLS controller, but at the very least this PR would make |
Jellyfin API (v 10.12.0)What's Changed
|
gnattu
left a comment
There was a problem hiding this comment.
This works in principle but I do noticed a slight regression in seek performance for very large files, but it was already slow enough which makes this regression likely irrelevant.
We can still keep the transcode strategy for some very edgy cases, where output seeking breaks, which means we can make current filter as another audio seek strategy.
I do not have any sample that the strategy in this PR breaks though, but for changes like this I do prefer to let the user decide for now because our users have far more video sample than myself and can usually hit the edge case.
| return string.Format( | ||
| CultureInfo.InvariantCulture, | ||
| "{0} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4} {5} -copyts -avoid_negative_ts disabled -max_muxing_queue_size {6} -f hls -max_delay 5000000 -hls_time {7} -hls_segment_type {8} -start_number {9}{10} -hls_segment_filename \"{11}\" {12} -y \"{13}\"", | ||
| "{0} {1}{2} -map_metadata -1 -map_chapters -1 -threads {3} {4} {5} {6} -copyts -avoid_negative_ts disabled -max_muxing_queue_size {7} -f hls -max_delay 5000000 -hls_time {8} -hls_segment_type {9} -start_number {10}{11} -hls_segment_filename \"{12}\" {13} -y \"{14}\"", |
There was a problem hiding this comment.
Maybe we should refactor this in the future, this is currently uh, too many numbers
There was a problem hiding this comment.
It was my first impression, but I want to be consistent with other parts of the code
nyanmisaka
left a comment
There was a problem hiding this comment.
This change may result in corrupted frames being output by the decoder, which will also annoy users.
Decoder errors (software and hardware are affected)
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> hevc (hevc_nvenc))
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[h264 @ 0000020acb482dc0] cabac_init_idc 4 overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
Output #0, mp4, to 'R:\0.mp4':
Metadata:
encoder : Lavf62.12.100
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
Stream #0:0: Video: hevc (Main) (hev1 / 0x31766568), cuda(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 8000 kb/s, 60 fps, 15360 tbn
Metadata:
encoder : Lavc62.28.100 hevc_nvenc
BPS : 4444527
DURATION : 00:01:00.034000000
NUMBER_OF_FRAMES: 3601
NUMBER_OF_BYTES : 33352848
_STATISTICS_WRITING_APP: mkvmerge v94.0 ('Initiate') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2025-07-28 12:13:52
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Side data:
CPB properties: bitrate max/min/avg: 8000000/0/8000000 buffer size: 16000000 vbv_delay: N/A
[h264 @ 0000020acb480cc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb480cc0] no frame!
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp (default)
Metadata:
BPS : 125667
DURATION : 00:01:00.023000000
NUMBER_OF_FRAMES: 2585
NUMBER_OF_BYTES : 942869
_STATISTICS_WRITING_APP: mkvmerge v94.0 ('Initiate') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2025-07-28 12:13:52
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
Last message repeated 1 times
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0000020acb482dc0] reference count overflow
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb480cc0] reference count overflow
[h264 @ 0000020acb480cc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Error submitting packet to decoder: Invalid data found when processing input
[h264 @ 0000020acb482dc0] deblocking_filter_idc 15 out of range
[h264 @ 0000020acb482dc0] no frame!
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Decoding error: Invalid data found when processing input
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Decode error rate 0.946903 exceeds maximum 0.666667
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Task finished with error code: -1145393733 (Error number -1145393733 occurred)
[vist#0:0/h264 @ 0000020ac86fedc0] [dec:h264 @ 0000020aca300880] Terminating thread with return code -1145393733 (Error number -1145393733 occurred)
There was a problem hiding this comment.
It turns out that the corruption frame was caused by an open gop file, and it would fail to output first few frames after seeking to some point no matter what, regardless of the change.
However, I think this should have undergone more testing before being merged.
Wouldn't the risk here be low if like gnattu suggest this gets implemented as a 3rd option for the in master configurable option on strategy? (I forgot the 2 options in master, I think old behavior, and transcode audio) so this would be a 3rd. Depending on what is the default there is a fallback or this can be offered as an opt-in before it becomes the default. |
nyanmisaka
left a comment
There was a problem hiding this comment.
Ultimately, I encountered a playback issue in HLS.js due to using an external audio stream.
The video was in an MKV container, while the FLAC audio was in an external MKA container. HLS.js kept requesting the two segments after a seek, even though they had already been downloaded. The issue disappeared after I reverted the change.
|
External audio might not be the only edge case that users might face, I do think it is necessary to make it one of the configurable option so that users won't just got broken playback without workarounds, if they faced compatibility issues of this behavior. By making it configurable we don't have to identify and fix all edge cases before merging. |
It can be added as a new configurable option and should be disabled at least when remuxing external audio. |
|
I investigated the external audio issue @nyanmisaka reported and found the root cause. When using output-level -ss with -output_ts_offset and -copyts, ffmpeg's interleaving queue sees a large DTS gap between encoded video and stream-copied audio. This exceeds the default max_interleave_delta threshold (10s), causing ffmpeg to force-flush video packets before audio arrives — producing HLS segments without audio. This affects both fMP4 and TS segments. Adding -max_interleave_delta 0 alongside -ss and -output_ts_offset prevents the forced flush. I verified this fixes the external audio case (MKV + external MKA/FLAC) and tested 7 edge cases:
I'm not sure about 3rd option. I feel like this should be maybe separate option. Because I want ie. use Monosnap.screencast.2026-04-09.13-53-04.mp4 |
What is the use case to use both transcode audio and this PR? Could you elaborate? |
I was thinking about option when I want to use DisableAccurateSeek and output seek. I was thinking that having DisableAccurateSeek set we will add So I guess we can have 3 options:
|
Thank you for looking into it, but in my affected files, adding Here's the ffmpeg log: FFmpeg.Transcode.log.txt |
|
When I tested this on longer files I have the same problem. I think I think the strange thing is that I need to set |
|
@nyanmisaka it was strange to me that when we are using With this patched version we need only to use Can you play around with your content if this fix things? |
|
The added |
When Jellyfin restarts ffmpeg with -ss for a mid-video resume, the demuxer seeks to the nearest source keyframe which may be seconds before the target time. The video encoder discards frames before the target and starts precisely, but copied audio starts from the keyframe position, creating audible A/V desync (300ms+, depending on source keyframe interval). Add an output-level -ss after -i to trim the copied audio to match the transcoded video start point. This is the standard ffmpeg technique for combining fast seeking (input -ss) with precise output alignment (output -ss). The fix only applies when video is transcoded and audio is copied, which is the scenario described in jellyfin#14194. Fixes jellyfin#14194
Add -max_interleave_delta 0 to the output seek parameters to prevent ffmpeg from force-flushing video-only HLS segments when audio is stream-copied. The output -ss causes ffmpeg's of_streamcopy to subtract start_time from stream-copied audio timestamps (e.g. 60s becomes 0s) while encoded video retains its original timestamps from the trim filter (stays at 60s). This DTS gap exceeds the default max_interleave_delta threshold (10s), causing the muxer to flush video packets before audio arrives, producing HLS segments without audio. This affects both fMP4 and TS segment formats.
Instead of always applying the output seek, gate it behind a new OutputSeek strategy so users can choose between: - DisableAccurateSeek (default): audio copy, may desync - TranscodeAudio: re-encodes audio, accurate but costs CPU - OutputSeek: audio copy with output-level -ss, accurate, low overhead
With the ffmpeg fix for stream-copied audio timestamp handling (of_streamcopy), -copyts alone preserves correct timestamps without needing -output_ts_offset to shift them back. The -max_interleave_delta 0 workaround is also no longer needed since audio packets are no longer prematurely discarded by the trim logic. The output -ss is kept to trim both streams to the exact seek position after the keyframe-imprecise input seek.
When Jellyfin seeks mid-video, -ss lands on the previous keyframe. For transcoded video, accurate_seek (the default) discards decoded frames before the target. For stream-copied audio, no decoder runs, so audio starts from the keyframe — potentially seconds before the video. Previously, -noaccurate_seek was used on fMP4 to work around this by making video also start at the keyframe. This fixed A/V sync but made segments start at the wrong time (3-10s too early), causing subtitle desync and SyncPlay drift. For mpegts (majority of clients), no workaround existed at all. Replace -noaccurate_seek with the noise bitstream filter: -bsf:a noise=drop='lt(pts*tb,<seek_seconds>)' This drops copied audio packets before the seek target at the demuxer level. Combined with accurate_seek trimming the transcoded video, both streams now start at the exact target time. The fix applies to both mpegts and fMP4 containers, resolving the desync for all HLS clients. No patched ffmpeg needed — the noise bsf with drop expressions has been available since ffmpeg 5.0. Fixes jellyfin#14194
…meter Tests verify that the noise bitstream filter is correctly applied when: - HLS + transcode video + copy audio → bsf added with seek time - Works for both mpegts and fMP4 segment containers And NOT applied when: - Both streams transcoded (accurate_seek handles both) - Both streams copied (no trim needed) - Video copied + audio transcoded (accurate_seek trims audio) - Non-HLS jobs (Progressive) - WTV input (excluded per existing workaround) - Zero or null seek time
The noise bsf approach no longer disables accurate seeking — it uses accurate seek for video and trims copied audio with a bitstream filter. Rename the enum value to reflect what it actually does. Existing user configs with DisableAccurateSeek in encoding.xml will fall back to the default (0) which is the same value, so behavior is preserved.
4ecf800 to
4a9c515
Compare
|
|
The previous iteration of this PR used an output-level |
The A/V desync only affects ffmpeg's threaded CLI rewrite introduced in 7.0; earlier versions trim copied audio correctly during output seek.
Move the seek-side noise filter into GetAudioBitStreamArguments so it co-exists with aac_adtstoasc as a comma-separated chain instead of two conflicting -bsf:a flags (the second would have overridden the first for HLS fMP4 segments built from MPEG-TS/AAC/HLS sources).
Drop the >= 7.0 ffmpeg version gate. Cross-version tests show the copied-audio leak under input -ss exists identically on ffmpeg 6.1.4, 7.1.3, and 8.0.1, so gating the workaround was a false hypothesis.
|
BSFs applied to inputs is only available since 7.0 (ae06111d74)
For earlier versions, you will need copyts and output BSF arg.
Support for expr in noise is since 5.0
Regards,
Gyan
…On 2026-05-21 01:04 pm, Piotr Niełacny wrote:
***@***.**** commented on this pull request.
------------------------------------------------------------------------
In MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
<#16580 (comment)>:
> && !string.Equals(state.InputContainer, "wtv", StringComparison.OrdinalIgnoreCase))
{
- seekParam += " -noaccurate_seek";
+ var seekSeconds = time / (double)TimeSpan.TicksPerSecond;
+ seekParam += string.Format(
+ CultureInfo.InvariantCulture,
+ " -bsf:a noise=drop='lt(pts*tb\\,{0:F3})'",
Well, this filter thing is working on each version of ffmpeg. So there
is no need for version check. I'm not sure if we want to support both
output |-ss| and filter based on the version. This is working on every
version so I would stick to that.
—
Reply to this email directly, view it on GitHub
<#16580 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEXUANB42WR5ZXCU5BNWY3432WPVAVCNFSM6AAAAACXODHRMKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHM2DGMZUHA3TQMJYGE>.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
The noise bsf's drop= parameter was added in ffmpeg 5.0. On 4.x the
filter exists but rejects the option ('Option drop not found'), which
would abort the HLS transcode. Skip the noise trim on < 5.0 and fall
back to the un-trimmed copied-audio behavior matching master.
Verified end-to-end against ffmpeg 4.4.6 / 6.1.4 / 7.1.3 / 8.0.1: on
4.4.6 only aac_adtstoasc is emitted (audio leak unchanged from master,
no regression); on >= 5.0 the chained noise+aac_adtstoasc produces
A/V alignment within one AAC frame.
|
| /// remains stream-copied (no re-encoding overhead). | ||
| /// </summary> | ||
| DisableAccurateSeek = 0, | ||
| TrimCopiedAudio = 0, |
There was a problem hiding this comment.
Without a migration, won't this break existing configs?
There was a problem hiding this comment.
In encoding.xml, this is stored as the value of the enum instead of the name of the enum, so I guess it should be safe? Moreover, these enums were introduced in unstable.
There was a problem hiding this comment.
Yes, we store only value. But after change DisableAccurateSeek does not make sense as the name.
There was a problem hiding this comment.
Plus the change that added DisableAccurateSeek hasn't been released to any stable versions of Jellyfin yet, and it hasn't been exposed in the WebUI either (can't find the PR adding it right now but it has not been merged).
There was a problem hiding this comment.
It's here, but it needs some updates: jellyfin/jellyfin-web#7473
There was a problem hiding this comment.
I just updated the web PR 👍



Changes
When Jellyfin restarts ffmpeg mid-video with
-ss(e.g., user resumes playback or seeks beyond the transcoded buffer), the demuxer seeks to the nearest source keyframe, which may be seconds before the target. For transcoded video, ffmpeg'saccurate_seek(the default) discards decoded frames before the target — so video starts at the right time. But stream-copied audio bypasses the decoder entirely, so it starts from the keyframe position — potentially seconds before the video.This creates segments where audio and video start at different times, causing A/V desync, subtitle offset, and SyncPlay drift. The issue affects both mpegts and fMP4 containers.
This PR replaces the previous
-noaccurate_seekworkaround with ffmpeg'snoisebitstream filter:https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/22765#issuecomment-36410
This drops copied audio packets before the seek target at the demuxer level. Combined with
accurate_seektrimming the transcoded video, both streams now start at the exact target time. No patched ffmpeg needed — thenoisebsf with drop expressions has been available since ffmpeg 5.0 (https://code.ffmpeg.org/FFmpeg/FFmpeg/commit/23da5caf09).ffmpeg command before (fMP4 only):
Video AND audio both start at keyframe (60s) — aligned but 3s too early.
ffmpeg command before (mpegts — no workaround existed):
Video starts at 63s (accurate_seek trims it), audio starts at 60s — 3s A/V desync.
ffmpeg command after (both containers):
Both video and audio start at 63s — aligned and accurate.
Reproduction and measurements:
Step 1: Generate test source (HEVC + AAC, keyframes every 10s)
ffmpeg -y \ -f lavfi -i "testsrc2=size=640x360:rate=24000/1001:duration=120" \ -f lavfi -i "aevalsrc='if(lt(mod(t,1),0.03),0.8*sin(2*PI*1000*t),0)':s=48000:d=120" \ -map 0:v -map 1:a \ -c:v libx265 -preset fast -crf 28 \ -x265-params "keyint=240:min-keyint=240" \ -c:a aac -b:a 128k \ -t 120 \ desync_test.mkvThis produces HEVC video (which Jellyfin must transcode to H.264 for browsers) with AAC audio (which Jellyfin can copy). Keyframes every 10s to create a measurable gap when
-sslands between them.Step 2: Reproduce on stock ffmpeg (no patches needed)
Step 3: External audio file (separate .mka)
Step 4: Video-only (no audio stream)
The bsf is harmless when no audio stream exists — ffmpeg ignores
-bsf:aon inputs without audio.mkdir noaudio ffmpeg -y -ss 00:01:03.063 \ -bsf:a "noise=drop=lt(pts*tb\,63.063)" \ -i video_only.mkv \ -map 0:v \ -c:v libx264 -preset veryfast -crf 23 \ -force_key_frames "expr:gte(t,n_forced*3)" \ -copyts -avoid_negative_ts disabled \ -f hls -hls_time 3 -hls_segment_type fmp4 \ -hls_fmp4_init_filename "init.mp4" -start_number 21 \ -hls_segment_filename "noaudio/seg%d.mp4" \ -hls_playlist_type vod -hls_list_size 0 \ -hls_segment_options movflags=+frag_discont \ noaudio/playlist.m3u8Step 5: Measure segment timestamps with ffprobe
Results (stock ffmpeg 8.0, source keyframes at 60.06s, 70.07s, seek to 63.06s):
Single input (muxed video+audio):
External audio (separate .mkv + .mka):
Video-only (no audio stream):
The bsf fixes audio alignment for both single-input and external-audio cases, and is harmless when no audio stream is present.
Performance (3-hour HEVC+AAC source, seek to 1:30:00, transcode video + copy audio, 1800 HLS segments):
Overhead: ~0.8% (~0.36s on a 44s transcode). The bsf evaluates one float comparison per audio packet — negligible compared to video encoding. Output size and segment count are identical.
Issues
Fixes #14194
This issue was extensively discussed in #15845 and PR #15926. The existing
HlsAudioSeekStrategyenum previously offered two options:DisableAccurateSeek(default): used-noaccurate_seekon fMP4 to align streams at the keyframe position, but caused subtitle desync and inaccurate player timestamps. Did nothing for mpegts.TranscodeAudio: forces audio re-encoding when video is transcoded, which fixes sync but wastes CPU.As @abitofevrything noted in #15845:
The noise bsf approach achieves exactly that — accurate timestamps with audio copy preserved, on both mpegts and fMP4, with no ffmpeg patches and no extra transcoding overhead. The approach was suggested by @GyanD (FFmpeg maintainer) in https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/22765.
What changed:
EncodingHelper.GetFastSeekCommandLineParameter(): replaced-noaccurate_seekwith-bsf:a noise=drop='lt(pts*tb\,<seconds>)'HlsAudioSeekStrategy.DisableAccurateSeekrenamed toTrimCopiedAudioto reflect the new behaviorOutputSeekstrategy from earlier iterationRelevant discussions: