I am using mediainfo to get the audio duration (in ms)

 .\mediainfo.exe --Output='Audio;%Duration%' file.mkv

Example for mkv with 1 audio: 1367130

Example for mkv with 2 audio tracks: 13671301367130

if the file has several audio tracks,I only want one value, is there is way to instruct mediainfo to only return 1 value? If it helps, in my script I do retrieve the default audio's ID, is there a way to use that to select audio with id=some_id with mediainfo and get the duration of that particular audio file?


1 Answer 1


The program does what you request, no space or any other character between 2 values. You may want to append some extra characters after each value e.g. a carriage return:

.\MediaInfo.exe --Output='Audio;%Duration%' file.mkv
.\MediaInfo.exe --Output='Audio;%Duration%\r\n' file.mkv

If you want to add the track ID:

.\MediaInfo.exe --Output='Audio;%ID%: %Duration%\r\n' file.mkv
2: 10224071
3: 10224071
4: 10224071

It is currently not possible to select a specific track but you can use a grep-like command after MediaInfo for peeking what you need.

  • YES, this is exactly what I wanted, I was going to edit my post to ask if it is at least possible to concatenate a delimiter of my choice, that way I can split on that and get what I want. Thanks a lot for this great tool jérôme.
    – user206904
    Dec 6, 2022 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.