Reputation: 5757
I'm not sure, but the following command seems to do just that. Here I get the duration of the first audio stream of the mp4 file:
ffprobe -v error -select_streams a:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 -i input.mp4
However, I'm looking for the equivalent with ffmpeg (if it exists). Your answer is equally valid if it's that it's not possible to do that with ffmpeg
.
Upvotes: 0
Views: 1762
Reputation: 93329
Use
ffmpeg -i input.mp4 -c copy -map 0:v:3 -f null - 2>&1 | tail -3 | grep -oP "(?<=time=).+?\s"
0:v:3
will select the fourth video stream. If it exists, output will be a duration e.g. 00:02:57.64
If it doesn't exist, output will be empty.
Upvotes: 2
Reputation: 1084
.Using FFmpeg
to get the media file duration, you can do this:
ffmpeg -i inputfile -map 0:0 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//
For further reading about the Map option.
Upvotes: 1