【问题标题】:How to get xml/json output when ffprobe could not find codec parameters for a stream当 ffprobe 找不到流的编解码器参数时如何获取 xml/json 输出
【发布时间】:2014-03-27 13:40:27
【问题描述】:

我在 mkv 文件上使用 ffprobe 以获取有关章节结构的一些信息,以便使用 ffmpeg 拆分 mkv。

ffprobe miku.mkv -print_format xml

但是 ffprobe 遇到了 scodec 错误(不影响章节信息),我无法通过设置打印格式获取信息。我知道有类似管道的方法可以绕过错误,但我仍然想获取 xml/json 文件以便轻松解析。

我想知道是否有办法导入错误并输出 xml/json 文件,或者是否有解决该错误的方法。 (但我更喜欢前者的解决方案,因为我不知道我可能会遇到什么错误,只要章节信息可用,我想看看它是否有效)

错误是这样的。

ffprobe 版本 N-60899-ga8ad7e4 版权所有 (c) 2007-2014 FFmpeg 开发者 使用 gcc 4.8.2 (GCC) 于 2014 年 2 月 25 日 04:04:01 构建 配置: --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 libav 设备 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] 找不到流 3 的编解码器参数(字幕:hdmv_pgs_subtitle):未指定大小 考虑增加“analyzeduration”和“probesize”选项的值 输入 #0, matroska,webm, 来自 '[初音未来 Magical Mirai 2013][JPN][BDRIP][1080P][H264_FLAC_DTS-HDMA].mkv': 元数据: 编码器:libebml v1.3.0 + libmatroska v1.4.1 创建时间:2014-02-18 22:57:12 时长:01:58:00.08,开始:0.000000,比特率:16495 kb/s 第 0.0 章:开始 0.000000,结束 30.030000 元数据: 标题:开始 第 0.1 章:开始 30.030000,结束 149.749000 元数据: title : 00. 开场音乐 ……

【问题讨论】:

    标签: ffmpeg ffprobe


    【解决方案1】:

    a link 显示了一个很好的解决方案:

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

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

    你会得到

    {
    "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"
        }
    }
    }
    

    <?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>
    

    【讨论】:

      【解决方案2】:
      # ffprobe music.ts -show_format -print_format xml  > xx.xml
      # cat xx.xml
      
      <format filename="music.ts" nb_streams="2" nb_programs="1" format_name="mpegts" format
      _long_name="MPEG-TS (MPEG-2 Transport Stream)" start_time="1.400000" duration="122.720000"
       size="12575884" bit_rate="819809" probe_score="100"/>
      

      【讨论】:

        猜你喜欢
        • 2016-02-15
        • 2017-08-24
        • 2017-07-16
        • 2014-03-16
        • 2011-04-13
        • 2019-04-20
        • 2021-10-03
        • 1970-01-01
        • 2012-07-24
        相关资源
        最近更新 更多