[FFmpeg-user] MPEG 'broken_link' flag -- How do I set it?

Mark Filipak markfilipak.imdb at gmail.com
Tue Mar 26 02:05:01 EET 2024


Thank you, Mark.

On 25/03/2024 16.45, Mark Thompson wrote:
> On 24/03/2024 15:48, Mark Filipak wrote:
>> I cut at the end of an open GOP. When I did that, FFmpeg did not set the MPEG 'broken_link' flag 
>> to '1'.
>>
>> The frame following the cut has to be flagged:
>> 'closed_gop' = '0' because it's an open GOP, also, and
>> 'broken_link' = '1'.
>>
>>
>> How do I do that? I searched but did not find.
> 
> The ffmpeg utility does not edit the internals of the bitstream when cutting (packets are 
> effectively opaque to it); you would need a BSF to make this change.

Yes, a bit stream filter is what I seek.

> Making such a BSF should be straightforward: use CBS BSF with a single update_fragment function 
> which edits the GOP header on any I frame with a discontinuity before it.

What's a CBS bit stream filter?

There's 2 segments, so 4 cuts. They are both 100% open GOPs. The concatenation is 6 seconds of 
video. There are 29 GOPs. As you can see, all 29 have identical GOPs. My parse shows that they claim 
to be closed and not broken. That is 100% false. The use of packet time codes is obsolete, but the 
'closed_gop' & 'broken_link' flags aren't.

00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47
00 00 01 B8 41 A2 95 47

GOP_start_code     00 00 01 B8
time_code          == == == == 41 A2 95 47   //Re: H.262 §6.3.8
                      .—————————'         '—————————————————.
drop_frame_flag      0--- ---- ---- ---- ---- ---- ---- ----   //'1': drop, '0' don't drop
time_code_hours      -100 00-- ---- ---- ---- ---- ---- ----   //= 16
time_code_minutes    ---- --01 1010 ---- ---- ---- ---- ----   //= 26
marker_bit           ---- ---- ---- 0--- ---- ---- ---- ----
time_code_seconds    ---- ---- ---- -010 100- ---- ---- ----   //= 20
time_code_pictures   ---- ---- ---- ---- ---1 0101 0--- ----   //= 42; time code = 16:26:20.42
closed_gop           ---- ---- ---- ---- ---- ---- -1-- ----   //'1': closed GOP; '0': open GOP
broken_link          ---- ---- ---- ---- ---- ---- --0- ----   //'1': GOP edited, B-frames have lost 
their reference frames; '0': GOP not edited
?????                ---- ---- ---- ---- ---- ---- ---0 0111





More information about the ffmpeg-user mailing list