I) To get the duration of video stream: $ mediainfo -Inform="Video %Duration%" How to find duration of a video file using mediainfo in seconds or other formats? Result = n(, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) You can use the following method instead to get the duration: def get_length(input_video):
There is one simple command which returns only the duration of the input file: ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 There is no need to iterate though the output of FFprobe. Using ffmpeg to obtain video durations in python Try this: ffmpeg -i file.mp4 2>&1 | grep Duration | awk '' | tr -d , Notice the redirection of stderr to stdout: 2>&1 Try this: ffmpeg -i file.mp4 2>&1 | grep Duration | sed 's/Duration: \(.*\), start/\1/g'
How to extract duration time from ffmpeg output?įfmpeg is writing that information to stderr, not stdout.