1

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

This page only shows how to print the duration of a media file. I want to show both filename and duration for many media files.

The output should in the format of the following.

filename<TAB>duration

How can I call mediainfo to get this result?

user1424739
  • 11,937
  • 17
  • 63
  • 152

1 Answers1

0

This page only shows how to print the duration of a media file.

Actually it shows also how to print more than one item, see e.g. "iv)" in the best answer, you may adapt it for your needs.

filename<TAB>duration

Example:

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

tab is replaced by a comma, the command line interface does not permit the tab.

for a tab, you need to create a file e.g. template.csv with:

General;%CompleteName%<TAB>%Duration%

(replace "<TAB>" by a real tab character)

Then:

$ mediainfo mediainfo --Inform=file://template.csv [inputfile]

Jérôme, main developer of MediaInfo.

Jérôme Martinez
  • 1,118
  • 5
  • 10
  • Acctually, I can do it without a file. `mediainfo --Inform='General;%CompleteName%'$'\t''%Duration/String3%\n' ...` – user1424739 Jan 23 '23 at 15:47
  • I don't understand the syntax of `--Inform`. Why `General;` is needed? Whereas the example on that page uses `Video;`? – user1424739 Jan 23 '23 at 15:48
  • Section name depends on what you are looking for. Use the "General" entry for metadata in the General section of the MediaInfo report (file name, container format, global duration, etc), use the "Video" entry for metadata in the Video section of the MediaInfo report (track ID, video format, video characteristics, etc). If you need 2 sections, you need to use a template file. – Jérôme Martinez Jan 26 '23 at 08:12