[FFmpeg-user] debug qp (debug mb_type) output issues
Chema Gonzalez
chema at berkeley.edu
Thu Aug 18 01:08:39 EEST 2022
Note that the same issue happens with "-debug mb_type" and "-debug
skip". This looks like a logger issue.
-Chema
On Wed, Aug 17, 2022 at 3:07 PM Chema Gonzalez <chema at berkeley.edu> wrote:
>
> Hi,
>
> I'm trying to get the per-MB QP list for an h264 (avc) video (Annex B
> format, though this should not matter much). I can get the exact list
> I'm looking for when using ffprobe:
>
> ```
> $ ffprobe -v quiet -show_frames -debug qp -print_format flat
> input.264 > /tmp/stdout 2> /tmp/stderr
> ```
>
> The stdout gets the (flat format) per-frame info, and the stderr gets
> the QP list:
>
> ```
> $ cat /tmp/stderr
> [h264 @ 0x3bce440] Format h264 probed with size=2048 and score=51
> [h264 @ 0x3bce440] Before avformat_find_stream_info() pos: 0 bytes
> read:32768 seeks:0 nb_streams:1
> [extract_extradata @ 0x3bd1840] nal_unit_type: 7(SPS), nal_ref_idc: 3
> [extract_extradata @ 0x3bd1840] nal_unit_type: 8(PPS), nal_ref_idc: 3
> [extract_extradata @ 0x3bd1840] nal_unit_type: 5(IDR), nal_ref_idc: 3
> [h264 @ 0x3bcfa80] nal_unit_type: 7(SPS), nal_ref_idc: 3
> [h264 @ 0x3bcfa80] nal_unit_type: 8(PPS), nal_ref_idc: 3
> [h264 @ 0x3bcfa80] nal_unit_type: 5(IDR), nal_ref_idc: 3
> [h264 @ 0x3bcfa80] Format yuv420p chosen by get_format().
> [h264 @ 0x3bcfa80] Reinit context to 1280x720, pix_fmt: yuv420p
> [h264 @ 0x3bcfa80] New frame, type: I
> [h264 @ 0x3bcfa80] 35353535353535353535353535353535353535353535...
> [h264 @ 0x3bcfa80] 35353535353535353535353535353535353535353535...
> [h264 @ 0x3bcfa80] ...
> [h264 @ 0x3bcfa80] 35353535353535353535353535353535353535353535...
> [h264 @ 0x3bcfa80] nal_unit_type: 1(Coded slice of a non-IDR picture),
> nal_ref_idc: 2
> [h264 @ 0x3bcfa80] New frame, type: P
> [h264 @ 0x3bcfa80] 37373737373737373737373737373737373737373737...
> [h264 @ 0x3bcfa80] ...
> ...
> [h264 @ 0x3c01500] New frame, type: P
> [h264 @ 0x3c01500] 24242424242424242424242424242424242424242424...
> [h264 @ 0x3c01500] 24242424242424242424242424242424242424242424...
> [h264 @ 0x3c01500] ...
> [h264 @ 0x3c01500] 24242424242424242424242424242424242424242424...
> [AVIOContext @ 0x3bcf100] Statistics: 6508544 bytes read, 0 seeks
> ```
>
> Note that the per-frame output is correct all the way to the end.
>
> But if I try to do the same using ffmpeg, the output after a few
> frames gets garbled. It seems like there are 2x writers competing for
> putting QP values to the stderr:
>
> ```
> $ ffmpeg -debug:v qp -i in.264 -an -v 100 -f null - > /tmp/stdout2 >&
> /tmp/stderr2
> ```
>
> Then I get:
>
> ```
> $ cat /tmp/stderr2
> -- first few frames work well
> [h264 @ 0x36bb140] nal_unit_type: 7(SPS), nal_ref_idc: 3
> [h264 @ 0x36bb140] nal_unit_type: 8(PPS), nal_ref_idc: 3
> [h264 @ 0x36bb140] nal_unit_type: 5(IDR), nal_ref_idc: 3
> [h264 @ 0x36bb140] Format yuv420p chosen by get_format().
> [h264 @ 0x36bb140] Reinit context to 1280x720, pix_fmt: yuv420p
> [h264 @ 0x36bb140] New frame, type: I
> [h264 @ 0x36bb140] 353535353535353535353535353535353535...
> [h264 @ 0x36bb140] 353535353535353535353535353535353535...
> [h264 @ 0x36bb140] ...
> [h264 @ 0x36bb140] 353535353535353535353535353535353535...
> ...
> -- but at some point output gets garbled
> [h264 @ 0x36d68c0] nal_unit_type: 7(SPS), nal_ref_idc: 3
> [h264 @ 0x36d68c0] nal_unit_type: 8(PPS), nal_ref_idc: 3
> [h264 @ 0x36d68c0] nal_unit_type: 5(IDR), nal_ref_idc: 3
> [h264 @ 0x36d68c0] Format yuv420p chosen by get_format().
> [h264 @ 0x36d68c0] Reinit context to 1280x720, pix_fmt: yuv420p
> cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is
> harmless if it occurs once at the start per stream)
> [h264 @ 0x373de40] nal_unit_type: 1(Coded slice of a non-IDR picture),
> nal_ref_idc: 2
> cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is
> harmless if it occurs once at the start per stream)
> [h264 @ 0x37584c0] nal_unit_type: 1(Coded slice of a non-IDR picture),
> nal_ref_idc: 2
> cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is
> harmless if it occurs once at the start per stream)
> [h264 @ 0x36fbec0] nal_unit_type: 1(Coded slice of a non-IDR picture),
> nal_ref_idc: 2
> [h264 @ 0x36d68c0] New frame, type: I
> [h264 @ 0x36d68c0]
> 3535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535
> [h264 @ 0x36d68c0]
> 35353535353535353535353535353535353535353535353535New frame, type: P
> [h264 @ 0x373de40] 373737373735New frame, type: P
> [h264 @ 0x37584c0]
> 444444444444444444444444444444444444444444444444444444444444444444444435353535353535353535353535353535374435374435353535353535353535353544373544444444373737373737373535353737373737373737373737373737373737373737cur_dts
> is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it
> occurs once at the start per stream)
> [h264 @ 0x36d68c0]
> 35444444444444373735353535373737373737354444444444443737373737373535353544444444373737373737373737373737373737373744444444443737373737373737373737373737
> [h264 @ 0x373de40] 37nal_unit_type: 1(Coded slice of a non-IDR
> picture), nal_ref_idc: 2
> [h264 @ 0x37584c0] 4444444444444444444444444444444444
> [h264 @ 0x37584c0]
> 44444444444444444444444444444444444444444444444444444444443735444444444444444444444444444444443737373737373737373737373737373737373737373737373735353535353544444444373737373737373535353544444444444444373737373737373737373737373737
> [h264 @ 0x37584c0]
> 4437353535353535353535353535353535444444444435353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535374435353535
> [h264 @ 0x36d68c0]
> 35373737373737374435353535353535353535353537373737353535353535353535373737373737373737373737373737373535353535353535353737
> [h264 @ 0x373de40]
> 373737374444444444373737373535353535353535353535353535353535353535353535353535353537444444443535353537373737373737373737373737373737373737373737353535354444444437373737373737373737444444
> [h264 @ 0x37584c0]
> 44353535353535353537373737373744444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444cur_dts
> is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it
> occurs once at the start per stream)
> [h264 @ 0x36d68c0] 3537373737374435353535
> [h264 @ 0x37584c0]
> 444444444444443737373737443537444444444437373737373544444444353744444444444435nal_unit_type:
> 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
> ...
> ```
>
> I tried with 3x different files, and all do the same. Wonder whether
> this makes sense.
>
> Thanks.
> -Chema
More information about the ffmpeg-user
mailing list