View Full Version : MeGUI: avi-file as audio source / commandline???
Buzz Lightyear
30th August 2007, 15:59
I've been playing with MeGUI and noticed that I can use an avi file as audio input.
If I set up the task with MeGUI it works just fine. I get an .mp4 output file with the sound of the movieclip.
My problem now is, that I'm trying to make a batchfile for a whole series of clips that I want to convert from xvid/mp3 to x264/aac. I was able to find all the necessary command lines for the batchfile in the MeGUI logfiles, except for the audio conversion (avi --> mp4). neroAacEnc.exe (naturally) doesn't accept avi as input.
Can someone please tell me what MeGUI does to convert the avi-audio directly to mp4?
All the necessary programs must be there, but I have no idea how to do that conversion manually.
Thanks!
Buzz
Sharktooth
30th August 2007, 16:06
the audio goes thru avisynth and the output gets fed to the encoder
that's what megui actually does.
mitsubishi
30th August 2007, 17:26
You can use avi2wav to send the WAV data to neroenc: http://forum.doom9.org/showthread.php?t=124471
eg:
wavi filename.avs - | neroAacEnc_SSE2.exe -ignorelength -he -br 64000 -if - -of filename.mp4
Buzz Lightyear
30th August 2007, 19:03
@mitsubishi:
Thanks. That was exactly what I was looking for.
Goto go now. Will ask some more n00b questions later....
;)
Buzz Lightyear
30th August 2007, 22:51
OK. If I had known before that this would be so time-consuming, I wouldn't have started at all.....
But somehow it's working now. By far not as simple or elegant as I'd wish, but anyhow.
My super complicated batch001.avs-file looks like this:
DirectShowSource("batch001.avi",fps=23.9759856527702)
#deinterlace
#crop
#resize
Undot() # Minimal Noise
My batchfile looks like this:
@echo off
REM Parameters
REM %1 - avisynth script
REM %2 - audio bitrate
REM %3 - video bitrate
call :encode batch001.avs 96000 420
call :encode batch002.avs 96000 420
call :encode batch003.avs 96000 420
<....snip....>
echo Done.....
pause
GOTO :END
:encode
REM Audio Conversion
C:\Programme\megui\wavi.exe "%~f1" - | "C:\Programme\megui\tools\neroaacenc\neroAacEnc.exe" -ignorelength -he -br %2 -if - -of "%~dp1%~n1_audio.mp4"
REM Video Conversion 2-Pass
C:\Programme\megui\tools\x264\x264.exe --pass 1 --bitrate %3 --stats "%~dp1%~n1.stats" --ref 2 --mixed-refs --no-fast-pskip --bframes 3 --b-pyramid --bime --weightb --trellis 1 --analyse all --8x8dct --threads auto --thread-input --progress --no-dct-decimate --no-psnr --no-ssim --output NUL "%~f1"
C:\Programme\megui\tools\x264\x264.exe --pass 2 --bitrate %3 --stats "%~dp1%~n1.stats" --ref 2 --mixed-refs --no-fast-pskip --bframes 3 --b-pyramid --bime --weightb --trellis 1 --analyse all --8x8dct --threads auto --thread-input --progress --no-dct-decimate --no-psnr --no-ssim --output "%~dp1%~n1_video.264" "%~f1"
REM Muxing
C:\Programme\megui\tools\mp4box\MP4Box.exe -add "%~dp1%~n1_video.264" -add "%~dp1%~n1_audio.mp4" -fps 23.9759856527702 -new "%~dp1%~n1_muxed.mp4"
:END
Since I couldn't come up with an idea how to simply feed 40+ files with very long filenames to the script, without editing the filenames in the batchfile AND make seperate .avs-files for each .avi, I renamed all the .avi's to batch001.avi, batch002.avi etc. and made corresponding .avs files.
So I can re-use the .avs files and only need to rename my avi's.
Not very elegant, I know. If someone has a better idea, you're welcome to share...
I still have a couple of questions:
- Does it slow down the audio conversion if I have Undot() in the .avs?
- Can I feed parameters (like %1) to an .avs script? That would maybe allow me to use the same script for all files.
- The audio is slightly too late. How can I fix this? I've been playing with the "-inter" parameter of mp4box, but it doesn't seem to do anything at all.
Regards
Buzz
P.S. Just in case you're wondering: No, I'm not a programmer.... ;)
mitsubishi
30th August 2007, 23:21
Not very elegant, I know. If someone has a better idea, you're welcome to share...You can use the for command: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/for.mspx
- Does it slow down the audio conversion if I have Undot() in the .avs?
It shouldn't do no, because the wavi programme isn't asking for video frames.
- Can I feed parameters (like %1) to an .avs script? That would maybe allow me to use the same script for all files.No, but you can generate an avs script from within the batch script, then run it.
There's a similar script here if it helps: http://forum.doom9.org/showthread.php?p=1024780#post1024780
Buzz Lightyear
31st August 2007, 12:33
Heureka! It works! After all, it was easier than I'd expected in the end.
mitsubishi, you've been most helpful! Thanks!
I succeded in writing a batch file that does exactly what I wanted. It takes all .avis in the scripts folder and converts them to x264/mp4.
I've tried to add some comments to make the batch easier to understand. Maybe it's useful for some of you.
Please feel free to modify the batch to your needs. Suggestions are very welcome.
Regards
Buzz
@echo off
REM http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true
REM %~dp1 Expands %1 to a drive letter and path "c:\test\"
REM %~f1 Expands %1 to a fully qualified path name "c:\test\test.exe"
REM %~nx1 Expands %1 to a file name and extension "test.exe"
REM %~n1 Expands %1 to a file name "test"
REM "encode" Parameters
REM %1 - avisynth script
REM %2 - audio bitrate
REM %3 - video bitrate
cls
echo Batch encoding script v0.2 by Buzz Lighyear 31.08.2007
echo This script converts all .avis it finds in the current folder and converts them to x264/mp4
echo Example: "clip.avi" will become "clip.mp4" (if "clip.mp4" already exist it will be overwritten!)
echo You probably need to modify the options in this script to your needs before running!
echo.
echo Really start encoding?
pause
REM ******Loop all .avis in current dir
for %%f in (*.avi) do (
call :makeavs "%%f"
call :encode batchavs.avs 96000 420
call :rename "%%f"
)
REM ******A little cleaning up
if exist batchavs.avs del batchavs.avs
if exist batchavs_video.264 del batchavs_video.264
if exist batchavs_audio.mp4 del batchavs_audio.mp4
echo Done!
pause
goto :eof
:makeavs
REM ******Your .avs script goes here, change it to your needs
echo DirectShowSource(%1,fps=23.9759856527702) > batchavs.avs
echo Undot() >> batchavs.avs
GOTO :eof
:encode
REM ******Audio Conversion
C:\Programme\megui\wavi.exe "%~f1" - | "C:\Programme\megui\tools\neroaacenc\neroAacEnc.exe" -ignorelength -he -br %2 -if - -of "%~dp1%~n1_audio.mp4"
REM ******Video Conversion 2-Pass (you can copy the commandline options from MeGUI if you want)
C:\Programme\megui\tools\x264\x264.exe --pass 1 --bitrate %3 --stats "%~dp1%~n1.stats" --ref 2 --mixed-refs --no-fast-pskip --bframes 3 --b-pyramid --bime --weightb --direct auto --filter 1,-1 --trellis 1 --analyse p8x8,b8x8,i4x4,p4x4 --threads auto --thread-input --progress --no-dct-decimate --no-psnr --no-ssim --output NUL "%~f1"
C:\Programme\megui\tools\x264\x264.exe --pass 2 --bitrate %3 --stats "%~dp1%~n1.stats" --ref 2 --mixed-refs --no-fast-pskip --bframes 3 --b-pyramid --bime --weightb --direct auto --filter 1,-1 --trellis 1 --analyse p8x8,b8x8,i4x4,p4x4 --threads auto --thread-input --progress --no-dct-decimate --no-psnr --no-ssim --output "%~dp1%~n1_video.264" "%~f1"
REM ******Muxing
C:\Programme\megui\tools\mp4box\MP4Box.exe -add "%~dp1%~n1_video.264" -add "%~dp1%~n1_audio.mp4" -fps 23.9759856527702 -new "%~dp1%~n1_muxed.mp4"
REM ******Cleaning up temp files
if exist batchavs.stats del batchavs.stats
GOTO :eof
:rename
REM ******Rename batchavs_muxed.mp4 to real name
if exist %~n1.mp4 del %~n1.mp4
ren batchavs_muxed.mp4 %~n1.mp4
GOTO :eof
Buzz Lightyear
31st August 2007, 17:46
OK. I've tweaked my batch file a little more. I've added some more avisynth filters (which should work fine with cartoon content), and I've made seperate avs scripts for audio and video processing.
There is certainly a lot more that could be done to make my batch more flexible / safe / sophisticated, but for me it works now. So I'll probably not make any more changes.
Feel free to use/change/modify the batch file to your needs.
If you want to run the whole process at IDLE priority, you shouldn't start batchenc.bat, but instead runlow.bat.
Buzz
batchenc.bat
@echo off
REM Just some reminders for myself :)
REM http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true
REM %~dp1 Expands %1 to a drive letter and path - "c:\test\"
REM %~f1 Expands %1 to a fully qualified path name - "c:\test\test.exe"
REM %~nx1 Expands %1 to a file name and extension - "test.exe"
REM %~n1 Expands %1 to a file name - "test"
REM "encode" Parameters
REM %1 - avisynth script
REM %2 - audio bitrate
REM %3 - video bitrate
REM change log:
REM v0.2: first public release
REM v0.3: made seperate avs files for audio and video because MSmooth f***** up the audio conversion
cls
echo Batch encoding script v0.3 by Buzz Lightyear 31.08.2007
echo.
echo This script converts all .avis it finds in the current folder
echo and converts them to x264/mp4.
echo Example: "clip.avi" will be converted to "clip.mp4"
echo If "clip.mp4" already exists it will be overwritten!
echo You most probably need to modify the options in this script to your needs
echo before running!! The current options should work fine for cartoons.
echo.
echo Really start encoding?
pause
REM ******Loop all .avis in current dir
for %%f in (*.avi) do (
call :makeavs_audio "%%f"
call :encode_audio batchavs.avs 96000 420
call :makeavs_video "%%f"
call :encode_video batchavs.avs 96000 420
call :mux batchavs.avs
call :rename "%%f"
)
REM ******A little cleaning up
if exist batchavs.avs del batchavs.avs
if exist batchavs_video.mp4 del batchavs_video.mp4
if exist batchavs_audio.mp4 del batchavs_audio.mp4
echo Done!
pause
goto :eof
:makeavs_audio
REM ******Your .avs script for audio goes here, change it to your needs
echo DirectShowSource(%1,fps=23.9759856527702) > batchavs.avs
GOTO :eof
:makeavs_video
REM ******Your .avs script for video goes here, change it to your needs
echo DirectShowSource(%1,fps=23.9759856527702) > batchavs.avs
echo Undot() >> batchavs.avs
echo MSmooth(threshold=5, strength=3, chroma=false, mask=false) >> batchavs.avs
GOTO :eof
:encode_audio
REM ******Audio Conversion
C:\Programme\megui\wavi.exe "%~f1" - | "C:\Programme\megui\tools\neroaacenc\neroAacEnc.exe" -ignorelength -he -br %2 -if - -of "%~dp1%~n1_audio.mp4"
goto :eof
:encode_video
REM ******Video Conversion 2-Pass (you can copy the commandline options from MeGUI if you want)
C:\Programme\megui\tools\x264\x264.exe --pass 1 --bitrate %3 --stats "%~dp1%~n1.stats" --ref 2 --mixed-refs --no-fast-pskip --bframes 3 --b-pyramid --bime --weightb --direct auto --filter 2,2 --trellis 1 --analyse p8x8,b8x8,i4x4,p4x4 --threads auto --thread-input --progress --no-dct-decimate --no-psnr --no-ssim --output NUL "%~f1"
C:\Programme\megui\tools\x264\x264.exe --pass 2 --bitrate %3 --stats "%~dp1%~n1.stats" --ref 2 --mixed-refs --no-fast-pskip --bframes 3 --b-pyramid --bime --weightb --direct auto --filter 2,2 --trellis 1 --analyse p8x8,b8x8,i4x4,p4x4 --threads auto --thread-input --progress --no-dct-decimate --no-psnr --no-ssim --output "%~dp1%~n1_video.mp4" "%~f1"
REM ******Cleaning up temp files
if exist batchavs.stats del batchavs.stats
GOTO :eof
:mux
REM ******Muxing
C:\Programme\megui\tools\mp4box\MP4Box.exe -add "%~dp1%~n1_video.mp4" -add "%~dp1%~n1_audio.mp4" -fps 23.9759856527702 -new "%~dp1%~n1_muxed.mp4"
GOTO :eof
:rename
REM ******Rename batchavs_muxed.mp4 to real name
if exist "%~n1.mp4" del "%~n1.mp4"
ren batchavs_muxed.mp4 "%~n1.mp4"
GOTO :eof
runlow.bat
start /LOW /B batchenc.bat
Buzz Lightyear
1st September 2007, 16:54
v0.4: OK. I've updated the script to use AviSource in the avisynth scripts, because DirectShowSource had problems with VBR MP3s in AVI containers.
v0.5: changed from AviSource to DirectShowSource + EnsureVBRMp3Sync because audio was for some reason broken again
batchenc.bat
@echo off
REM Just some reminders for myself :)
REM http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true
REM %~dp1 Expands %1 to a drive letter and path - "c:\test\"
REM %~f1 Expands %1 to a fully qualified path name - "c:\test\test.exe"
REM %~nx1 Expands %1 to a file name and extension - "test.exe"
REM %~n1 Expands %1 to a file name - "test"
REM change log:
REM v0.2: first public release
REM v0.3: made seperate avs files for audio and video because MSmooth f***** up the audio conversion
REM v0.4: changed from DirectShowSource to AviSource, because DirectShowSource has problems with VBR in AVI
REM v0.5: changed from AviSource to DirectShowSource + EnsureVBRMp3Sync because audio was for some reason broken
cls
echo Batch encoding script v0.5 by Buzz Lightyear
echo.
echo This script converts all .avis in the current folder to x264/mp4.
echo Example: "clip.avi" will be converted to "clip.mp4"
echo.
echo You probably need to modify the options in this script to your needs
echo before running!! The current options should work fine for cartoons.
echo.
echo Really start encoding?
pause
REM ******Loop all .avis in current dir
for %%f in (*.avi) do (
echo.
echo ****************************************************************
echo Processing: %%f
echo ****************************************************************
echo.
call :makeavs_audio "%%f"
call :encode_audio batchavs.avs 96000
call :makeavs_video "%%f"
call :encode_video batchavs.avs 420
call :mux batchavs.avs
call :rename "%%f"
echo.
echo ****************************************************************
echo Finished processing: %%f
echo ****************************************************************
echo.
)
REM ******A little cleaning up after all
if exist batchavs.avs del batchavs.avs
if exist batchavs_video.264 del batchavs_video.264
if exist batchavs_audio.mp4 del batchavs_audio.mp4
echo Done!
goto :eof
:makeavs_audio
REM ******Your .avs script for audio goes here, change it to your needs
echo DirectShowSource(%1) > batchavs.avs
echo ensureVBRMp3Sync() >> batchavs.avs
GOTO :eof
:makeavs_video
REM ******Your .avs script for video goes here, change it to your needs
echo AviSource(%1,false) > batchavs.avs
REM echo Undot() >> batchavs.avs
REM echo MSmooth(threshold=5, strength=3, chroma=false, mask=false) >> batchavs.avs
GOTO :eof
:encode_audio
REM ******Audio Encoding
echo *
echo *
echo *
echo *
echo ******** Starting Audio Encoding ********
.\wavi\wavi.exe "%~f1" - | ".\nero\neroAacEnc.exe" -ignorelength -he -br %2 -if - -of "%~dp1%~n1_audio.mp4"
echo ******** Finished Audio Encoding ********
goto :eof
:encode_video
REM ******Video Conversion 2-Pass (you can copy the commandline options from MeGUI if you want)
echo *
echo *
echo *
echo *
echo ******** Starting Video Encoding Pass 1 ********
.\x264\x264.exe --pass 1 --bitrate %2 --stats "%~dp1%~n1.stats" --ref 2 --mixed-refs --no-fast-pskip --bframes 3 --b-pyramid --weightb --direct auto --filter 2,2 --trellis 1 --analyse p8x8,b8x8,i4x4,p4x4 --threads auto --thread-input --progress --no-dct-decimate --no-psnr --no-ssim --output NUL "%~f1"
echo *
echo *
echo *
echo *
echo ******** Starting Video Encoding Pass 2 ********
.\x264\x264.exe --pass 2 --bitrate %2 --stats "%~dp1%~n1.stats" --ref 2 --mixed-refs --no-fast-pskip --bframes 3 --b-pyramid --weightb --direct auto --filter 2,2 --trellis 1 --analyse p8x8,b8x8,i4x4,p4x4 --threads auto --thread-input --progress --no-dct-decimate --no-psnr --no-ssim --output "%~dp1%~n1_video.264" "%~f1"
REM ******Quick 1-pass for testing purposes only
REM .\x264\x264.exe --bitrate %2 --nf --no-cabac --subme 1 --no-chroma-me --analyse none --vbv-maxrate 25000 --me dia --merange 8 --threads auto --thread-input --progress --no-psnr --no-ssim --output "%~dp1%~n1_video.264" "%~f1"
echo ******** Finished Video Encoding ********
REM ******Cleaning up temp files
if exist batchavs.stats del batchavs.stats
GOTO :eof
:mux
REM ******Muxing
echo *
echo *
echo *
echo *
echo ******** Starting Muxing ********
.\mp4box\MP4Box.exe -add "%~dp1%~n1_video.264" -add "%~dp1%~n1_audio.mp4" -fps 23.9759856527702 -new "%~dp1%~n1_muxed.mp4"
echo ******** Finished Muxing ********
GOTO :eof
:rename
REM ******Rename batchavs_muxed.mp4 to real name
if exist "%~n1.mp4" del "%~n1.mp4"
ren batchavs_muxed.mp4 "%~n1.mp4"
echo ******** Written "%~n1.mp4" ********
GOTO :eof
funkydoobie
2nd December 2007, 23:44
I am posting a batch file here that I created after being inspired by the other examples in this thread. I use this file to convert captured DV video files to small, high quality MP4 (H264/AAC) files with embedded subtitles that indicate the original date/time code. The two goals are (1) to play these on a portable media player (most likely the new Creative Zen), and (2) to eventually import these into a media/video cataloging program (none seems to support mp4 well today) and--using the subtitles--quickly locate the tape and location of a given clip. I am posting this file as a means of "giving back" for all of the tips and insights I obtained from this forum, but also to solicit some feedback. Please let me know what you think! (E.g., Would you change the x264 options? Encode the audio differently? Alter the AVS script? Change the batch file?)
Here's the basic workflow; the batch file "code" appears below.
Tools Used for Batch Processing
BePipe: To "pipe" audio from the *.avi files to the Nero AAC encoder
NeroAacEnc: To encode AAC audio
x264: To encode the video
mp4box: To mux the files
(Future) MediaInfo: To write final file information to a log
Workflow
Capture DV video from tape
Use DVDate (http://paul.glagla.free.fr/dvdate_en.htm)to rename clip files and create subtitles (*.srt) with the date and timecode
Run the batch file to create mp4 files
Delete the captured DV *.avi files
Batch File Contents
Lines 001-028: DOS tips/tricks
032-061: "Printed" instructions
072-077: Variables
081-097: The main loop; calls "sub processes" for each avi file found in the directory
100-107: Confirmation of batch completion
111-119: Generate the avs file
AVS pseudo-template for "File.avi" (some lines disabled):
# 1) Store parameter in variable named "Clip"
Clip="File"
# 2) Set clip as DirectShowSource; include audio
DirectShowSource(Clip+".avi",fps=29.97002997002997002997002997003,audio=true)
# Exact frame rate is 30000/1001
# 3) Deinterlace
edeintted = last.AssumeBFF().SeparateFields().SelectEven().EEDI2(field=-1)
TDeint(order=0,edeint=edeintted)
# 4) Crop
crop( 0, 0, -2, -2)
# 5) Resize to 320x240 square pixels
Lanczos4Resize(320,240) Lanczos4 (Sharp)
# 6) Denoise
# 7) TextSub("path\filename.ext"[, charset[, fps]])
# You need textsub (vsfilter) plugin!
# TextSub(Clip+".srt", 25, 25)
# 8) ConvertToYV12
ConvertToYV12()
158-170: Use BePipe to pipe audio from *.avi file to Nero AAC encoder
174-197: Encode video using x264 (two-pass); modified Sharktooth profile for Quicktime
201-213: Generate timed text subtitle file from *.srt file
(NOTE: This is not required; you can mux in an *.srt file directly. I tried this to see if I could get mp4box's "isma" switch to work with the subtitle (see below); it didn't work)
217-239: Mux the mp4 file
243-255: (Future) Tag the mp4 file
259-272: (Future) Create info file for the mp4 file
276-305: Clean up temp files
Things I'd Still Like to Figure Out
How to set the "poster" frame of an MP4 video file (is such a thing spec compliant?)
Use a command line program (e.g., AtomicParsley (http://atomicparsley.sourceforge.net/)) to write tags to the MP4 files (in batch format)
Add subtitles to the MP4 file that are ISMA-compliant (if I add the -isma switch to mp4box, it doesn't mux in the subtitle...)
Create a log file
Create summary info files using the MediaInfo CLI
The Batch File
@echo off
rem **************************************************************************
rem ******************** Batch file tips and tricks ********************
rem **************************************************************************
rem ** [rem] enables commenting; [rem] is better/faster. **
rem ** [echo off] prevents the printing of each command to standard output. **
rem ** [echo.] prints a blank line. **
rem ** [echo text] prints the word "text" on the display **
rem ** [pause] pauses until the user presses a key; displays a prompt **
rem ** [pause > nul] pauses until the user presses a key; no prompt **
rem ** [%1] refers to the first argument passed to the batch file **
rem ** [:end] defines a section of the file called "end" **
rem ** [goto end] transfers execution to the "end" section **
rem ** [if errorlevel 1 goto error] transfers execution to the "error" **
rem ** section if an error occurs; most applications return "0" if no **
rem ** error occurred, and 1 (or higher value) if an error occurred **
rem ** [cls] clears the screen **
rem ** [>file.txt] redirects output to a text file named "file.txt" **
rem ** [>>file.txt] appends output to a text file named "file.txt" **
rem ** **
rem ** For command reference, see: **
rem ** http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true
rem ** **
rem ** For a similar example, see: **
rem ** http://forum.doom9.org/showthread.php?t=129415 **
rem ** **
rem **************************************************************************
rem *** Instructions ***
cls
echo ****************************************************************
echo *********** Batch Processing Media Files ***********
echo ****************************************************************
echo * *
echo * This batch file will convert all .avi files in the current *
echo * folder and convert them to x264/aac mp4 files with subtitles *
echo * Example: "clip.avi" will be converted to "clip.mp4" *
echo * If "clip.mp4" already exists it will be overwritten! *
echo * *
echo * *
echo * For this batch file to work, the following utilities must be *
echo * located in a "Tools" subdirectory: *
echo * - BePipe.exe *
echo * - NeroAacEnc.exe *
echo * - x264.exe *
echo * - mp4box.exe *
echo * *
echo * Also, AviSynth must be installed. *
echo * *
echo * If running Windows Vista, it seems that mp4box must be con- *
echo * figured to run as an administrator. *
echo * *
echo * *
echo * Begin encoding? *
echo * *
echo ****************************************************************
pause
cls
rem *** Error handling ***
if errorlevel 1 goto error
rem *** Variables ***
set video_bitrate=640
set audio_bitrate=128000
set video_ext=264
set audio_ext=aac
rem *** Loop through all .avi files in current directory ***
for %%f in (*.avi) do (
echo *****************************************************************************************
echo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
echo . . . . . . . . . Processing: %%f . . . . . . . . .
echo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
echo *****************************************************************************************
echo.
call :generate_avs "%%f"
call :encode_audio "%%f" %audio_bitrate%
call :encode_video "%%f" %video_bitrate%
call :generate_ttxt "%%f"
call :mux "%%f"
rem call :info "%%f"
call :cleanup "%%f"
rem call :tag "%%f"
)
echo.
echo.
echo *****************************************************************************************
echo ***************** Batch processing is complete *****************
echo *****************************************************************************************
echo.
pause
goto :end
:generate_avs
rem *** Generate AviSynth file for video ***
rem *** %1 is the avi file name ***
echo.
echo *** Generating AVS file ***
echo Input: %~f1
echo Output: %~dpn1.avs
echo.
rem @echo on
echo # ----------------------------------------------------------------->"%~dpn1.avs"
echo # Movie: %~dpn1>>"%~dpn1.avs"
echo # ----------------------------------------------------------------->>"%~dpn1.avs"
echo. >> "%~dpn1.avs"
echo # 1) Store parameter in variable named "Clip" >> "%~dpn1.avs"
echo Clip="%~n1" >> "%~dpn1.avs"
echo. >> "%~dpn1.avs"
echo # 2) Set clip as DirectShowSource; include audio >> "%~dpn1.avs"
echo DirectShowSource(Clip+".avi",fps=29.97002997002997002997002997003,audio=true) >> "%~dpn1.avs"
rem Exact frame rate is 30000/1001, not 29.97000002997
echo. >> "%~dpn1.avs"
echo # 3) Deinterlace >> "%~dpn1.avs"
echo edeintted = last.AssumeBFF().SeparateFields().SelectEven().EEDI2(field=-1) >> "%~dpn1.avs"
echo TDeint(order=0,edeint=edeintted) >> "%~dpn1.avs"
echo. >> "%~dpn1.avs"
echo # 4) Crop >> "%~dpn1.avs"
echo crop( 0, 0, -2, -2) >> "%~dpn1.avs"
echo. >> "%~dpn1.avs"
echo # 5) Resize to 320x240 square pixels >> "%~dpn1.avs"
echo Lanczos4Resize(320,240) # Lanczos4 (Sharp) >> "%~dpn1.avs"
echo. >> "%~dpn1.avs"
echo # 6) Denoise >> "%~dpn1.avs"
echo. >> "%~dpn1.avs"
echo # 7) TextSub("path\filename.ext"[, charset[, fps]]) >> "%~dpn1.avs"
echo # You need textsub (vsfilter) plugin! >> "%~dpn1.avs"
echo # TextSub(Clip+".srt", 25, 25) >> "%~dpn1.avs"
echo. >> "%~dpn1.avs"
echo # 8) ConvertToYV12 >> "%~dpn1.avs"
echo ConvertToYV12() >> "%~dpn1.avs"
echo. >> "%~dpn1.avs"
rem @echo off
echo.
goto :eof
:encode_audio
rem *** Audio encoding: AAC LC 128kbps ***
rem *** %1 is the avi file name; %2 is the bitrate ***
echo.
echo *** Audio encoding ***
echo Input: %~f1
echo Output: %~dpn1.%audio_ext%
echo.
@echo on
Tools\BePipe --script "DirectShowSource(^%~f1^)"|Tools\neroAacEnc.exe -br %2 -lc -if - -of "%~dpn1.%audio_ext%"
@echo off
echo.
goto :eof
:encode_video
rem *** Video encoding: CE-QuickTime profile (tweaked), (command line can be generated with MeGUI or similar x264 GUI) ***
rem *** NOTE: QuickTime 7 supports a maximum of 1 B-frame, i.e. "--bframes=1"
rem *** %1 is the avi file name; %2 is the bitrate ***
echo.
echo *** Video encoding ***
echo Input: %~dpn1.avs
echo Output: %~dpn1.%video_ext%
echo.
echo * First pass *
@echo on
Tools\x264.exe --pass 1 --bitrate %2 --stats "%~dpn1.stats" --fps 30000/1001 --keyint 300 --min-keyint 30 --ref 5 --no-fast-pskip --bframes 2 --b-rdo --direct auto --subme 6 --trellis 1 --analyse p8x8,b8x8,i4x4 --me umh --threads auto --thread-input --progress --no-psnr --no-ssim --output NUL "%~dpn1.avs"
@echo off
echo.
echo * Second pass *
@echo on
Tools\x264.exe --pass 2 --bitrate %2 --stats "%~dpn1.stats" --fps 30000/1001 --keyint 300 --min-keyint 30 --ref 5 --no-fast-pskip --bframes 2 --b-rdo --direct auto --subme 6 --trellis 1 --analyse p8x8,b8x8,i4x4 --me umh --threads auto --thread-input --progress --no-psnr --no-ssim --output "%~dpn1.%video_ext%" "%~dpn1.avs"
@echo off
echo.
goto :eof
:generate_ttxt
rem *** Generate timed text file from srt file for subtitles ***
rem *** %1 is the avi file name ***
echo.
echo *** Generating ttxt file ***
echo Input: %~dpn1.srt
echo Output: %~dpn1.ttxt
echo.
@echo on
Tools\MP4Box -ttxt "%~dpn1.srt"
@echo off
echo.
goto :eof
:mux
rem *** Mux video, audio, and subtitle into MP4 container ***
rem *** %1 is the avi file name ***
rem *** For mp4box usage, see: ***
rem *** - http://gpac.sourceforge.net/doc_mp4box.php ***
rem *** - http://pwet.fr/man/linux/commandes/mp4box ***
rem *** ("-v" switch puts it into verbose mode) ***
rem *** To use ttxt subtitles, "un"comment the "generate_ttxt" conversion call above
echo.
echo *** Muxing MP4 file ***
echo Inputs: %~dpn1.%video_ext%, %~dpn1.%audio_ext%, %~dpn1.ttxt
echo Output: %~dpn1.mp4
echo.
@echo on
Tools\MP4Box.exe -fps 29.97002997002997002997002997003 -add "%~dpn1.%video_ext%:name=Video:lang=en:par=10:11" -add "%~dpn1.%audio_ext%:name=Audio:lang=en" -add "%~dpn1.ttxt:name=Date/Time Code:lang=en" "%~dpn1.mp4" -new -v
@echo off
rem alternative
rem Tools\MP4Box.exe -add "%~dpn1.%video_ext%#1:name=Video:lang=en:fps=30:par=10:11" -add "%~dpn1.%audio_ext%#1:name=Audio:lang=en" -add "%~dpn1.srt:name=Date/Time Code:lang=en" -v -new "%~dpn1.mp4" -isma
echo.
goto :eof
:tag
rem *** Tagging MP4 file ***
rem *** %1 is the avi file name ***
echo.
echo *** Tagging MP4 file ***
echo Inputs: %~dpn1.mp4, %~dpn1.jpg
echo Output: %~dpn1.mp4
echo.
@echo on
rem PUT COMMAND HERE
@echo off
echo.
goto :eof
:info
rem *** Create info file using MediaInfo***
rem *** %1 is the avi file name ***
echo.
echo *** Generating info for MP4 file ***
echo Inputs: %~dpn1.mp4
echo Output: %~dpn1.htm
echo.
@echo on
rem PUT MediaInfo COMMAND HERE
rem Add MediaInfo.exe requirement for tools folder to instructions
@echo off
echo.
goto :eof
:cleanup
rem *** Cleaning up temp files ***
rem *** %1 is the avi file name ***
echo.
echo *** Cleaning up temp files ***
echo Inputs: %~dpn1.%video_ext%, %~dpn1.%audio_ext%, %~dpn1.stats
echo.
if exist "%~dpn1.%video_ext%" (
del "%~dpn1.%video_ext%"
echo "%~dpn1.%video_ext%" deleted
) else echo "%~dpn1.%video_ext%" is missing and cannot be deleted
if exist "%~dpn1.%audio_ext%" (
del "%~dpn1.%audio_ext%"
echo "%~dpn1.%audio_ext%" deleted
) else echo "%~dpn1.%audio_ext%" is missing and cannot be deleted
if exist "%~dpn1.stats" (
del "%~dpn1.stats"
echo "%~dpn1.stats" deleted
) else echo "%~dpn1.stats" is missing and cannot be deleted
if exist "%~dpn1.avs" (
del "%~dpn1.avs"
echo "%~dpn1.avs" deleted
) else echo "%~dpn1.avs" is missing and cannot be deleted
echo.
goto :eof
:error
rem *** Error handling section ***
echo.
echo Something went wrong with batch file
pause
goto :end
:end
rem *** End section ***
echo Goodbye
goto :eof
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.