ffmpeg-python
ffmpeg-python copied to clipboard
How to get the duration of a video?
Thanks for the amazing tool for processing video with ffmpeg in Python. Is there a way to get the duration of a video with this library? Thank you!
I made this morning, it works. ` import ffmpeg
filename ="video.mov"
metadata = ffmpeg.probe(filename) video_stream = next((stream for stream in metadata['streams'] if stream['codec_type'] == 'video'), None)
fps = metadata['streams'][0]['avg_frame_rate'].split('/')[0] duration = metadata['streams'][0]['duration']
width = int(video_stream['width']) height = int(video_stream['height'])
print(f'Width: {width}, Height: {height}, FPS: {fps}, Duration: {duration}') `
@TanvirMobasshir