我在mkv文件上使用ffprobe以获取有关章节结构的一些信息,以便使用ffmpeg拆分mkv。
ffprobe miku.mkv -print_format xml
但是ffprobe遇到了scodec错误(不影响章节信息),我无法通过设置打印格式来获取信息。我知道有一些方法可以绕过错误,但是我仍然希望得到xml / json文件,以便它可以轻松解析。
我想知道是否有办法输入错误并输出xml / json文件或是否有错误的解决方案。 (但我更喜欢前者的解决方案,因为我不知道我可能遇到的任何错误,只要章节信息可用,我希望看到它有效)
错误是这样的。
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 ......
答案 0 :(得分:6)
这是显示出良好解决方案的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>
答案 1 :(得分:0)
# 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"/>