Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find duration of a video file using mediainfo in seconds or other formats?

How can I find duration of a video file in miliseconds i.e. in integer in deterministic way. I have used ffprobe to get the duration but it doesn't give duration for all file formats.

like image 608
Harit Vishwakarma Avatar asked Sep 30 '13 10:09

Harit Vishwakarma


1 Answers

Use the following commands:

i) To get the duration of video stream:

$ mediainfo --Inform="Video;%Duration%"  [inputfile]

ii) To get the duration of the media file:

$ mediainfo --Inform="General;%Duration%" [inputfile]

iii) To get the duration of audio stream only:

$ mediainfo --Inform="Audio;%Duration%" [inputfile]

iv) To get values of more than one parameter:

$ mediainfo --Inform="Video;%Width%,%Height%,%BitRate%,%FrameRate%" [inputfile]

Output would be something like this:

1280,720,3000000,30.0
like image 135
Harit Vishwakarma Avatar answered Oct 07 '22 05:10

Harit Vishwakarma