Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Announcements and Chat > General Discussion

Reply
 
Thread Tools Search this Thread Display Modes
Old 10th July 2018, 04:49   #1  |  Link
pitoloko
Registered User
 
Join Date: Apr 2011
Posts: 2
How to use MediaInfo CLI to obtain info of a specific audio track by its index?

As the title says: how to use MediaInfo CLI to obtain info of a specific audio track by its index?

Using this command directly in the CMD it returns the audio track count of a video file:

Code:
mediainfo.exe "C:\file.mp4" "--Inform=General;%AudioCount%"
Now, knowing the amount of audio streams I would like to perform a loop from index 1 (base=1) to "%AudioCount%" to get the "%Format%" field for every audio track.

This is something random that I tried to get the "%Format%" field for audio track with index=1 but of course it does not work:

Code:
mediainfo.exe "C:\file.mp4" "--Inform=Audio;--StreamKindPos=1;%Format%"
I'm just trying to figure what is the correct syntax to use in mediainfo CLI, I did a lot of research in Google results and I found none commentary talking about how to do this,
however I know this can be done, I mean I know mediainfo can obtain info of a specific stream index, at least using mediainfo native library instead of the CLI program (but I need to use the CLI program).

Last edited by pitoloko; 10th July 2018 at 04:55.
pitoloko is offline   Reply With Quote
Old 10th July 2018, 11:17   #2  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Quote:
Originally Posted by pitoloko View Post
...Now, knowing the amount of audio streams I would like to perform a loop from index 1 (base=1) to "%AudioCount%" to get the "%Format%" field for every audio track.
I can suggest you use (Windows CLI):

mediainfo.exe "InputFile" "--Inform=Audio;%%ID%% %%Format%%\r\n" 1>"Info.log"

And use the "Info.log", something like:

Code:
2 AC-3
3 EAC-3
to do the loop. You have a sample in ...\MediaInfo\Contrib\CLI_Help.doc
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is online now   Reply With Quote
Old 10th July 2018, 14:36   #3  |  Link
pitoloko
Registered User
 
Join Date: Apr 2011
Posts: 2
@tebasuna51

Thank you, that is not the direct solution that I expected since it involves output redirection to a text file and then parsing the text file, however what you suggested is the only viable solution because MediaInfo, the CLI version, does not support this feature as answered here:

https://sourceforge.net/p/mediainfo/...read/dafbfedc/

Thanks again.
pitoloko is offline   Reply With Quote
Old 10th July 2018, 15:21   #4  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,419
Well, you could also pipe the output to grep, assuming that you've set up msys2's /usr/bin directory on the %PATH%*. At least then there's no intermediate text file.

*or on 64-bit Windows 10 with WSL enabled and a distro set up, you just enter the Linux environment and use both mediainfo (either the .exe from the inherited $PATH or one installed through the package manager) and grep in there.
qyot27 is offline   Reply With Quote
Old 20th July 2018, 05:27   #5  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
Things like this get a lot easier (though more complicated) if you use the API version with a short piece of software, like a C program or Python script.

MediaInfo CLI cannot do single streams, only all streams of a type. libav/ffmpeg can do what you want, but so can the MediaInfo API.
foxyshadis is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:34.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.