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. Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se |
|
|||||||
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 | Link |
|
Registered User
Join Date: Jul 2011
Posts: 224
|
Guide AviSynth encode x264 trim splice cut commercials autocrop srt subtitle sync
This guide shows how to use AviSynth to encode x264, and cut out commercials in the process.
You may need to adjust the paths or rename files to reflect where you installed AviSynth, I installed AviSynth directly to my 'E:\' partition eg: E:\AviSynth E:\AviSynth\plugins My batch files are directly in my AviSynth folder: E:\AviSynth\bd.bat E:\AviSynth\bd-go.bat software required: Code:
AviSynth 2.6 ffms2.dll (put in AvisSynth plugins folder) NicAudio.dll (put in AvisSynth plugins folder) AutoCrop.dll (put in AvisSynth plugins folder) ffmpeg (E:\AviSynth\ffmpeg\bin\ffmpeg.exe) mkvtoolnix (E:\AviSynth\mkvtoolnix\mkvmerge.exe) x264 (E:\AviSynth\x264.exe) avs2pipe (E:\AviSynth\avs2pipe.exe) http://forum.doom9.org/showthread.php?p=1527344 trimsrt (E:\AviSynth\trimsrt.exe) http://forum.doom9.org/showthread.php?t=162828 neroAacEnc (E:\AviSynth\neroAacEnc.exe) *or* qaac (E:\AviSynth\qaac.exe) There are also some codecs that are required, but if you install CCCP http://www.cccp-project.net/ it will take care of them all. bd.bat <in-file> <fps> <audio-stream-id> <audio-channels> <out-file> <frame1A> <frame1B> <frame2A> <frame2B> example: bd.bat E:\yyh\BDMV\STREAM\00039.m2ts 23.976 0:2 6 004 2832 16675 16872 31270 The above line will take me from the 00039.m2ts file to a trimmed, spliced, cropped, and x264 encoded 004.mkv file with Quicktime TVBR AAC encoded audio (or neroaac), and a trim and adjusted .srt subtitle file if applicable. to determine which audio stream you want and how many channels it has use ffmpeg (for 5.1 use 6, for stereo use 2): Code:
E:\AviSynth\ffmpeg\bin\ffmpeg -i E:\yyh\BDMV\STREAM\00036.m2ts Code:
SET FPS=%~2
if "%~2"=="23.976" SET FPS=24000/1001
del bd.avs
echo A = RaWavSource("E:\AviSynth\job.wav")>>bd.avs
echo V = FFVideoSource("E:\AviSynth\job.mkv")>>bd.avs
echo AudioDub(V, A)>>bd.avs
if not "%~6"=="" echo AlignedSplice(Trim(%6, %7), Trim(%8, %9))>>bd.avs
echo AutoCrop(0,2,2,0,0,0,0,30,5,0,-1,0)>>bd.avs
E:\AviSynth\ffmpeg\bin\ffmpeg -i %1 -vn -sn -y -map %3 -drc_scale 0 -ac %4 -async 1 -acodec pcm_s24le -f wav job.wav
E:\AviSynth\ffmpeg\bin\ffmpeg -i %1 -an -sn -y -vcodec copy -f rawvideo job.h264
E:\AviSynth\mkvtoolnix\mkvmerge -o E:\AviSynth\job.mkv --engage keep_bitstream_ar_info --default-duration 0:%FPS%fps --compression 0:none -d 0 -A -S -T --no-global-tags --no-chapters E:\AviSynth\job.h264
E:\AviSynth\avs2pipe -wav bd.avs | qaac --tvbr 90 --quality 2 --rate keep --ignorelength - -o job.m4a
::E:\AviSynth\avs2pipe -wav bd.avs | neroAacEnc.exe -q 0.5 -ignorelength -if - -of job.m4a
E:\AviSynth\x264 --preset veryslow --crf 22.0 --ref 5 --bframes 16 --no-fast-pskip --output "jobz.mkv" "E:\AviSynth\bd.avs"
E:\AviSynth\mkvtoolnix\mkvmerge -o E:\AviSynth\%5.mkv --engage keep_bitstream_ar_info --compression 1:none -d 1 -A -S -T --no-global-tags --no-chapters E:\AviSynth\jobz.mkv --compression 1:none -a 1 -D -S -T --no-global-tags --no-chapters E:\AviSynth\job.m4a
::E:\AviSynth\trimsrt -i %5.srt -f %FPS% -t %6,%7,%8,%9
::E:\AviSynth\mkvtoolnix\mkvmerge -o E:\AviSynth\%5.mkv --engage keep_bitstream_ar_info --compression 1:none -d 1 -A -S -T --no-global-tags --no-chapters E:\AviSynth\jobz.mkv --compression 1:none -a 1 -D -S -T --no-global-tags --no-chapters E:\AviSynth\job.m4a --compression 0:none -s 0 -D -A -T --no-global-tags --no-chapters E:\AviSynth\%5new.srt
I use --crf 22.0 for Bluray and --crf 20.0 for DVD, some people will use lower or higher, you have to figure out what works for you: https://trac.handbrake.fr/wiki/ConstantQuality To make use of trimsrt uncomment the last two lines in bd.bat by removing the two :: from the beginning of that line, and comment out the mkvmerge line before the last two lines To use trimsrt you have to have the .srt file in the same output directory as the other files (job.mkv, job.wav, bd.bat). Also the .srt file has to have the same filename as your output filename for the finished mkv bd.bat E:\yyh\BDMV\STREAM\00039.m2ts 004 2832 16675 16872 31270 (in this example the output file name is 004, so you would need to name the .srt file 004.srt prior to running bd.bat or bd-go.bat, which means you have to prepare your subs first) With the bd.bat batch file I can queue up as many jobs as I want, by making another batch file that calls bd.bat eg: bd-go.bat: Code:
CALL bd.bat E:\yyh\BDMV\STREAM\00036.m2ts 23.976 0:2 6 001 2112 17685 17854 30940 CALL bd.bat E:\yyh\BDMV\STREAM\00037.m2ts 23.976 0:2 6 002 2833 16127 16296 31296 CALL bd.bat E:\yyh\BDMV\STREAM\00038.m2ts 23.976 0:2 6 003 2832 16463 16632 31295 CALL bd.bat E:\yyh\BDMV\STREAM\00039.m2ts 23.976 0:2 6 004 2832 16703 16872 31295 CALL bd.bat E:\yyh\BDMV\STREAM\00040.m2ts 23.976 0:2 6 005 2856 17471 17640 31295 CALL bd.bat E:\yyh\BDMV\STREAM\00041.m2ts 23.976 0:2 6 006 2832 16727 16896 31295 CALL bd.bat E:\yyh\BDMV\STREAM\00042.m2ts 23.976 0:2 6 007 2856 16367 16536 31295 CALL bd.bat E:\yyh\BDMV\STREAM\00043.m2ts 23.976 0:2 6 008 2856 15935 16104 31295 CALL bd.bat <in-file> <fps> <audio-stream-id> <audio-channels> <out-file> <frame1A> <frame1B> <frame2A> <frame2B> <frame1A> <frame1B> is the frame range to keep before the commercial and, <frame2A> <frame2B> is the frame range to keep after the commercial To figure out the frame range that I needed I used Avidemux, but you could also use AvsP: http://avisynth.org/qwerpoi/ (it has a trim editor with a preview window so you can see exactly what you will get) The Frame Range is optional, if you would like to encode the entire file you can (although if you dont need the frame ranges there are easier ways to do all this) Last edited by xekon; 27th October 2011 at 07:03. |
|
|
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|