PDA

View Full Version : mediainfo from batch


smok3
22nd July 2008, 18:11
if i run mediainfo.exe (winxp) from cli:
mediainfo --Inform=General;%Duration/String3% del01.wav

it will nicely return:
00:03:25.160

---

how to use that as batch?, example:
test.bat
mediainfo --Inform=General;%Duration/String3% %1

so i would run as:
test del01.wav

(nothing is working, escaping with carrots, escaping with %, nothing...)

RunningSkittle
22nd July 2008, 18:25
its because command prompt thinks

%Duration/String3% is an environment variable.

try this

%%Duration/String3%%

mediainfo really should have used a different deliminator...

smok3
22nd July 2008, 18:28
like i said, i tried every escape trick allready...., any other tricks? (i really don't want to play with findstr and stuff like that)

RunningSkittle
22nd July 2008, 18:34
I just made this script, it works exactly as it should

set file="E:\Movies\BeerFest.mkv"
set mediainfo="C:\Program Files (x86)\StaxRip\Applications\MediaInfo\mediainfo\mediainfo.exe"

%mediainfo% --Inform=General;%%Duration/String3%% %file%
pause

output:

01:56:26.146

Its not an "escape trick", its just a workaround for the way command prompt handles variables. kind of like how "::" is frequently used to comment instead of "rem"... when actually its calling a label ":" Likewise !var! would not work unless you enabled delayed environment variable expansion.

You can also parse the output using "for /f"

Can you post your script?

smok3
22nd July 2008, 21:07
tnx, will post tommorow what i did.

cdanddvdpublisher
23rd July 2008, 04:00
I just made this script, it works exactly as it should

set file="E:\Movies\BeerFest.mkv"
set mediainfo="C:\Program Files (x86)\StaxRip\Applications\MediaInfo\mediainfo\mediainfo.exe"

%mediainfo% --Inform=General;%%Duration/String3%% %file%
pause

output:

01:56:26.146




looks good - hope it helps the guy/gal out

smok3
23rd July 2008, 08:12
i still don't get it how %% didn't work for me, it is working now, shrug, here is what i did now:

main, audiodur.bat
@echo off

t:\path\mediainfo --Inform=General;%%Duration/String3%% %1 > t:\tmp\tmpdur.txt
set /P somestring=<t:\tmp\tmpdur.txt
del t:\tmp\tmpdur.txt
:: drop ms part of the string
::set somestring=%somestring:~0,-4%

echo %somestring% %~n1%~x1

and 2nd one, that serves as a loop, audiodur_tcm.bat
@ECHO OFF

for /f "delims=+++++" %%i in (%1) DO t:\path\audiodur.bat "%%i" >>durlist.txt

the 2nd one is applied to tcm start menu with %L option, and thats it.

RunningSkittle
23rd July 2008, 13:04
To avoid creating a temporary file, use the "usebackq" option

@echo off
set file="D:\Movies\BeerFest.mkv"
set mediainfo="C:\mediainfo\mediainfo.exe"

for /f "usebackq" %%a in (`"%mediainfo% --Inform=General;%%Duration/String3%% %file%"`) do set duration=%%a
echo %duration%
pause

were you trying to loop this for all files in a directory (and or subdirectories?) This is very easy to do with for /r

smok3
23rd July 2008, 13:42
total commander with option %L provides ascii file-list (one file per line) and then i loop thought those (this list is the list of files selected in active pane of the total commander gui).

for /f "usebackq" %%a in (`"%mediainfo% --Inform=General;%%Duration/String3%% %file%"`) do set duration=%%a

this looks totally greek to me today, and in one month i won't have a clue what it means, so i'll let the tmp files to be made :)

RunningSkittle
23rd July 2008, 14:08
"usebackq", use-back-quotes lets "for /f" parse the output of a command in a "back quoted" string. for example
for /f "usebackq" %%a in `"command"` do echo %%a

(back quote is the button under tilde)

in this case, it parses the output of "%mediainfo% --Inform=General;%%Duration/String3%% %file%"

This is useful because you cant do:
set duration="%mediainfo% --Inform=General;%%Duration/String3%% %file%"

Rather you could... but it wouldn't have the desired effect ;)

smok3
23rd July 2008, 16:35
i got what it does, syntax is greek.

ricardo.santos
25th October 2009, 09:45
hi everyone

can anyone tell me how to parse/retrieve the framerate from a video file?

i have a semi automatic script that at the end uses mp4box to mux 264+aac into mp4 container but it needs to know the fps.

is this possible?

dr.schanker
25th October 2009, 11:16
The following example works for me:


set mediainfo_exe=c:\Programme\MediaInfo_CLI_0.7.11\MediaInfo.exe
set mp4box_exe=C:\Programme\mp4box\MP4Box.exe

set inputvideo=C:\tmp\fps_test.264
set outputvideo=C:\tmp\fps_test_muxed.mp4

"%mediainfo_exe%" --Inform=Video;%%FrameRate%% "%inputvideo%" > "analyze.txt"
set /p video_fps=<"analyze.txt"
del "analyze.txt"

"%mp4box_exe%" -add "%inputvideo%" -fps %video_fps% -new "%outputvideo%"

ricardo.santos
25th October 2009, 11:33
hi dr.schanker, thanks for your advice, thsi is kind of of what im looking for, i will PM you for some specific help.