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. |
1st December 2011, 17:36 | #1 | Link |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
x264+aac+mkv Batcher v0.18 ;)
EDIT: I deleted my questions in this first post and I am adding fruits of my work (with huge help of guys in this thread) for whoever might wanna use it.
Updates Hi, guys, muxing stopped to work after I upgraded mkvmerge. Just letting you know, before I figure it out and publish update. Probably some change in CLI syntax, which is really not what I would expect. Batch VAMD.18.rar + ini-file, sourcefilter-file, lot of small improvements Batch VAMD.15.rar What it does: - gets filelists with name like list23.txt, where 23 is desired encoding quality (in the list can be various types of video files and also *.avs files!) - processes the listed files in "test"or "full" mode as set at the beginning of the batchfile - autocrops video - resizes video to mod16 or whatever mod you like - encodes with x264 at constant quality according your wish - logs parameter to adjustments file where it can be overriden for the next pass (for example autocrop is applied only first pass, next time it uses parameters from the adjustments file) - converts audio to 48000kHz - encodes with neroaacenc - removes the (annoying and everywherebeing) neroaacenc delay, so the audio and video are perfectly in sync (unless there is other reason for being out of sync) - muxes audio and video to mkv - deletes some intermediate files - creates lot of files with lot if info, warnings and error reports (thats why I recommend it to run from empty directory) What it does not...todo's?: - MPEG2Source not yet implemented (could be done via directsource but I would prefer not to, but I havent figured that yet ...maybe something like Call (DGDecode)?) - aspect ratio not kept if the source is anamorph...need to get that info from mediainfo and feed it to avs somehow - additional filtering and deinterlacing NEEDS: bat:neroaacenc, x264, mkvtoolnix, wavi, avs:Autocrop,masktools2,RedAverage FIRST TIME: put files to some directory where you'll keep it safe. In Batch VAMD.18.bat replace the path to VAMD.ini.bat file, in the VAMD.ini.bat file set all the parameters relevant for your comp. USAGE: 1. create file list to encode (you can use make_dirs.bat for that purpose) 2. split the list into files named list??.txt (like list20.txt, list25.txt) where ?? stands for encoding quality 3. in the beginning of the ini file write SET process="test" this will enable fast first run to create encoded samples of the sources 4. run the batch file (the batch produces video and various other files) (lists need to be in current directory) 5. look on the results. If you are not satistied you can override values of processing for each file in SourceFilter.avsi and adjustmentsX_?.avsi look also into file dim*.txt where you see some warnings and report and also look into other files produced in the working directory. 6. change the values in SourceFilter.avsi and adjustmentsX_?.avsi if necessary, change SET process="full" and run again, and again and again (or you can run test twice) 7. if you wanna reencode some file, you need to delete it 8. if there was error encoding a file, the excact avs script which caused the error is copied to the source file directory and you can open it in some previewer and editor to see what happened. Mostly the problem is codecs if tyou have some exotic source. 9. the automatically created adjustmentsX_?.avsi format is basically set of avisynth expressions delimited with $$ so feel free to write there whatever you want if you know the consequence. It is applied immediately after opening the file, cropping and everything else happens after. 10. the automatically created SourceFilter.avsi format is source filter decided in form of string strSF="FFVideoSource(srcfile, threads=1)" etc to eval() EXAMPLE 1: You have lot of videos from your digital camera. You run in test mode and for each file is created line in adjustmentsX. But, one of your video you were shooting with camera vertically (turned 90 degree). So, you find the line for that specific video, change it as below. If you are not sure, you can delete the sample video and run again. Code:
"cl=0 $$ ct=0 $$ cr=0 $$ cb=0 $$ modx=16 $$ mody=8 $$ maxwidth=1280 $$ fpsn=1000000 $$ fpsd=33333 $$ ovrsize=0 $$ logadj=0 $$ ACMode=-1 $$ " #before "TurnRight() $$ cl=0 $$ ct=0 $$ cr=0 $$ cb=0 $$ modx=16 $$ mody=8 $$ maxwidth=1280 $$ fpsn=1000000 $$ fpsd=33333 $$ ovrsize=0 $$ logadj=0 $$ ACMode=-1 $$" #after Code:
cl=0 $$ ct=0 $$ cr=0 $$ cb=0 $$ modx=16 $$ mody=8 $$ maxwidth=1280 $$ aw2=640 $$ ah2=360 $$ aw3=640 $$ ah3=360 $$ fpsn=22800 $$ fpsd=1001 $$ ovrsize=0 $$ logadj=0 $$ ACMode=-1 $$ # showcrop=1 crop... modulo dim... downsize? display dim... resize dim... framerate... size override? log this line again? autocrop? It you wanna change the way the script reads input video you have three options: 1. Change SourceFilterTmp.txt - here is how is source handled by default. 2. Change function ChooseMediaFilter() in video_processing_fileX.txt. This is how the video is handled if there is no default settings in 1. or if there was error and retryerr=true in the ini file. 3. Change SourceFilter.avsi which is the file imported during processing. For example add lines like this (strSF should contain the source filter): Code:
strSF=(srcfile!="path1.mp4") ? strSF \ : "DirectShowSource(srcfile)" strSF=(srcfile!="path2.mpg") ? strSF \ : "MPEG2Source(path2.d2v)" 1. You can change adjustmentsX_?.avsi in following way: Find the line which is related to particular source you want to process differently and you can: a) change crop via c?=x b) change modulo resizing via mod?=x c) AssumeFPS via setting fps?=x d) override resizing via a??=x and setting ovrsize=1 e) enable autocrop with ACMode=0 f) add any avs commands to the line separated by $$ as in example 1 g) enable to log new parameters to the file with logadj=1 (this will override the settings in f) Running these changes is recommended in test mode first. 2. Change video_processing_fileX.txt preferably in the dedicated area, like #[universal progressive filtering here] etc Last edited by redfordxx; 20th December 2011 at 06:55. |
1st December 2011, 17:41 | #2 | Link |
Registered User
Join Date: Dec 2008
Location: Germany
Posts: 173
|
I searched such way too.
You can go another way. Make a fixed name for videofile in avs-script e.g. "video.wmv". When you want to convertt a file copy them into dir with avs-script and rename it to "video.wmv". For this example it works, but of course not for other parameters in your avs-script. |
1st December 2011, 18:25 | #3 | Link |
Registered User
Join Date: Sep 2011
Posts: 86
|
Code:
for %%A in (*.wmv) do call :encode %%A goto:eof :encode :: %1 - file to encode ( echo FFVideoSource^("%1", threads=1^) type basic_processing_file.txt ) > tmp.avs "C:\Program Files (x86)\MeGUI\tools\x264\x264_64.exe" --crf 23.0 --output "%~n1.mkv" tmp.avs goto:eof Last edited by gyth; 1st December 2011 at 18:36. |
1st December 2011, 22:27 | #5 | Link | |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
Quote:
Last edited by redfordxx; 1st December 2011 at 22:29. |
|
2nd December 2011, 00:49 | #6 | Link |
Registered User
Join Date: Sep 2011
Posts: 86
|
Code:
for %%A in (*.wmv) do call :encode %%A The for loop calls the encode function on each of the files. Code:
goto:eof Code:
:encode Code:
:: %1 - file to encode Code:
( Code:
echo FFVideoSource^("%1", threads=1^) %1 is one of the file names being passed in from the for loop. Code:
type basic_processing_file.txt Code:
) > tmp.avs Code:
"C:\Program Files (x86)\MeGUI\tools\x264\x264_64.exe" --crf 23.0 --output "%~n1.mkv" tmp.avs %~n1 is the base name of the .wmv, the base name of File1.wmv is File1 Code:
goto:eof |
2nd December 2011, 17:10 | #8 | Link |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
So I ended up with following script, which does the job.
Code:
del all.log for %%A in (*.wmv) do call :encode %%A goto:eof :encode :: %1 - file to encode echo ****************************************************************************** >> all.log echo %1 >> all.log echo ****************************************************************************** >> all.log echo * >> all.log echo * >> all.log ( echo LoadPlugin^("C:\Program Files (x86)\MeGUI\tools\ffms\ffms2-x64.dll"^) echo FFIndex^("%1"^) echo FFVideoSource^("%1", threads=1^) type basic_video_processing_file.txt ) > tmp.avs ( echo LoadPlugin^("C:\Program Files (x86)\MeGUI\tools\ffms\ffms2.dll"^) echo FFIndex^("%1"^) echo FFAudioSource^("%1", 0^) type basic_audio_processing_file11.txt ) > tmpa.avs "C:\Program Files (x86)\MeGUI\tools\x264\x264_64.exe" --crf 23.0 --bframes 8 --b-adapt 2 --ref 8 --qpmin 10 --qpmax 51 --subme 10 --partitions all --trellis 2 --sar 1:1 --output "%~n1.video.mkv" tmp.avs >> all.log "C:\Program Files (x86)\MeGUI\tools\besplit\wavi.exe" "tmpa.avs" - | "C:\Program Files (x86)\MeGUI\tools\neroaacenc\neroaacenc.exe" -q 0.15 -if - -of "%~n1.audio.mp4" >> all.log "C:\Program Files (x86)\MeGUI\tools\mkvmerge\mkvmerge.exe" -o "%~n1.new.mkv" "--language" "1:eng" "--default-track" "1:yes" "--forced-track" "1:no" "-d" "1" "-A" "-S" "-T" "--no-global-tags" "--no-chapters" "%~n1.video.mkv" "--sync" "1:-128" "--forced-track" "1:no" "-a" "1" "-D" "-S" "-T" "--no-global-tags" "--no-chapters" "%~n1.audio.mp4" "--track-order" "0:1,1:1" >> all.log "C:\Program Files (x86)\MeGUI\tools\mkvmerge\mkvmerge.exe" -o "%~n1.audio.mka" "--forced-track" "1:no" "-a" "1" "-D" "-S" "-T" "--no-global-tags" "%~n1.audio.mp4" "--track-order" "0:1" >> all.log "C:\Program Files (x86)\MeGUI\tools\mkvmerge\mkvinfo.exe" "%~n1.audio.mka" >> all.log del "%~n1.video.mkv" del "%~n1.audio.mka" echo * >> all.log echo * >> all.log echo * >> all.log goto:eof 1 Spaces in filenames: %1 seems to have really problem with that. It returns only the part of the filename before first space. How to solve it? 2 Filelist as an input: how should I modify the script to process files in a filelist I specify, instead of *.wmv? The filelist will be something like dir * /b/s > f.txt and then manually deleted files which I dont want to process. 3 Logging x264 and neroaacenc do not write to the logfile. I think it is because they do not output text report to stdout but to stderr...my guess... is there anything to do with tthat? 4 Deleting I am deleting the intermediate video file. However, if there is a problem in muxing (it means *.new.mkv doesnot exist) I want to keep it. How to do it? 5 If I want to filter the output of mkvinfo and for example to log only line, which contains only one of these expressions "+ Duration:", "+ Default duration:" and "ChapterTimeStart", how to do that. 6 Is it possible to have date and time as a part of the name of the logfile? 7 In the avs script I will resize the video to 1280x???, if it is bigger, while keeping the size otherwise. Since I have to stick to mod 16, that can introduce aspect ratio error. I will calculate that error or the correct display dimensions in avs, but how do I pass it to x264 or mkvmerge? BTW I am on Win7, in case it matters. I am sorry, lot of question. I you dont have time, please at least number one, which is critical. Thank you again Last edited by redfordxx; 2nd December 2011 at 17:12. |
2nd December 2011, 17:54 | #9 | Link | |||||||
Registered User
Join Date: Oct 2010
Posts: 36
|
Quote:
if %1 contains spaces it should automatically have ", however %~1 removes the " so "%~1" will ensure all paths are inside Quote:
Quote:
Quote:
Code:
IF EXISTS "%~n1.new.mkv" do ( del "%~n1.video.mkv" del "%~n1.audio.mka" ) Quote:
Quote:
Code:
:timelog echo %TIME% %1 >> log.txt goto:EOF Quote:
Code:
set /A height=<calculation> NOTE: I haven't tested most of the code here but they should work - if not try typing the the command (so if,for etc) followed by a /? to get the help from these commands. Last edited by splinter98; 2nd December 2011 at 17:57. |
|||||||
2nd December 2011, 19:31 | #10 | Link |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
1]
Code:
echo FFIndex^("%~1"^) 3] 2>> gives me line per line progress of the encoding...so I guess this is not the way, but its not that important 6] but I meant the time part of the filename. Like echo text >> log_2011-12-02-10-00.txt btw: What exactly %~n1 does? Seems like the name part of the file. But what when there is whole path in the variable? |
2nd December 2011, 19:43 | #11 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
From Command Prompt type "help for".
EDIT: or eg, 'help for >c:\For.txt'
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 2nd December 2011 at 19:46. |
2nd December 2011, 19:43 | #12 | Link |
Registered User
Join Date: Sep 2011
Posts: 86
|
Code:
for %%A in (*.wmv) do call :encode %%A Code:
for /F %%A in (f.txt) do call :encode "%%A" Last edited by gyth; 2nd December 2011 at 19:49. |
2nd December 2011, 20:08 | #13 | Link | |
Registered User
Join Date: Sep 2011
Posts: 86
|
Quote:
Code:
@echo off call :log_name log echo %log% pause goto:eof :log_name :: %1 - variable that the log name will be returned to SETLOCAL for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('"echo.|date"') do ( for /f "tokens=1-3 delims=/.- " %%A in ("%date:* =%") do ( set %%a=%%A&set %%b=%%B&set %%c=%%C)) set /a "yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100" for /f "tokens=1-4 delims=:. " %%A in ("%time: =0%") do set log_name=log_%yy%-%mm%-%dd%-%%A-%%B-%%C-%%D.txt ENDLOCAL & SET %~1=%log_name% goto:eof Code:
call :log_name log for /F %%A in (f.txt) do call :encode "%%A" goto:eof :encode :: %1 - file to encode echo ****************************************************************************** >> %log% ... Last edited by gyth; 2nd December 2011 at 20:16. |
|
2nd December 2011, 21:26 | #14 | Link |
Registered User
Join Date: Sep 2011
Posts: 86
|
x264 can resize
--video-filter resize:1280,,,width but that would upsize things smaller than 1280 as well. Code:
"C:\Program Files (x86)\anrichan3.3\x264.exe" "%~nx1" --frames 1 -o NUL 2>tmp.txt :: avs [info]: 1920x1080p 0:0 @ 60001/1001 fps (cfr) FOR /F "tokens=3 delims=x " %%B IN ('TYPE tmp.txt ^| FIND "avs [info]: "') DO ( SET vf= if %%B GTR 1280 SET "vf= --video-filter resize:1280,,,width " ) Hum, but that doesn't seem to set the SAR right. It gets as close to 1:1 as it can (mod8?) and then sets it to 1:1 even it is a little bit off. Resizing to 1280x720 "--video-filter resize:1280,720" gets the SAR set correctly, but it is possibly far from square pixels depending on how wacky your sources are. |
2nd December 2011, 23:11 | #15 | Link |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
EDIT:Ooops, I didn't refresh the browser since your post 12. So maybe here is something off.
Well here is the script as of now in case anyone finds this thread and would like to use it Code:
@IF EXIST batchlog.log del batchlog.log @IF EXIST all.log del all.log @for %%A in (*.wmv) do call :encode "%%A" ::@for /F "tokens=* " %%A in (list.txt) do call :encode "%%A" @goto:finish :encode :: %1 - file to encode @IF EXIST "%~dpn1.new.mkv" ( echo ********************************************************* >> batchlog.log echo "%~dpn1.new.mkv" exists and was fully skipped >> batchlog.log echo ********************************************************* >> batchlog.log goto:eof) @echo ********************************************************* >> all.log @echo %1 >> all.log @echo ********************************************************* >> all.log @echo * >> all.log @echo * >> all.log @( echo LoadPlugin^("C:\Program Files (x86)\MeGUI\tools\ffms\ffms2-x64.dll"^) echo FFIndex^("%~1"^) echo FFVideoSource^("%~1", threads=1^) type "D:\video\_process\_processing\basic_video_processing_file.txt" ) > tmp.avs @IF EXIST "%~dpn1.video.mkv" ( echo ********************************************************* >> batchlog.log echo "%~dpn1.video.mkv" exists and was not encoded >> batchlog.log echo ********************************************************* >> batchlog.log ) ELSE ( "C:\Program Files (x86)\MeGUI\tools\x264\x264_64.exe" --crf 23.0 --bframes 8 --b-adapt 2 --ref 8 --qpmin 10 --qpmax 51 --subme 10 --partitions all --trellis 2 --sar 1:1 --output "%~dpn1.video.mkv" tmp.avs >> all.log ) @( echo LoadPlugin^("C:\Program Files (x86)\MeGUI\tools\ffms\ffms2.dll"^) echo FFIndex^("%~1"^) echo FFAudioSource^("%~1"^) type "D:\video\_process\_processing\basic_audio_processing_file11.txt" ) > tmpa.avs @IF EXIST "%~dpn1.audio.mp4" ( echo ********************************************************* >> batchlog.log echo "%~dpn1.audio.mp4" was overwritten >> batchlog.log echo ********************************************************* >> batchlog.log ) @"C:\Program Files (x86)\MeGUI\tools\besplit\wavi.exe" "tmpa.avs" - | "C:\Program Files (x86)\MeGUI\tools\neroaacenc\neroaacenc.exe" -q 0.15 -if - -of "%~dpn1.audio.mp4" >> all.log @"C:\Program Files (x86)\MeGUI\tools\mkvmerge\mkvmerge.exe" -o "%~dpn1.new.mkv" "--language" "1:eng" "--default-track" "1:yes" "--forced-track" "1:no" "-d" "1" "-A" "-S" "-T" "--no-global-tags" "--no-chapters" "%~dpn1.video.mkv" "--sync" "1:-128" "--forced-track" "1:no" "-a" "1" "-D" "-S" "-T" "--no-global-tags" "--no-chapters" "%~dpn1.audio.mp4" "--track-order" "0:1,1:1" >> all.log @"C:\Program Files (x86)\MeGUI\tools\mkvmerge\mkvmerge.exe" -o "%~dpn1.audio.mka" "--forced-track" "1:no" "-a" "1" "-D" "-S" "-T" "--no-global-tags" "%~dpn1.audio.mp4" "--track-order" "0:1" >> all.log @"C:\Program Files (x86)\MeGUI\tools\mkvmerge\mkvinfo.exe" "%~dpn1.audio.mka" >> all.log @IF EXIST "%~dpn1.new.mkv" ( del "%~dpn1.video.mkv" del "%~dpn1.audio.mp4" ) @del "%~dpn1.audio.mka" @del "%~1.ffindex" @echo * >> all.log @echo * >> all.log @echo * >> all.log @goto:eof :finish @pause Code:
DelayAudio(11.0/1000.0) SSRC(48000) return last Code:
DelayAudio(31.0/1000.0) SSRC(48000) return last Code:
o=last w=o.width w2=(w>1280 ? 1280 : w) w3=((w2+15)/16)*16 w3=(w3>w ? w3-16 : w3) h=o.height h2=h*w2/w h3=((h2+15)/16)*16 h3=(h3>h ? h3-16 : h3) #display dimensions are w2 , h2 (w<=1280) ? o : o.BicubicResize(w3,h3,0,0.75) 1) checking the nero's audiodelay (because it requires the grep function) 2) checking aspect ratio in case of resizing (the variable is calculated in avs environment and I have to use it in commandline) But besides that, I think it does everything fine....thanks again Last edited by redfordxx; 2nd December 2011 at 23:14. |
2nd December 2011, 23:16 | #16 | Link |
Registered User
Join Date: Sep 2011
Posts: 86
|
@echo off
at the start will keep it from talking back at you without needing @s everywhere. Code:
w3=((w2+15)/16)*16 w3=(w3>w ? w3-16 : w3) Last edited by gyth; 2nd December 2011 at 23:22. |
3rd December 2011, 00:55 | #18 | Link |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
the date and time thing seems to more or less work, but how the hell happened that the variables in this line
Code:
set /a "yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100" |
3rd December 2011, 01:30 | #19 | Link |
Registered User
Join Date: Sep 2011
Posts: 86
|
Code:
set %%a=%%A One of the for loops is going through yy, mm, dd while the other is their values. This is used because not everyone uses the same date format; MM/DD/YYYY, YYYY/MM/DD, DD/MM/YYY On my system it is Code:
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('"echo.|date"') do ( :: The current date is: Fri 12/02/2011 :: Enter the new date: (mm-dd-yy) for /f "tokens=1-3 delims=/.- " %%A in ("%date:* =%") do ( :: 12/02/2011 |
|
|