New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skipped Frames at the beginning of file with some decoders #113
Comments
This is a typical issue in broadcast streams because the number of B-frame reordering isn't known right from the start, so to minimize decode latency (which is especially relevant for Live TV) LAV "guesses", unfortunately if the guess is too low it has to drop a frame when it corrects itself. The guessing goes especially wrong if different GOP structures are mixed, but the stream is otherwise perfectly valid. I adjusted the guessing logic a bit to always consider at least two out-of-order frames, which seems most common in real-world broadcast streams, and this avoids the problem with this particular sample, but there are no guarantees that it won't come back later with others. |
This avoids dropping frames in the most common broadcast streams while still keeping decode latency low. Fixes GitHub issue #113
That was incredibly fast! Thanks.
|
|
|
The POC is not reliable for this, if there is a hole in the POCs you don't know if any future frame is going to fill it, or if its just going to remain open - there are no guarantees that every single "slot" is used. Memory use can be impacted as these re-ordered frames are not necessarily reference frames, although the memory aspect is not something i'm very concerned with. I have been considering just stickting to standards-compliant behavior and buffer more frames, but in reality the "guessing" based on measuring the delay in the first GOP works fine in 99% of all cases. |
Thanks for everything again (including your patient explanations). I just checked the file with release 0.69 and it really works. Job well done! |
…ed as DISCARD They do not count towards the codec delay, and are used to signal, for example, edit list edits. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Hello,
I have an issue with some missing frames at the start of a file (not at the very beginning, but close). More specifically, frames 25-27 (frame count starts at zero) of the file "Skipped.Frames.mkv" are skipped when I use software decoding or DXVA (native and copy-back) decoding, but not with Intel Quick Sync. I tested this both with GraphStudioNext and the latest release (0.68.1) and with MPC-HC and its internal filters (based upon 0.66). They are even skipped when I fast-forward frame-by-frame and I cannot seek to these frames. Microsoft's DTV-DVD decoder plays it just fine (at least in hardware; I am unable to test whether it would play it in software, too, because it automatically uses hardware).
The missing frames are b-frames shared between two GOPs (the latter of which is open). Here is an extract from mkvinfo:
| + SimpleBlock (track number 1, 1 frame(s), timecode 0.400s = 00:00:00.400)
| + Frame with size 6081
| + SimpleBlock (track number 1, 1 frame(s), timecode 0.420s = 00:00:00.420)
| + Frame with size 6079
| + SimpleBlock (track number 1, 1 frame(s), timecode 0.440s = 00:00:00.440)
| + Frame with size 5935
| + SimpleBlock (track number 1, 1 frame(s), timecode 0.460s = 00:00:00.460)
| + Frame with size 5923
|+ Cluster
| + Cluster timecode: 0.500s
| + SimpleBlock (key, track number 1, 1 frame(s), timecode 0.640s = 00:00:00.640)
| + Frame with size 48044
| + SimpleBlock (discardable, track number 1, 1 frame(s), timecode 0.560s = 00:00:00.560)
| + Frame with size 10815
| + SimpleBlock (discardable, track number 1, 1 frame(s), timecode 0.500s = 00:00:00.500)
| + Frame with size 3662
| + SimpleBlock (track number 1, 1 frame(s), timecode 0.520s = 00:00:00.520)
| + Frame with size 5051
| + SimpleBlock (track number 1, 1 frame(s), timecode 0.540s = 00:00:00.540)
| + Frame with size 5048
| + SimpleBlock (track number 1, 1 frame(s), timecode 0.580s = 00:00:00.580)
| + Frame with size 1981
| + SimpleBlock (track number 1, 1 frame(s), timecode 0.600s = 00:00:00.600)
| + Frame with size 5238
| + SimpleBlock (track number 1, 1 frame(s), timecode 0.620s = 00:00:00.620)
| + Frame with size 5238
| + SimpleBlock (track number 1, 1 frame(s), timecode 0.760s = 00:00:00.760)
| + Frame with size 35275
| + SimpleBlock (discardable, track number 1, 1 frame(s), timecode 0.660s = 00:00:00.660)
| + Frame with size 988
| + SimpleBlock (track number 1, 1 frame(s), timecode 0.680s = 00:00:00.680)
| + Frame with size 4837
| + SimpleBlock (track number 1, 1 frame(s), timecode 0.700s = 00:00:00.700)
| + Frame with size 4829
And here is an extract from h264_parse. It shows that mkvmerge (which I used to create these mkv's) has made no error in the determining the decoding and presentation orders. The first I-frame is the one with timecode 0.64 above:
Nal length 12 start code 4 bytes
ref 0 type 6 SEI
payload_type: 6 recovery_point
payload_size: 1 0x84
recovery_frame_cnt: 0
exact_match_flag: 0
broken_link_flag: 0
changing_slice_group_idc: 0
payload_type: 1 pic_timing
payload_size: 1 0x4
pict_struct: 0
clock_timestamp_flag[0]: 0
Nal length 47889 start code 4 bytes
ref 2 type 1 Coded slice of non-IDR picture
first_mb_in_slice: 0
slice_type: 7 (I)
pic_parameter_set_id: 0
frame_num: 28 (5 bits)
pic_order_cnt_lsb: 32
Nal is new picture
Nal length 9 start code 4 bytes
ref 0 type 6 SEI
payload_type: 1 pic_timing
payload_size: 1 0x4
pict_struct: 0
clock_timestamp_flag[0]: 0
Nal length 10806 start code 4 bytes
ref 2 type 1 Coded slice of non-IDR picture
first_mb_in_slice: 0
slice_type: 6 (B)
pic_parameter_set_id: 0
frame_num: 29 (5 bits)
pic_order_cnt_lsb: 24
Nal is new picture
Nal length 9 start code 4 bytes
ref 0 type 6 SEI
payload_type: 1 pic_timing
payload_size: 1 0x4
pict_struct: 0
clock_timestamp_flag[0]: 0
Nal length 3652 start code 4 bytes
ref 0 type 1 Coded slice of non-IDR picture
first_mb_in_slice: 0
slice_type: 6 (B)
pic_parameter_set_id: 0
frame_num: 30 (5 bits)
pic_order_cnt_lsb: 18
Nal is new picture
Nal length 9 start code 4 bytes
ref 0 type 6 SEI
payload_type: 1 pic_timing
payload_size: 1 0x4
pict_struct: 0
clock_timestamp_flag[0]: 0
Nal length 5042 start code 4 bytes
ref 0 type 1 Coded slice of non-IDR picture
first_mb_in_slice: 0
slice_type: 6 (B)
pic_parameter_set_id: 0
frame_num: 30 (5 bits)
pic_order_cnt_lsb: 20
Nal is new picture
Nal length 9 start code 4 bytes
ref 0 type 6 SEI
payload_type: 1 pic_timing
payload_size: 1 0x4
pict_struct: 0
clock_timestamp_flag[0]: 0
Nal length 5039 start code 4 bytes
ref 0 type 1 Coded slice of non-IDR picture
first_mb_in_slice: 0
slice_type: 6 (B)
pic_parameter_set_id: 0
frame_num: 30 (5 bits)
pic_order_cnt_lsb: 22
Nal is new picture
Nal length 9 start code 4 bytes
ref 0 type 6 SEI
payload_type: 1 pic_timing
payload_size: 1 0x4
pict_struct: 0
clock_timestamp_flag[0]: 0
Nal length 1972 start code 4 bytes
ref 0 type 1 Coded slice of non-IDR picture
first_mb_in_slice: 0
slice_type: 6 (B)
pic_parameter_set_id: 0
frame_num: 30 (5 bits)
pic_order_cnt_lsb: 26
Nal is new picture
Nal length 9 start code 4 bytes
ref 0 type 6 SEI
payload_type: 1 pic_timing
payload_size: 1 0x4
pict_struct: 0
clock_timestamp_flag[0]: 0
Nal length 5229 start code 4 bytes
ref 0 type 1 Coded slice of non-IDR picture
first_mb_in_slice: 0
slice_type: 6 (B)
pic_parameter_set_id: 0
frame_num: 30 (5 bits)
pic_order_cnt_lsb: 28
Nal is new picture
Nal length 9 start code 4 bytes
ref 0 type 6 SEI
payload_type: 1 pic_timing
payload_size: 1 0x4
pict_struct: 0
clock_timestamp_flag[0]: 0
Nal length 5229 start code 4 bytes
ref 0 type 1 Coded slice of non-IDR picture
first_mb_in_slice: 0
slice_type: 6 (B)
pic_parameter_set_id: 0
frame_num: 30 (5 bits)
pic_order_cnt_lsb: 30
Nal is new picture
Nal length 9 start code 4 bytes
ref 0 type 6 SEI
payload_type: 1 pic_timing
payload_size: 1 0x4
pict_struct: 0
clock_timestamp_flag[0]: 0
Nal length 35266 start code 4 bytes
ref 2 type 1 Coded slice of non-IDR picture
first_mb_in_slice: 0
slice_type: 5 (P)
pic_parameter_set_id: 0
frame_num: 30 (5 bits)
pic_order_cnt_lsb: 44
Nal is new picture
Nal length 9 start code 4 bytes
ref 0 type 6 SEI
payload_type: 1 pic_timing
payload_size: 1 0x4
pict_struct: 0
clock_timestamp_flag[0]: 0
Nal length 979 start code 4 bytes
ref 0 type 1 Coded slice of non-IDR picture
first_mb_in_slice: 0
slice_type: 6 (B)
pic_parameter_set_id: 0
frame_num: 31 (5 bits)
pic_order_cnt_lsb: 34
Nal is new picture
As one can see, this is a pretty long B-chain; and inside this chain, the decode and presentation orderings do not coincide. Is this even allowed? (This is an unreencoded satellite recording so it should be.)
There is also another strange thing: If I do not cut frame-accurately at the beginning, but include a little bit more, these frames are not skipped (with either decoder). You can see this behaviour in "No.Skipped.Frames.mkv" in this zip-file.
I use Win 7 64bit and have an Intel i3 4005U. But at least the part with software-decoding should be hardware-independent so I hope you can reproduce it.
And thanks for the huge amount of time you have invested in these filters.
The text was updated successfully, but these errors were encountered: