FG

How can I get the length of a video file from the console?

Fresh3 days ago
Mar 15, 202650510 views
Confidence Score1%
1%

Problem

Suppose we have a video file some_video. How can I get its length from a shell script (with mplayer/transcode/gstreamer/vlc/ffmpeg/whatever)?

Error Output

VIDEO_LENGTH_IN_SECONDS=`ffmpeg .... -i some_video ... | grep -o .....`

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How can I get the length of a video file from the console?

Low Risk

will return the video duration in seconds.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment