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
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 2nd March 2019, 10:03   #21  |  Link
Music Fan
Registered User
 
Join Date: May 2009
Location: Belgium
Posts: 1,744
By the way, you forgot to add VFR in the name for VFR files.
Music Fan is offline   Reply With Quote
Old 2nd March 2019, 17:58   #22  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
Quote:
Originally Posted by Music Fan View Post
Great, thanks !
I see that you didn't put this line ;
Code:
IF NOT DEFINED height GOTO next_file
It's done for width and type but not height, I added it.
No, I did this on purpose (effective coding). If MediaInfo does not report a value for Width then the file is not a video. No reason to check the Height then, one check is all you need.

Quote:
By the way, you forgot to add VFR in the name for VFR files.
No, this was also on purpose. The FrameRate_Mode is not reported under FrameRate, it has its own parameter. I was too lazy to check it, because if you don't get a value for FrameRate then the Mode will always be VFR.

Here is a "universal" template for my needs, it also reports the AspectRatio and the FrameRate_Mode. Under the label "outname" you can easily modify the format of the output to your needs, should be easy...

https://www.sendspace.com/file/hof8bz

Cheers
manolito
manolito is offline   Reply With Quote
Old 2nd March 2019, 20:26   #23  |  Link
Music Fan
Registered User
 
Join Date: May 2009
Location: Belgium
Posts: 1,744
Thanks.
I achieved to add VFR for VFR files, but the script also adds CFR for CFR files while I didn't specify it ; is there a way not to write anything for the FrameRate_Mode when it's CFR ?
For example ;
Code:
FOR /F %%a in ('MediaInfo.exe "--Inform=Video;%%FrameRate_Mode%%" %in%') DO SET fr_mode=%%a
IF "%fr_mode%"=="Variable" SET type=VFR
IF "%fr_mode%"=="Constant" SET type=
I also tried ;
Code:
IF "%fr_mode%"=="Constant" DO NOT SET type
but this adds CFR anyway.
Music Fan is offline   Reply With Quote
Old 2nd March 2019, 21:17   #24  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
The FrameRate_Mode parameter returns CFR or VFR, not Constant or Variable. Use these lines:
Quote:
FOR /F %%a in ('MediaInfo.exe "--Inform=Video;%%FrameRate_Mode%%" %in%') DO SET fr_mode=%%a
SET fr_mode= %fr_mode%
IF "%fr_mode%"==" CFR" SET fr_mode=
and in the "outname" line remove the space character between %fps% and %fr_mode%. Should look like this:
Quote:
%fps%%fr_mode%
If you don't do this your new file name will have an extra space before the dot for CFR files.
manolito is offline   Reply With Quote
Old 3rd March 2019, 09:36   #25  |  Link
Music Fan
Registered User
 
Join Date: May 2009
Location: Belgium
Posts: 1,744
Thanks, I also had to remove 2 spaces : in front of %fr_mode% (second line) and in front of CFR (third line).
Otherwise, CFR was added anyway and a space was added in front of VFR (despite the fact that I removed the space in the "outname" line), now it's perfect
Music Fan is offline   Reply With Quote
Old 9th June 2023, 13:49   #26  |  Link
Music Fan
Registered User
 
Join Date: May 2009
Location: Belgium
Posts: 1,744
Hi manolito,

a few years later, I'm trying to do something else based on your script : change the extension using MediaInfo because I have some video files with wrong extensions and would like to correct them.

I tried to modify your script and made this ;

Code:
@ECHO off
IF !%1==! GOTO syntax
SET Work_Drive=%~d0
SET Work_PATH=%~p0
%Work_DRIVE%
CD "%Work_PATH%"


FOR /F %%a in ('MediaInfo.exe "--Inform=General;%%Format%%" %in%') DO SET Format=%%a
IF NOT DEFINED Format GOTO next_file
FOR /F %%a in ('MediaInfo.exe "--Inform=General;%%Format profile%%" %in%') DO SET ForProf=%%a
IF "%Format%"=="MPEG-TS" SET Format=ts
IF "%Format%"=="Matroska" SET Format=mkv
IF "%Format%"=="Flash Video" SET Format=flv
IF "%Format%"=="AVI" SET Format=avi
IF "%Format%"=="MPEG-4" GOTO FormProf

:FormProf
IF "%ForProf%"=="Base Media" SET Format=mp4
IF "%ForProf%"=="QuickTime" SET Format=MOV

:outname
SET out_name=%in_name%.%Format%


RENAME %in% "%out_name%"
REM COPY /B %in% "%in_path%%out_name%" >NUL


:next_file
SHIFT
IF NOT !%1==! GOTO syntax
GOTO :EOF

:syntax
CLS
ECHO.
Echo Press a key to exit...
PAUSE >nul
I put it with a .bat extension in my MediaInfo folder but it doesn't work, it actually opens MediaInfo but nothing happens with the extension of the file I dropped on the bat.
I guess something's wrong with my code.

mp4 and mov have both the same format for MediaInfo (MPEG-4), that's why I had to redirect them to "Format profile" (with "GOTO FormProf") which helps to distinguish them.

Thanks for your help.

Last edited by Music Fan; 9th June 2023 at 13:54.
Music Fan is offline   Reply With Quote
Old 10th June 2023, 12:59   #27  |  Link
Music Fan
Registered User
 
Join Date: May 2009
Location: Belgium
Posts: 1,744
By the way, if I put it in the same folder than the CLI version you gave me in 2019, I see briefly a DOS command window (as with your script) but nothing happens either on the video file.
Music Fan is offline   Reply With Quote
Old 12th June 2023, 08:22   #28  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 1,545
Since all the sendspace links are dead now, can you put the scripts back up here in doom9 as plain code snippets ?
That would make it possible to troubleshoot & modify, and it would be nice to have them back available again.
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."
Emulgator is offline   Reply With Quote
Old 12th June 2023, 11:09   #29  |  Link
Music Fan
Registered User
 
Join Date: May 2009
Location: Belgium
Posts: 1,744
Yes, here is the code that still works with a 2019 CLI MediaInfo version to add resolution in name ;

Code:
@ECHO off
IF !%1==! GOTO syntax
SET Work_Drive=%~d0
SET Work_PATH=%~p0
%Work_DRIVE%
CD "%Work_PATH%"

:loop
SET in="%~1"
SET in_path=%~dp1
SET in_name=%~n1
SET extension=%~x1
SET width=
SET height=
Set type=
SET fr_mode=
SET fps=

FOR /F %%a in ('MediaInfo.exe "--Inform=Video;%%Width%%" %in%') DO SET width=%%a
IF NOT DEFINED width GOTO next_file
FOR /F %%a in ('MediaInfo.exe "--Inform=Video;%%Height%%" %in%') DO SET height=%%a
FOR /F %%a in ('MediaInfo.exe "--Inform=Video;%%ScanType%%" %in%') DO SET type=%%a
IF NOT DEFINED type SET type=p
IF "%type%"=="Progressive" SET type=p
IF "%type%"=="Interlaced" SET type=i
IF "%type%"=="MBAFF" SET type=i
IF "%type%"=="PAFF" SET type=i
FOR /F %%a in ('MediaInfo.exe "--Inform=Video;%%FrameRate_Mode%%" %in%') DO SET fr_mode=%%a
SET fr_mode=%fr_mode%
IF "%fr_mode%"=="CFR" SET fr_mode=
FOR /F %%a in ('MediaInfo.exe "--Inform=Video;%%FrameRate%%" %in%') DO SET fps=%%a
IF NOT DEFINED fps GOTO outname
:format_fps
IF %fps:~-1%==0 SET fps=%fps:~0,-1%& GOTO format_fps
IF %fps:~-1%==. SET fps=%fps:~0,-1%

:outname
SET out_name=%in_name% %width%.%height%%type%%fps%%fr_mode%


REM ____________________________________________________________________________________________________________
REM Use next command to rename the source file(s), use the command after the next one to copy the source file(s)
REM ____________________________________________________________________________________________________________

RENAME %in% "%out_name%%extension%"
REM COPY /B %in% "%in_path%%out_name%%extension%" >NUL

:next_file
SHIFT
IF NOT !%1==! GOTO loop
GOTO :EOF

:syntax
CLS
ECHO.
ECHO.
ECHO ERROR: No Input File Specified...
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO Syntax is: Rename_Properties.bat Input_file(s)
ECHO.
ECHO.
ECHO You can also drag and drop or copy and paste one
ECHO or multiple input file(s) on the Rename_Properties.bat file.
ECHO.
ECHO.
ECHO Hint: Create a shortcut to Rename_Properties.bat on the desktop.
ECHO Makes it easy to drop input files on the desktop icon...
ECHO.
ECHO.
ECHO.
ECHO.
Echo Press a key to exit...
PAUSE >nul
I didn't use %extension% at the RENAME and REM COPY lines in my new script (see a few posts above), that's maybe the problem but I believed my trick could work.

Last edited by Music Fan; 12th June 2023 at 11:13.
Music Fan is offline   Reply With Quote
Old 14th June 2023, 23:41   #30  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 1,545
Many thanks, Music Fan !
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."
Emulgator is offline   Reply With Quote
Old 28th June 2023, 19:34   #31  |  Link
Music Fan
Registered User
 
Join Date: May 2009
Location: Belgium
Posts: 1,744
Hi Emulgator, did you try to modifiy my script (based on manolito's work) to find the problem ?
Music Fan is offline   Reply With Quote
Old 28th June 2023, 22:59   #32  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 1,545
Not yet, sitting deep in repairs...
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."
Emulgator is offline   Reply With Quote
Old 26th July 2023, 18:54   #33  |  Link
Music Fan
Registered User
 
Join Date: May 2009
Location: Belgium
Posts: 1,744
Hi, I made some modifications and there is a little progress.
But curiously, the code only works with ts, avi and mkv but not with mp4, mov, wmv and flv for which extension is removed
Same problem with a more recent MediaInfo CLI version.

Code:
@ECHO off
IF !%1==! GOTO syntax
SET Work_Drive=%~d0
SET Work_PATH=%~p0
%Work_DRIVE%
CD "%Work_PATH%"

:loop
SET in="%~1"
SET in_path=%~dp1
SET in_name=%~n1
SET extension=

FOR /F %%a in ('MediaInfo.exe "--Inform=General;%%Format%%" %in%') DO SET Format=%%a
IF NOT DEFINED Format GOTO next_file
FOR /F %%a in ('MediaInfo.exe "--Inform=General;%%Format profile%%" %in%') DO SET Format profile=%%a
IF "%Format%"=="MPEG-TS" SET extension=ts
IF "%Format%"=="Matroska" SET extension=mkv
IF "%Format%"=="Flash Video" SET extension=flv
IF "%Format%"=="AVI" SET extension=avi
IF "%Format%"=="MPEG-4" GOTO FormProf

:FormProf
IF "%Format profile%"=="Base Media" SET extension=mp4
IF "%Format profile%"=="Base Media / Version 2" SET extension=mp4
IF "%Format profile%"=="QuickTime" SET extension=MOV

:outname
SET out_name=%in_name%


RENAME %in% "%out_name%.%extension%"
REM COPY /B %in% "%in_path%%out_name%.%extension%" >NUL


:next_file
SHIFT
IF NOT !%1==! GOTO syntax
GOTO :EOF

:syntax
CLS
ECHO.
Echo Press a key to exit...
PAUSE >nul
Music Fan is offline   Reply With Quote
Old 5th August 2023, 11:16   #34  |  Link
Music Fan
Registered User
 
Join Date: May 2009
Location: Belgium
Posts: 1,744
I still made a little modification and now the extension is not removed anymore for mp4, mov, wmv and flv files but is not corrected either, very strange

Code:
@ECHO off
IF !%1==! GOTO syntax
SET Work_Drive=%~d0
SET Work_PATH=%~p0
%Work_DRIVE%
CD "%Work_PATH%"

:loop
SET in="%~1"
SET in_path=%~dp1
SET in_name=%~n1
SET extension=%~x1

FOR /F %%a in ('MediaInfo.exe "--Inform=General;%%Format%%" %in%') DO SET Format=%%a
IF NOT DEFINED Format GOTO next_file
FOR /F %%a in ('MediaInfo.exe "--Inform=General;%%Format profile%%" %in%') DO SET Formatprofile=%%a
IF "%Format%"=="MPEG-TS" SET extension=.ts
IF "%Format%"=="Matroska" SET extension=.mkv
IF "%Format%"=="Flash Video" SET extension=.flv
IF "%Format%"=="AVI" SET extension=.avi
IF "%Format%"=="Windows Media" SET extension=.wmv
IF "%Format%"=="MPEG-4" GOTO FormProf

:FormProf
IF "%Formatprofile%"=="Base Media" SET extension=.mp4
IF "%Formatprofile%"=="Base Media / Version 2" SET extension=.mp4
IF "%Formatprofile%"=="QuickTime" SET extension=.MOV

:outname
SET out_name=%in_name%


RENAME %in% "%out_name%%extension%"
REM COPY /B %in% "%in_path%%out_name%%extension%" >NUL


:next_file
SHIFT
IF NOT !%1==! GOTO loop
GOTO :EOF

:syntax
:syntax
CLS
ECHO.
ECHO.
ECHO ERROR: No Input File Specified...
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO Syntax is: rename_extension_k.bat Input_file(s)
ECHO.
ECHO.
ECHO You can also drag and drop or copy and paste one
ECHO or multiple input file(s) on the rename_extension_k.bat file.
ECHO.
ECHO.
ECHO Hint: Create a shortcut to rename_extension_k.bat on the desktop.
ECHO Makes it easy to drop input files on the desktop icon...
ECHO.
ECHO.
ECHO.
ECHO.
Echo Press a key to exit...
PAUSE >nul
Music Fan 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 11:52.


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