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.

Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se

 

Go Back   Doom9's Forum > Announcements and Chat > General Discussion
Register FAQ Today's Posts Search

Reply
 
Thread Tools Search this Thread
Old 22nd July 2008, 18:11   #1  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,392
mediainfo from batch

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...)
__________________
certain other member
smok3 is offline   Reply With Quote
Old 22nd July 2008, 18:25   #2  |  Link
RunningSkittle
Skittle
 
RunningSkittle's Avatar
 
Join Date: Mar 2008
Posts: 539
its because command prompt thinks

Code:
%Duration/String3%
is an environment variable.

try this

Code:
%%Duration/String3%%
mediainfo really should have used a different deliminator...
RunningSkittle is offline   Reply With Quote
Old 22nd July 2008, 18:28   #3  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,392
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)
__________________
certain other member
smok3 is offline   Reply With Quote
Old 22nd July 2008, 18:34   #4  |  Link
RunningSkittle
Skittle
 
RunningSkittle's Avatar
 
Join Date: Mar 2008
Posts: 539
I just made this script, it works exactly as it should

Code:
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:

Code:
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?

Last edited by RunningSkittle; 22nd July 2008 at 18:46.
RunningSkittle is offline   Reply With Quote
Old 22nd July 2008, 21:07   #5  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,392
tnx, will post tommorow what i did.
__________________
certain other member
smok3 is offline   Reply With Quote
Old 23rd July 2008, 04:00   #6  |  Link
cdanddvdpublisher
Registered User
 
Join Date: Mar 2008
Posts: 93
Quote:
Originally Posted by RunningSkittle View Post
I just made this script, it works exactly as it should

Code:
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:

Code:
01:56:26.146

looks good - hope it helps the guy/gal out
cdanddvdpublisher is offline   Reply With Quote
Old 23rd July 2008, 08:12   #7  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,392
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
Code:
@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
Code:
@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.
__________________
certain other member

Last edited by smok3; 23rd July 2008 at 08:36.
smok3 is offline   Reply With Quote
Old 23rd July 2008, 13:04   #8  |  Link
RunningSkittle
Skittle
 
RunningSkittle's Avatar
 
Join Date: Mar 2008
Posts: 539
To avoid creating a temporary file, use the "usebackq" option

Code:
@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
RunningSkittle is offline   Reply With Quote
Old 23rd July 2008, 13:42   #9  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,392
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).

Quote:
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
__________________
certain other member

Last edited by smok3; 23rd July 2008 at 13:47.
smok3 is offline   Reply With Quote
Old 23rd July 2008, 14:08   #10  |  Link
RunningSkittle
Skittle
 
RunningSkittle's Avatar
 
Join Date: Mar 2008
Posts: 539
"usebackq", use-back-quotes lets "for /f" parse the output of a command in a "back quoted" string. for example
Code:
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:
Code:
set duration="%mediainfo% --Inform=General;%%Duration/String3%% %file%"
Rather you could... but it wouldn't have the desired effect

Last edited by RunningSkittle; 23rd July 2008 at 14:11.
RunningSkittle is offline   Reply With Quote
Old 23rd July 2008, 16:35   #11  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,392
i got what it does, syntax is greek.
__________________
certain other member
smok3 is offline   Reply With Quote
Old 25th October 2009, 10:45   #12  |  Link
ricardo.santos
Registered User
 
ricardo.santos's Avatar
 
Join Date: Mar 2005
Location: Portugal
Posts: 908
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?
ricardo.santos is offline   Reply With Quote
Old 25th October 2009, 12:16   #13  |  Link
dr.schanker
Registered User
 
dr.schanker's Avatar
 
Join Date: Feb 2002
Location: Berlin, Germany
Posts: 23
The following example works for me:

Code:
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%"
dr.schanker is offline   Reply With Quote
Old 25th October 2009, 12:33   #14  |  Link
ricardo.santos
Registered User
 
ricardo.santos's Avatar
 
Join Date: Mar 2005
Location: Portugal
Posts: 908
hi dr.schanker, thanks for your advice, thsi is kind of of what im looking for, i will PM you for some specific help.
ricardo.santos is offline   Reply With Quote
Old 21st August 2012, 14:17   #15  |  Link
dvdboy
Registered User
 
Join Date: Mar 2003
Posts: 191
Apologies in bumping such a really old post, but I am trying to achieve something similar but don't understand enough about the syntax.

I want to create a csv file which contains a breakdown of a folder's filenames, durations and filesizes.

I can get as far as:

Code:
mediainfo.exe "--Inform=General;%FileName%,%Duration/String%,%FileSize%" <PATH TO A FILE> >e:\output.csv
But I don't know how to repeat the command for every file in a directory.

Many Thanks for any pointers!
dvdboy is offline   Reply With Quote
Old 21st August 2012, 22:45   #16  |  Link
dr.schanker
Registered User
 
dr.schanker's Avatar
 
Join Date: Feb 2002
Location: Berlin, Germany
Posts: 23
Hi dvdboy,

This is a really helpful site. And here a two working examples from a .bat file:

Example 1 - analyzes all files in a directory
Code:
set mi_exe=C:\tmp\MediaInfo_CLI_0.7.59_Windows_i386\MediaInfo.exe
set input_folder=C:\test_videos

For %%x in ("%input_folder%\*.*") Do (
	"%mi_exe%" --Inform=General;%%FileName%%,%%Duration/String%%,%%FileSize%% "%%~x">>"E:\output.csv"
)
Example 2 - analyzes all files in a directory recursively (existing subfolders will also be searched)
Code:
set mi_exe=C:\tmp\MediaInfo_CLI_0.7.59_Windows_i386\MediaInfo.exe
set input_folder=C:\test_videos

For /R "%input_folder%" %%x in ("*.*") Do (
	"%mi_exe%" --Inform=General;%%FileName%%,%%Duration/String%%,%%FileSize%% "%%~x">>"E:\output.csv"
)
Just adapt the variables %mi_exe% and %input_folder%.
Please note that in a .bat file you have to add another "%" to the MediaInfo-Informstring, so "%Duration/String%" becomes "%%Duration/String%%".
With the redirect symbol ">>" the Info from MediaInfo for a single file will be appended to the file "E:\output.csv".
dr.schanker is offline   Reply With Quote
Old 22nd August 2012, 14:47   #17  |  Link
dvdboy
Registered User
 
Join Date: Mar 2003
Posts: 191
Many Thanks Dr. Schanker. I will give those a go, and check out that site.
dvdboy is offline   Reply With Quote
Old 26th December 2014, 14:25   #18  |  Link
Shezed
Registered User
 
Join Date: Dec 2014
Posts: 7
Quote:
Originally Posted by RunningSkittle View Post
To avoid creating a temporary file, use the "usebackq" option

Code:
@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
I'm trying to achieve this yes, but your code doesn't work for me
%%a doesn't seem to contain anything for me
Code:
%mediainfo% --Inform=General;%%Duration/String3%% %file%
does work ( i know it's old but i thought better than duplicating it
Shezed is offline   Reply With Quote
Old 30th January 2017, 00:58   #19  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,854
with powershell it looks like so:

Code:
PS D:\Video> get-mediainfo D:\Temp\Video\Eli.mp4 | select -ExpandProperty Duration_String3
00:00:43.420
PS D:\Video> $duration = get-mediainfo D:\Temp\Video\Eli.mp4 | select -ExpandProperty Duration_String3
PS D:\Video> $duration
00:00:43.420
stax76 is offline   Reply With Quote
Reply


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 19:15.


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