import ffmpeg
def get_source_info_ffmpeg(source_name):
return_value = 0
try:
info = ffmpeg.probe(source_name)
# print(info)
# print("---------------------------------")
vs = next(c for c in info['streams'] if c['codec_type'] == 'video')
format_name = info['format']['format_name']
codec_name = vs['codec_name']
duration_ts = float(vs['duration_ts'])
fps = vs['r_frame_rate']
width = vs['width']
height = vs['height']
print("format_name:{} \ncodec_name:{} \nduration_ts:{} \nwidth:{} \nheight:{} \nfps:{}".format(format_name, codec_name, duration_ts, width, height, fps))
except (OSError, TypeError, ValueError, KeyError, SyntaxError) as e:
print("init_source:{} error. {}\n"