How to get xml/json output when ffprobe could not find codec parameters for a stream

user2421731 picture user2421731 · Feb 25, 2014 · Viewed 8.3k times · Source

I was using ffprobe on a mkv file in order to get some info about the chapter structure so as to split the mkv using ffmpeg.

ffprobe miku.mkv -print_format xml

However ffprobe encountered an scodec error(does not affect chapter info) and I could not get the info by setting print format. I know there are ways like pipeline to bypass the error, but I still want to get the xml/json file so it can be parsed easily.

I wonder if there is a way to ingore the error and output the xml/json file or is there a solution to the error. (But I prefer a solution to the former, because I don't know what any errors I might encounter and I'd like to see it works as long as the chapter info is available)

The error was like this.

ffprobe version N-60899-ga8ad7e4 Copyright (c) 2007-2014 the FFmpeg developers
  built on Feb 25 2014 04:04:01 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 66.100 / 52. 66.100
  libavcodec     55. 52.102 / 55. 52.102
  libavformat    55. 33.100 / 55. 33.100
  libavdevice    55. 10.100 / 55. 10.100
  libavfilter     4.  1.103 /  4.  1.103
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
[matroska,webm @ 0000000002945080] Could not find codec parameters for stream 3 (Subtitle: hdmv_pgs_subtitle): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, matroska,webm, from '[Hatsune Miku Magical Mirai 2013][JPN][BDRIP][1080P][H264_FLAC_DTS-HDMA].mkv':
  Metadata:
    encoder         : libebml v1.3.0 + libmatroska v1.4.1
    creation_time   : 2014-02-18 22:57:12
  Duration: 01:58:00.08, start: 0.000000, bitrate: 16495 kb/s
    Chapter #0.0: start 0.000000, end 30.030000
    Metadata:
      title           : Start
    Chapter #0.1: start 30.030000, end 149.749000
    Metadata:
      title           : 00. Opening Music
......

Answer

zentby picture zentby · Jun 9, 2015

Here's a link that shows a good solution:

For JSON: ffprobe -v quiet -print_format json -show_format -show_streams "lolwut.mp4" > "lolwut.mp4.json"

For XML: ffprobe -v quiet -print_format xml -show_format -show_streams "lolwut.mp4" > "lolwut.mp4.xml"

You'll get

{
"streams": [
    {
        "index": 0,
        "codec_name": "h264",
        "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
        "profile": "High",
        "codec_type": "video",
        "codec_time_base": "1/180000",
        "codec_tag_string": "avc1",
        "codec_tag": "0x31637661",
        "width": 932,
        "height": 540,
        "coded_width": 944,
        "coded_height": 544,
        "has_b_frames": 2,
        "sample_aspect_ratio": "20745:20737",
        "display_aspect_ratio": "461:267",
        "pix_fmt": "yuv420p",
        "level": 31,
        "color_range": "tv",
        "color_space": "bt709",
        "color_transfer": "bt709",
        "color_primaries": "bt709",
        "chroma_location": "left",
        "refs": 4,
        "is_avc": "1",
        "nal_length_size": "4",
        "r_frame_rate": "30000/1001",
        "avg_frame_rate": "440190000/14687687",
        "time_base": "1/90000",
        "start_pts": 0,
        "start_time": "0.000000",
        "duration_ts": 14687687,
        "duration": "163.196522",
        "bit_rate": "1501671",
        "bits_per_raw_sample": "8",
        "nb_frames": "4891",
        "disposition": {
            "default": 1,
            "dub": 0,
            "original": 0,
            "comment": 0,
            "lyrics": 0,
            "karaoke": 0,
            "forced": 0,
            "hearing_impaired": 0,
            "visual_impaired": 0,
            "clean_effects": 0,
            "attached_pic": 0
        },
        "tags": {
            "language": "und",
            "handler_name": "VideoHandler"
        }
    },
    {
        "index": 1,
        "codec_name": "aac",
        "codec_long_name": "AAC (Advanced Audio Coding)",
        "profile": "LC",
        "codec_type": "audio",
        "codec_time_base": "1/48000",
        "codec_tag_string": "mp4a",
        "codec_tag": "0x6134706d",
        "sample_fmt": "fltp",
        "sample_rate": "48000",
        "channels": 2,
        "channel_layout": "stereo",
        "bits_per_sample": 0,
        "r_frame_rate": "0/0",
        "avg_frame_rate": "0/0",
        "time_base": "1/48000",
        "start_pts": 0,
        "start_time": "0.000000",
        "duration_ts": 7832576,
        "duration": "163.178667",
        "bit_rate": "157754",
        "nb_frames": "7649",
        "disposition": {
            "default": 1,
            "dub": 0,
            "original": 0,
            "comment": 0,
            "lyrics": 0,
            "karaoke": 0,
            "forced": 0,
            "hearing_impaired": 0,
            "visual_impaired": 0,
            "clean_effects": 0,
            "attached_pic": 0
        },
        "tags": {
            "language": "eng",
            "handler_name": "Stereo"
        }
    }
],
"format": {
    "filename": "C:\\Users\\danielzhao\\Videos\\mp4_test_files\\science_V-1500kbps_A-160kbps_moov_atom_at_end.mp4",
    "nb_streams": 2,
    "nb_programs": 0,
    "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
    "format_long_name": "QuickTime / MOV",
    "start_time": "0.000000",
    "duration": "163.197000",
    "size": "33972120",
    "bit_rate": "1665330",
    "probe_score": 100,
    "tags": {
        "major_brand": "mp42",
        "minor_version": "512",
        "compatible_brands": "isomiso2avc1mp41",
        "encoder": "HandBrake 0.10.1 2015030800"
    }
}
}

and

<?xml version="1.0" encoding="UTF-8"?>
<ffprobe>
    <streams>
        <stream index="0" codec_name="h264" codec_long_name="H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10" profile="High" codec_type="video" codec_time_base="1/180000" codec_tag_string="avc1" codec_tag="0x31637661" width="932" height="540" coded_width="944" coded_height="544" has_b_frames="2" sample_aspect_ratio="20745:20737" display_aspect_ratio="461:267" pix_fmt="yuv420p" level="31" color_range="tv" color_space="bt709" color_transfer="bt709" color_primaries="bt709" chroma_location="left" refs="4" is_avc="1" nal_length_size="4" r_frame_rate="30000/1001" avg_frame_rate="440190000/14687687" time_base="1/90000" start_pts="0" start_time="0.000000" duration_ts="14687687" duration="163.196522" bit_rate="1501671" bits_per_raw_sample="8" nb_frames="4891">
            <disposition default="1" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0" hearing_impaired="0" visual_impaired="0" clean_effects="0" attached_pic="0"/>
            <tag key="language" value="und"/>
            <tag key="handler_name" value="VideoHandler"/>
        </stream>
        <stream index="1" codec_name="aac" codec_long_name="AAC (Advanced Audio Coding)" profile="LC" codec_type="audio" codec_time_base="1/48000" codec_tag_string="mp4a" codec_tag="0x6134706d" sample_fmt="fltp" sample_rate="48000" channels="2" channel_layout="stereo" bits_per_sample="0" r_frame_rate="0/0" avg_frame_rate="0/0" time_base="1/48000" start_pts="0" start_time="0.000000" duration_ts="7832576" duration="163.178667" bit_rate="157754" nb_frames="7649">
            <disposition default="1" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0" hearing_impaired="0" visual_impaired="0" clean_effects="0" attached_pic="0"/>
            <tag key="language" value="eng"/>
            <tag key="handler_name" value="Stereo"/>
        </stream>
    </streams>

    <format filename="C:\Users\danielzhao\Videos\mp4_test_files\science_V-1500kbps_A-160kbps_moov_atom_at_end.mp4" nb_streams="2" nb_programs="0" format_name="mov,mp4,m4a,3gp,3g2,mj2" format_long_name="QuickTime / MOV" start_time="0.000000" duration="163.197000" size="33972120" bit_rate="1665330" probe_score="100">
        <tag key="major_brand" value="mp42"/>
        <tag key="minor_version" value="512"/>
        <tag key="compatible_brands" value="isomiso2avc1mp41"/>
        <tag key="encoder" value="HandBrake 0.10.1 2015030800"/>
    </format>
</ffprobe>