Extract video lenght to batch file

April 29, 2011 at 08:39:46
Specs: Windows 7
I am creating some simple batch files to encode xvid video. To determine filesize I need to know the lenght of the video. Is it possible to extract that info from a .ts file (mpeg)?

See More: Extract video lenght to batch file

Report •

April 30, 2011 at 07:58:57
You can get that information (and much, MUCH more) using the command line interface version of MediaInfo.

Here's an example of getting some Video information from a specific folder:


REM Setup MediaInfo parameters, delimiting them with a plus sign.
SET Inform_parms=%%Width%%+%%Height%%+%%FrameRate%%+%%Duration/String3%%

REM Find all mp4 files in a specific folder.
FOR /F "delims=" %%A IN ('DIR /B /S "F:\Video\MP4\New Folder\HD\1080\*.mp4"') DO (
    REM Execute MediaInfo.exe on the file found.
    FOR /F "usebackq delims=" %%B IN (`mediainfo.exe "--Inform=Video;%Inform_parms%" "%%~A"`) DO (
        REM Parse the output of MediaInfo.
        FOR /F "tokens=1-4 delims=+" %%C IN ("%%B") DO (
            REM Set variables for later use. 
            SET width=%%C
            SET height=%%D
            SET fps=%%E
            SET duration=%%F
            REM Display the file path and output from MediaInfo.
            ECHO "%%~A"
            ECHO     width    = !width!
            ECHO     height   = !height!
            ECHO     fps      = !fps!
            ECHO     duration = !duration!


mediainfo.exe --Info-Parameters
to get a list of all parameters you can request.

When your only tool is a hammer, every problem looks like a nail.

Report •

April 30, 2011 at 15:42:29
Just what I was looking for, thank you so much orangeboy !!

Report •
Related Solutions

Ask Question