Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get media file length in Mac Terminal

Tags:

terminal

macos

Is there a way to get any media file (.avi, .mp4, .mp3, etc.) length using Mac's Terminal?

I there is a need to install a package or a library can you please specify which, and how to install them?

like image 816
David Tzoor Avatar asked Dec 08 '22 07:12

David Tzoor


1 Answers

You can use ffmpeg or ffprobe to get the duration. You can install ffmpeg easily using Homebrew:

brew install ffmpeg

And then you can get the duration using this command:

ffmpeg -i input 2>&1 | grep "Duration"| cut -d ' ' -f 4 | sed s/,//

See the answers here for more details: How to get length of video file from console?

like image 148
Gergo Erdosi Avatar answered Jan 22 '23 07:01

Gergo Erdosi