Opened 4 years ago

Closed 15 months ago

#9266 closed defect (fixed)

ffprobe produces wrong output for compact format

Reported by: maksut Owned by:
Priority: normal Component: ffprobe
Version: git-master Keywords:
Cc: kev Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: yes

Description (last modified by maksut)

ffprobe produces wrong output for compact format when:

  1. stream has side data and
  2. "-show_entries stream=codec_type" filter is applied.

See "codec_type=videoside_data" below:

❯ ffprobe -show_entries stream=codec_type -print_format compact A_monkey_tale_.3gp
ffprobe version 4.4 Copyright (c) 2007-2021 the FFmpeg developers
  built with Apple clang version 12.0.0 (clang-1200.0.32.29)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
[amrnb @ 0x7fdc8780a600] Multiple frames in a packet.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'A_monkey_tale_.3gp':
  Metadata:
    major_brand     : 3gp5
    minor_version   : 768
    compatible_brands: 3gp53gp43g2aisom
    creation_time   : 2009-10-27T08:36:15.000000Z
  Duration: 00:01:09.44, start: 0.000000, bitrate: 141 kb/s
  Stream #0:0(eng): Video: h263 (s263 / 0x33363273), yuv420p, 128x96 [SAR 12:11 DAR 16:11], 127 kb/s, 14.40 fps, 14.99 tbr, 15750 tbn, 29.97 tbc (default)
    Metadata:
      rotate          : 0
      creation_time   : 2009-10-27T08:36:15.000000Z
      handler_name    : vide
      vendor_id       : [0][0][0][0]
    Side data:
      displaymatrix: rotation of -0.00 degrees
  Stream #0:1(eng): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s (default)
    Metadata:
      rotate          : 0
      creation_time   : 2009-10-27T08:36:15.000000Z
      handler_name    : soun
      vendor_id       : [0][0][0][0]
stream|codec_type=videoside_data|

stream|codec_type=audio

Valid json output for comparison:

❯ ffprobe -show_entries stream=codec_type -print_format json A_monkey_tale_.3gp
ffprobe version 4.4 Copyright (c) 2007-2021 the FFmpeg developers
  built with Apple clang version 12.0.0 (clang-1200.0.32.29)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
{
[amrnb @ 0x7fc84a817800] Multiple frames in a packet.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'A_monkey_tale_.3gp':
  Metadata:
    major_brand     : 3gp5
    minor_version   : 768
    compatible_brands: 3gp53gp43g2aisom
    creation_time   : 2009-10-27T08:36:15.000000Z
  Duration: 00:01:09.44, start: 0.000000, bitrate: 141 kb/s
  Stream #0:0(eng): Video: h263 (s263 / 0x33363273), yuv420p, 128x96 [SAR 12:11 DAR 16:11], 127 kb/s, 14.40 fps, 14.99 tbr, 15750 tbn, 29.97 tbc (default)
    Metadata:
      rotate          : 0
      creation_time   : 2009-10-27T08:36:15.000000Z
      handler_name    : vide
      vendor_id       : [0][0][0][0]
    Side data:
      displaymatrix: rotation of -0.00 degrees
  Stream #0:1(eng): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s (default)
    Metadata:
      rotate          : 0
      creation_time   : 2009-10-27T08:36:15.000000Z
      handler_name    : soun
      vendor_id       : [0][0][0][0]
    "programs": [

    ],
    "streams": [
        {
            "codec_type": "video",
            "side_data_list": [
                {

                }
            ]
        },
        {
            "codec_type": "audio"
        }
    ]
}

Version 4.3.1 and git master has the problem.
But version 4.0 does not have it.

Attachments (1)

A_monkey_tale_.3gp (1.2 MB ) - added by maksut 4 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by Carl Eugen Hoyos, 4 years ago

Please understand that tickets with -v quiet are generally invalid and please attach an input file that allows to reproduce.

Last edited 4 years ago by Carl Eugen Hoyos (previous) (diff)

by maksut, 4 years ago

Attachment: A_monkey_tale_.3gp added

comment:2 by maksut, 4 years ago

Description: modified (diff)

comment:3 by maksut, 4 years ago

Carl Eugen Hoyos, I've updated the description with an example without "-v quiet" and also attached the sample video.

Thanks!

comment:4 by kev, 3 years ago

Analyzed by developer: set
Cc: kev added
Status: newopen

I've encountered this issue before and made a local fix. This is a duplicate of #7153, and is a output formatting bug in the compact_writer Writer class implementation of print_section_header and print_section_footer (fftools/ffprobe.c)

The issue occurs any time an array section is added inside of another section (e.g. STREAM_SIDE_DATA_LIST inside of STREAM). Arrays are not permitted to nest, so the new array section formats as if it already started a new line, and an extra new line is inserted when the enclosing section closes (because it expected no newlines were inserted by nested sections).

There is more than one way to fix this:
1) Close the parent section and start a new line, like:

stream|codec_type=video
side_data|
stream|codec_type=audio

2) Nest the array (assumes element is printed)

stream|codec_type=video|side_data:side_data_type=SOMETHING
stream|codec_type=audio

Personally, I think it should be nested to reflect the data hierarchy, and nested arrays should have indexed elements. For example, the components array is indexed here:

pixel_format|name=x2rgb10le|nb_components=3|log2_chroma_w=N/A|log2_chroma_h=N/A|bits_per_pixel=30|flags:big_endian=0|flags:palette=0|flags:bitstream=0|flags:hwaccel=0|flags:planar=0|flags:rgb=1|flags:alpha=0|components[0]:index=1|components[0]:bit_depth=10|components[1]:index=2|components[1]:bit_depth=10|components[2]:index=3|components[2]:bit_depth=10
pixel_format|name=x2rgb10be|nb_components=3|log2_chroma_w=N/A|log2_chroma_h=N/A|bits_per_pixel=30|flags:big_endian=1|flags:palette=0|flags:bitstream=0|flags:hwaccel=0|flags:planar=0|flags:rgb=1|flags:alpha=0|components[0]:index=1|components[0]:bit_depth=10|components[1]:index=2|components[1]:bit_depth=10|components[2]:index=3|components[2]:bit_depth=10

If this looks like a good fix, I could submit a patch from my changes.

comment:5 by Stefano Sabatini, 16 months ago

Personally, I think it should be nested to reflect the data hierarchy, and nested arrays should have indexed elements. For example, the components array is indexed here:

Sorry for the super slow answer, I agree this should be nested. If you can provide a patch on ffmpeg-devel this would be ideal (I'll try to work a solution, but feel free to send your own solution if you have time).

comment:6 by Stefano Sabatini, 15 months ago

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.