使用ffprobe获取视频信息 以 json/xml/ini 等格式输出

Command :
/bin/ffprobe -i xxx.mp4 -print_format json -show_format -show_streams -v quiet -pretty

-show_format json|ini|xml 支持多种格式

将有如下输出:

XML 格式如下:

<?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/120" codec_tag_string="avc1" codec_tag="0x31637661" width="1920" height="1080" coded_width="1920" coded_height="1080" has_b_frames="2" sample_aspect_ratio="0:1" display_aspect_ratio="0:1" pix_fmt="yuvj420p" level="42" color_range="pc" chroma_location="left" refs="1" is_avc="true" nal_length_size="4" r_frame_rate="60/1" avg_frame_rate="60/1" time_base="1/15360" start_pts="0" start_time="0:00:00.000000" duration_ts="8625930" duration="0:09:21.583984" bit_rate="3.152659 Mbit/s" bits_per_raw_sample="8" nb_frames="33695">
            <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" timed_thumbnails="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="48 KHz" 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="576" start_time="0:00:00.012000" duration_ts="26956368" duration="0:09:21.591000" bit_rate="129.131000 Kbit/s" max_bit_rate="129.131000 Kbit/s" nb_frames="26324">
            <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" timed_thumbnails="0"/>
            <tag key="language" value="und"/>
            <tag key="handler_name" value="SoundHandler"/>
        </stream>
    </streams>

    <format filename="未命名.mp4" nb_streams="2" nb_programs="0" format_name="mov,mp4,m4a,3gp,3g2,mj2" format_long_name="QuickTime / MOV" start_time="0:00:00.000000" duration="0:09:21.584000" size="220.556567 Mibyte" bit_rate="3.294542 Mbit/s" probe_score="100">
        <tag key="major_brand" value="isom"/>
        <tag key="minor_version" value="512"/>
        <tag key="compatible_brands" value="isomiso2avc1mp41"/>
        <tag key="encoder" value="Lavf57.83.100"/>
    </format>
</ffprobe>