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 > General > Subtitles

Reply
 
Thread Tools Search this Thread Display Modes
Old 5th February 2013, 13:53   #1  |  Link
LanguidLegend
Registered User
 
Join Date: Jan 2013
Posts: 10
Batch file editing using MKVToolNix

So basically what I'm trying to do is to recursively search out MKV and AVI files in a particular folder and change their apsect ratios to 16:9.

Here is the folder/files setup:
MainFolder\
MainFolder\file1.mkv
MainFolder\file2.avi
...
MainFolder\Subfolder1\
MainFolder\Subfolder1\file1.mkv
MainFolder\Subfolder1\file2.avi
...
MainFolder\Subfolder2\
MainFolder\Subfolder2\file.mkv
...

Here is what I have so far in my batch file (fixAspect.bat):
Code:
@echo off
SET mkvmerge="C:\Program Files (x86)\MKVToolNix\mkvmerge.exe"
CD [C:\...\MainFolder]
FOR /R %%I IN (*.mkv) DO (mkvmerge -v -o "%%~nI (remux).mkv" "--aspect-ratio 16/9" "%%~I")
PAUSE
However it seems to skip right down to the PAUSE line every time.. any ideas why?
LanguidLegend is offline   Reply With Quote
Old 5th February 2013, 14:02   #2  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Any error messages?

For --aspect-ratio you have to supply a trackID: --aspect-ratio 0:16/9

Mkvpropedit can edit display width and height without remuxing, btw.

Last edited by sneaker_ger; 5th February 2013 at 14:04.
sneaker_ger is offline   Reply With Quote
Old 5th February 2013, 14:09   #3  |  Link
LanguidLegend
Registered User
 
Join Date: Jan 2013
Posts: 10
Quote:
Originally Posted by sneaker_ger View Post
Any error messages?

For --aspect-ratio you have to supply a trackID: --aspect-ratio 0:16/9

Mkvpropedit can edit display width and height without remuxing, btw.
Thanks for the quick reply!
So how would I replace mkvmerge with mkvpropedit in that example?
LanguidLegend is offline   Reply With Quote
Old 5th February 2013, 14:19   #4  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
You can either set the values in pixels (most common), like e.g.:
mkvpropedit "%%I" --edit track:v1 --set display-width=1920 --set display-height=1080

Or less common:
mkvpropedit "%%I" --edit track:v1 --set display-width=16 --set display-height=9 --set display-unit=3

Be careful when working on files without a backup. What exactly has to be done depends highly on the source files - working with anamorphic files is not trivial.
sneaker_ger is offline   Reply With Quote
Old 5th February 2013, 14:34   #5  |  Link
LanguidLegend
Registered User
 
Join Date: Jan 2013
Posts: 10
Do you know where I can find a complete list of options for the command, because the source website doesn't list those.
LanguidLegend is offline   Reply With Quote
Old 5th February 2013, 15:00   #6  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Just run the very first command listed on that website:
mkvpropedit -l

Explanations for valid values are listed in the mkv specs.
sneaker_ger is offline   Reply With Quote
Old 5th February 2013, 15:37   #7  |  Link
LanguidLegend
Registered User
 
Join Date: Jan 2013
Posts: 10
That's awesome, think I got it working!
Thanks


One last thing: I've also been trying to write a batch file which would search folders recursively, merging subtitles (.srt files) with the video files of the same name. Would you know how to do that?
LanguidLegend is offline   Reply With Quote
Old 5th February 2013, 16:07   #8  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
FOR /R %%I IN (*.srt) DO (
if exist "%%~nI.mkv" mkvmerge -o "%%~nI (remux).mkv" "%%~nI.mkv" "%%I"
)
sneaker_ger is offline   Reply With Quote
Old 5th February 2013, 16:09   #9  |  Link
LanguidLegend
Registered User
 
Join Date: Jan 2013
Posts: 10
Actually I'm stuck on one snag.
Here is my batch file now:
Code:
@echo on
SET /P folder=Source folder:
CD /D %folder%
PAUSE
FOR /R %%I IN (*.mkv) DO (mkvpropedit "%%~I" --edit track=v1 --set display-width=16 --set display-height=9 --set display-unit=3)
but I get this output:
A:\#Videos\Movies\#Comedy>(mkvpropedit "A:\#Videos\...\file.mkv" --edit track=v1 --set display-width=16 --set display-height=9 --set display-unit=3)
Error: Invalid selector in '--edit track=v1'.
LanguidLegend is offline   Reply With Quote
Old 5th February 2013, 16:13   #10  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
--edit track:v1 with ":".
sneaker_ger is offline   Reply With Quote
Old 5th February 2013, 16:13   #11  |  Link
LanguidLegend
Registered User
 
Join Date: Jan 2013
Posts: 10
Quote:
Originally Posted by sneaker_ger View Post
--edit track:v1 with ":".
oh.... haha thanks
LanguidLegend is offline   Reply With Quote
Old 5th February 2013, 16:29   #12  |  Link
LanguidLegend
Registered User
 
Join Date: Jan 2013
Posts: 10
Thanks for all your help sneaker!

Do you know if there is any utility like this which raises or lowers a video's overall volume?
LanguidLegend is offline   Reply With Quote
Old 5th February 2013, 16:31   #13  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
None that I know of. There are programs like mp3 gain, aac gain and maybe a few others which could be incorporated into a batch but I don't think anything exists that works directly on mkvfiles without re-encoding.
sneaker_ger is offline   Reply With Quote
Old 5th February 2013, 16:36   #14  |  Link
LanguidLegend
Registered User
 
Join Date: Jan 2013
Posts: 10
Aw too bad, because its weird - I have some files (even within the same season/folder) which are very noticeably louder or quieter than the others. I've tried the replay gain option with VLC but it didn't really make a difference..
LanguidLegend is offline   Reply With Quote
Old 5th February 2013, 17:29   #15  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
I'm not saying it's impossible, but it requires some work (time) and depending on the format you'll have to live with quality degradation (though it may be impossible not hear).
sneaker_ger is offline   Reply With Quote
Old 18th February 2013, 10:46   #16  |  Link
LanguidLegend
Registered User
 
Join Date: Jan 2013
Posts: 10
Hey sneaker, got another quick followup question for ya.
So here's my code:
Code:
@echo off
setlocal enabledelayedexpansion
SET /P folder=Source folder:

CD /D %folder%

FOR /R %%I IN (*.avi) DO (
	ECHO %%~fI
	IF EXIST "%%~fI" ( :if an avi file exists, convert it
		echo "%%~I" exists
		mkvmerge -o "%%~dI%%~pI%%~nI.mkv" "%%I"
		IF EXIST "%%~nI.mkv" ( :if mkv conversion successful, then delete source file
			RECYCLE "%%~fI"
			ECHO "%%~I DELETED" )
	)
)

FOR /R %%I IN (*.mp4) DO (
	ECHO %%~fI
	IF EXIST "%%~fI" ( :if an mp4 file exists, convert it
		echo "%%~I" exists
		mkvmerge -o "%%~dI%%~pI%%~nI.mkv" "%%I"
		IF EXIST "%%~nI.mkv" ( :if mkv conversion successful, then delete source file
			RECYCLE "%%~fI"
			ECHO "%%~I DELETED" )
	)
)
pause

FOR /R %%I IN (*.mkv) DO (mkvpropedit "%%~I" --edit track:v1 --set display-width=16 --set display-height=9 --set display-unit=3)
It is going through folders I know have avi & mp4 files in them but the IF EXIST conditional keeps failing for some reason..

Last edited by LanguidLegend; 18th February 2013 at 10:48.
LanguidLegend is offline   Reply With Quote
Old 18th February 2013, 10:53   #17  |  Link
LanguidLegend
Registered User
 
Join Date: Jan 2013
Posts: 10
Actually, figured it out -- had to comment out the setlocal line..
LanguidLegend is offline   Reply With Quote
Reply

Tags
aspect ratio, batch, mkvmerge, mkvtoolnix, subfolders

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 14:51.


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