为了使事情简单一点,下面的代码将输出
杰森
.
你可以用它
probe(filename)
或通过使用获取持续时间
duration(filename)
:
json_info = probe(filename)
secondes_dot_ = duration(filename) # float number of seconds
它工作在
Ubuntu 14.04
当然在哪
ffprobe
安装。代码并不是为了速度或漂亮的目的而优化的,但它在我的机器上工作,希望它能有所帮助。
#
# Command line use of 'ffprobe':
#
# ffprobe -loglevel quiet -print_format json \
# -show_format -show_streams \
# video-file-name.mp4
#
# man ffprobe # for more information about ffprobe
#
import subprocess32 as sp
import json
def probe(vid_file_path):
''' Give a json from ffprobe command line
@vid_file_path : The absolute (full) path of the video file, string.
'''
if type(vid_file_path) != str: