Information For Encoders
Introduction to Encoding
Encoding is the process of taking the raw video, rendering the subtitles onto the video and compressing it. Most video compression is lossy. It operates on the premise that much of the data present before compression is not necessary for achieving good perceptual quality. For example, DVDs use a video coding standard called MPEG-2 that can compress ~2 hours of video data by 15 to 30 times while still producing a picture quality that is generally considered high quality for standard-definition video. Video compression, like data compression, is a trade off between disk space, video quality and the cost of hardware required to decompress the video in a reasonable time. However, if the video is over compressed in a lossy manner, visible artifacts can appear.
A helpful tool for splitting the audio from a raw capture was created for use with BeSplit. Encoders can use
the tool to calculate the times that need to be split and generate the necessary .bat file for automating the splitting process.
Click here to visit the splitting tool.
The Definitive 120fps Subbing Guide
I. Preparing 120fps AVI files for Subtitling
To sub such files, first we must split the source file to video file and a timecode file. For this, we're going to use the avi_tc_package.
1. Launch tc-GUI and load the source file into the cfr2tc tab
2. Set the Output AVI File and the Output TC (timecode) file
3. Mode should be set to v1 timecode file, AVI output
4. Press Run
The resulting Output AVI file doesn't have any audio so the audio track of the original file must be demuxed using VDubMod, for example.
1. Load the source file into VDubMod
2. Go to Streams...Stream list and Demux the audio track
We now have three files:
video file (AVI)
timecode file (TXT)
audio file (MP3)
II. Preparing Variable Framerate DVD Videos for Subtitling
In order for this to work, we need to create a video file and a timecode file, using framerate autodetection. This will require TIVTC. The following method describes the 2-pass VFR mode.
Pass One
1. Index the input video using DGIndex as usual, make sure you demux the audio too
2. Create the following AVS (1) file
LoadPlugin("dgdecode.dll")
LoadPlugin("tivtc.dll")
d2vpath = "input.d2v"
mpeg2source(d2vpath)
tfm(d2v=d2vpath,output="tfm.txt")
tdecimate(mode=4,output="tdec.txt")
crop(344,224,-344,-224)
3. Load the file (1) into Virtualdub (do not seek!)
4. Save the file without using any video codec (the resulting video file can be discarded after the process is done)
This will autodetect the framerate for the entire input video. The resulting text files will be loaded in the second pass.
Pass Two
1. Create the following AVS (2) file
LoadPlugin("dgdecode.dll")
LoadPlugin("tivtc.dll")
d2vpath = "ep1.d2v"
mpeg2source(d2vpath)
tfm(d2v=d2vpath,input="tfm.txt")
# If your source is not anime or cartoon then add vfrDec=0 into the line below
tdecimate(mode=5,hybrid=2,input="tdec.txt",tfmIn="tfm.txt",mkvOut="timecodes.txt")
AssumeFPS(29.97)
# add other processing below, such as filtering
# cropping, resizing, color correction, etc...
2. Open the file (2) into VirtualDub so the timecode file is created
3. There are two options to start subtitling the video
A: Save the video in VirtualDub
B: Load the second pass AVS into Aegisub directly
III. VFR Subtitling in Aegisub
The files resulting from either I. or II. can now be loaded into Aegisub for subtitle processing. Load the video and audio files, then load the timecode file using the Video...Open timecodes file menu. This way the video should play in sync with the audio. Proceed with subbing normally.
In order for the subs to work while rendering later, they must be exported (File...Export Subtitles). Set the output to Variable Framerate and make sure the framerate matches the AVI/AVS file that was loaded into Aegisub.
IV. Rendering and Creating VFR Subtitled Video Files
To render the subtitles into the video, we must use the subtitle file that's been exported from Aegisub in part III. Load the subtitles into the AVS script (2) and render the file using your preferred conversion software.
There are two available output types
A. Variable Framerate MKV
1. Load the rendered file and the audio file into MKVMerge GUI
2. Select the video track add the timecode file to its properties
3. Start the saving process. Done.
B: 120fps AVI (Not Recommended)
1. Fire up tc-GUI and select the tc2cfr tab
2. Load the rendered video file and the timecode file into the appropriate fields
3. Set the Output AVI File; the Output AVI FPS should remain default (120000/1001)
4. Run the conversion process
5. Load the resulting output file into VDubMod
6. Add the audio track and save the file. Done.
The Definitive VFR MP4 Subbing Guide
I. Source Preparation
Demultiplexing MP4 files for subbing use, is a two-step process. For reliable results, we're going to convert the MP4 to MKV first, then demux everything from that. Below, you can find the appropriate command lines do perform these operations.
1. Conversion
mkvmerge -o output.mkv -a 2 -d 1 -S input.mp4 --track-order 0:1,0:2
2. Demultiplexing
mkvextract tracks output.mkv 2:audio.aac // extract audio
mkv2vfr output.mkv video.avi timecodes.txt // extract video + timecodes file
3. Note, there may be errors in the timecodes file that is produced. To check, open up the timecodes.txt in a text editor and look for lines that have an FPS value of 500.000 or 1000.000. Example:
752,1912,59.9442
1913,1913,1000.0000
To repair this, alter the first line of the file to go to 1931 (i.e., 752,1913) and then delete the line with the 1000.0000 FPS.
II. Aegisub Subtitling
To correctly load H.264 AVI video into Aegisub, it has to be done thru Avisynth. The following procedure describes it how.
1. Create the following AVS file
directshowsource("video.avi")
assumefps(30)
2. Open the AVS file in Aegisub
3. Open the corresponding timecodes file
III. Encoding
1. AVS Scripts for Encoding
--- HD ---
loadplugin("VSFilter.dll")
directshowsource("video.avi")
AssumeFPS(30)
textsub("DP.ass",vfr="timecodes.txt")
textsub("[PM]High_Touch(HD).ass",vfr="timecodes.txt")
textsub("[PM]Pichu(compiled).ass",vfr="timecodes.txt")
--- SD ---
loadplugin("VSFilter.dll")
directshowsource("video.avi")
AssumeFPS(30)
textsub("DP.ass",vfr="timecodes.txt")
textsub("[PM]High_Touch(HD).ass",vfr="timecodes.txt")
textsub("[PM]Pichu(compiled).ass",vfr="timecodes.txt")
lanczos4resize(720,480)
Note: needs VSFilter v2.39e or higher!
Download
2. x264 Encoding Settings
x264 --crf 18 --ref 8 --mixed-refs --no-fast-pskip --bframes 4 --b-pyramid --bime --weightb --trellis 0 --analyse all --8x8dct --direct auto --me umh --threads auto --progress --thread-input --no-psnr --no-ssim --output dpepnumberhd.mp4 hd.avs