Specific mediainfo command for audio duration for media stream having stereo or multiple audio streams

1.5k Views Asked by At

I am getting concatenated duration of audios present in the file from the following command:

mediainfo --Output="Audio;%Duration%" "filename"

This command will give me the number 130406130468 which is concatenated duration of 2 audios present in the file. with the following command:

mediainfo --Inform="Audio;%Duration/String1%" "filename"

The duration comes in "xxmn yys zzmsxxmn yys zzn" format where mn, s, ms are minutes, seconds and milliseconds. For this output it again requires context level parsing and is prone to errors when parsed in C language. Is there any specific command to get the audio duration separately for separate audio streams.

1

There are 1 best solutions below

0
On BEST ANSWER

Just add a separator in your MediaInfo template. For example:

mediainfo --Output="Audio;%Duration%\n" "filename"

(note the "\n" which is the character meaning "line return")

or if you want to keep a single line:

mediainfo --Output="Audio;%Duration%, " "filename"

It maybe safer to show also the ID corresponding to the duration, e.g.

mediainfo --Output="Audio;Duration for track having ID %ID% is %Duration/String1%\n" "filename"

Jérôme, developer of MediaInfo.