内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用
每次我尝试用ffmpeg获取一些关于我的视频文件的信息,它就会吐出很多无用的信息,并把好的东西混在一起。
我在用ffmpeg -i name_of_the_video.mpg
。
有没有可能以友好的方式得到它?我的意思是,JSON最好
现在,我让我的应用程序用regex解析数据,但是在一些特定的视频文件中出现了许多令人讨厌的角落。我修复了我所遇到的一切,但可能还有更多。
我想要的是:
{ "Stream 0": { "type": "Video", "codec": "h264", "resolution": "720x480" }, "Stream 1": { "type": "Audio", "bitrate": "128 kbps", "channels": 2 } }
ffprobe -v quiet -print_format json -show_format -show_streams somefile.asf
会产生以下情况:
{ "streams": [{ "index": 0, "codec_name": "wmv3", "codec_long_name": "Windows Media Video 9", "codec_type": "video", "codec_time_base": "1/1000", "codec_tag_string": "WMV3", "codec_tag": "0x33564d57", "width": 320, "height": 240, "has_b_frames": 0, "pix_fmt": "yuv420p", "level": -99, "r_frame_rate": "30000/1001", "avg_frame_rate": "0/0", "time_base": "1/1000", "start_time": "0.000", "duration": "300.066", "tags": { "language": "eng" } }], "format": { "filename": "somefile.asf", "nb_streams": 1, "format_name": "asf", "format_long_name": "ASF format", "start_time": "0.000", "duration": "300.066", "tags": { "WMFSDKVersion": "10.00.00.3646", "WMFSDKNeeded": "0.0.0.0000", "IsVBR": "0" } } }