raymod2
22nd December 2005, 07:05
This article describes my method to convert raw digital video into an MP4 file. It strictly uses command line utilities. I offer it up to invite comments and solicit suggestions for improvement. Also I thought it might give others a starting point if they have never done this before.
First you will need to collect and install the following tools:
AviSynth 2.5.6a
---------------
link: http://www.avisynth.org
EEDI2 v0.9
----------
compiled by: tritical
thread: http://forum.doom9.org/showthread.php?t=82264
link: http://bengal.missouri.edu/~kes25c/EEDI2v09.zip
TDeint v1.0 RC2
---------------
compiled by: tritical
thread: http://forum.doom9.org/showthread.php?t=82264
link: http://bengal.missouri.edu/~kes25c/TDeintv1RC2.zip
x264 CLI encoder v389
---------------------
compiled by: Sharktooth
thread: http://forum.doom9.org/showthread.php?t=89979
link: http://files.x264.nl/Sharktooth/force.php?file=./x264-Full_r389.exe
avs2wav v1.0
------------
compiled by: kassandro
thread: http://forum.doom9.org/showthread.php?t=70882
link: http://home.pages.at/kassandro/avs2wav.rar
FAAC v1.24.1
------------
thread: http://forum.doom9.org/showthread.php?t=68300
link: http://rarewares.org/aac.html
MP4Box v0.4.1-DEV
-----------------
compiled by: Celtic Druid
thread: http://forum.doom9.org/showthread.php?t=94874
link: http://www.aziendeassociate.it/cd.asp?dir=/gpac/dev
Haali Media Splitter
--------------------
thread: http://forum.doom9.org/showthread.php?t=89979
link: http://haali.cs.msu.ru/mkv/
ffdshow-20051129
----------------
compiled by: Milan
thread: http://forum.doom9.org/showthread.php?t=89979
link: http://ffdshow.sourceforge.net/tikiwiki/tiki-index.php?page=Getting+ffdshow
notes: when installing check only H.264,X264 video codec and AAC audio codec;
after installing go to the audio decoder configuration and select realaac
for the AAC decoder (libfaad2 results in garbled sound for me)
Next you need to create an AviSynth script. It should look something like this:
DirectShowSource("C:\Documents and Settings\Dan\My Documents\Adobe\Premiere Pro\1.5\distance.avi")
#AssumeBFF().SeparateFields() # use this to check if the video is BFF or TFF
#return last
mark = trim(849,1491)
jay1 = trim(3855,4481)
jay2 = trim(9331,10191)
last = mark + jay1 + jay2
# Deinterlace
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\EEDI2.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\TDeint.dll")
interp = separatefields().selecteven().EEDI2(field=0) # BFF
TDeint(order=0,field=0,edeint=interp) # BFF
#interp = separatefields().selecteven().EEDI2(field=1) # TFF
#tdeint(order=1,field=1,edeint=interp) # TFF
# Resize to square pixels
# FS source multiply horz by 10/11 (720x480 -> 656x480)
# WS source multiply vert by 33/40 (720x480 -> 720x400)
LanczosResize(720,400)
ConvertToYV12() # x264 only accepts YV12 colorspace
The first line loads your raw DV clip.
The next two lines are used to determine if your video is "top field first" (TFF) or "bottom field first" (BFF). Uncomment these lines and load the script into VirtualDub. If it plays smoothly it is BFF. If it stutters (moving objects jump back and forth) then it is TFF. When you are done make sure you comment these lines out again.
The next four lines select the parts of the clip that you want to include in your final output. You will need to view the raw DV clip in a video editor to determine the start and end frames of the ranges you want. I use VirtualDub for this. Uncomment "return last" and load the script into VirtualDub.
The next block of lines deinterlace the video (convert from interlaced to progressive). You need to uncomment the correct lines depending on whether your video is TFF or BFF (in this example the video was BFF).
The next block of lines resize the video so that the pixels are square in the final output. You need to know whether the source is fullscreen (FS) or widescreen (WS) to determine the output resolution (this example used widescreen video).
The last line converts the video to a colorspace that the x264 encoder can handle.
Now you need to create a batch file to encode (compress) the video. It should look something like this:
x264 -B 750 -f 0:0 -b 3 --b-pyramid -w -p 1 -r 1 -A none --me dia -m 1 --progress -o NUL filter.avs
x264 -B 750 -f 0:0 -b 3 --b-pyramid -w -p 2 -r 5 -A all --me umh -m 6 -8 --progress -o video.mp4 filter.avs
avs2wav filter.avs - | faac -o audio.mp4 -
mp4box -new -add audio.mp4 -add video.mp4 muxed.mp4
The first line does the first pass encoding of the video and the second line does the second pass. You might want to change the "-B 750" parameter. This sets the bitrate of the output (in kB/sec). The third line encodes the audio (around 100 KB/sec AAC). The fourth line multiplexes the audio and video streams into one MP4 file.
First you will need to collect and install the following tools:
AviSynth 2.5.6a
---------------
link: http://www.avisynth.org
EEDI2 v0.9
----------
compiled by: tritical
thread: http://forum.doom9.org/showthread.php?t=82264
link: http://bengal.missouri.edu/~kes25c/EEDI2v09.zip
TDeint v1.0 RC2
---------------
compiled by: tritical
thread: http://forum.doom9.org/showthread.php?t=82264
link: http://bengal.missouri.edu/~kes25c/TDeintv1RC2.zip
x264 CLI encoder v389
---------------------
compiled by: Sharktooth
thread: http://forum.doom9.org/showthread.php?t=89979
link: http://files.x264.nl/Sharktooth/force.php?file=./x264-Full_r389.exe
avs2wav v1.0
------------
compiled by: kassandro
thread: http://forum.doom9.org/showthread.php?t=70882
link: http://home.pages.at/kassandro/avs2wav.rar
FAAC v1.24.1
------------
thread: http://forum.doom9.org/showthread.php?t=68300
link: http://rarewares.org/aac.html
MP4Box v0.4.1-DEV
-----------------
compiled by: Celtic Druid
thread: http://forum.doom9.org/showthread.php?t=94874
link: http://www.aziendeassociate.it/cd.asp?dir=/gpac/dev
Haali Media Splitter
--------------------
thread: http://forum.doom9.org/showthread.php?t=89979
link: http://haali.cs.msu.ru/mkv/
ffdshow-20051129
----------------
compiled by: Milan
thread: http://forum.doom9.org/showthread.php?t=89979
link: http://ffdshow.sourceforge.net/tikiwiki/tiki-index.php?page=Getting+ffdshow
notes: when installing check only H.264,X264 video codec and AAC audio codec;
after installing go to the audio decoder configuration and select realaac
for the AAC decoder (libfaad2 results in garbled sound for me)
Next you need to create an AviSynth script. It should look something like this:
DirectShowSource("C:\Documents and Settings\Dan\My Documents\Adobe\Premiere Pro\1.5\distance.avi")
#AssumeBFF().SeparateFields() # use this to check if the video is BFF or TFF
#return last
mark = trim(849,1491)
jay1 = trim(3855,4481)
jay2 = trim(9331,10191)
last = mark + jay1 + jay2
# Deinterlace
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\EEDI2.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\TDeint.dll")
interp = separatefields().selecteven().EEDI2(field=0) # BFF
TDeint(order=0,field=0,edeint=interp) # BFF
#interp = separatefields().selecteven().EEDI2(field=1) # TFF
#tdeint(order=1,field=1,edeint=interp) # TFF
# Resize to square pixels
# FS source multiply horz by 10/11 (720x480 -> 656x480)
# WS source multiply vert by 33/40 (720x480 -> 720x400)
LanczosResize(720,400)
ConvertToYV12() # x264 only accepts YV12 colorspace
The first line loads your raw DV clip.
The next two lines are used to determine if your video is "top field first" (TFF) or "bottom field first" (BFF). Uncomment these lines and load the script into VirtualDub. If it plays smoothly it is BFF. If it stutters (moving objects jump back and forth) then it is TFF. When you are done make sure you comment these lines out again.
The next four lines select the parts of the clip that you want to include in your final output. You will need to view the raw DV clip in a video editor to determine the start and end frames of the ranges you want. I use VirtualDub for this. Uncomment "return last" and load the script into VirtualDub.
The next block of lines deinterlace the video (convert from interlaced to progressive). You need to uncomment the correct lines depending on whether your video is TFF or BFF (in this example the video was BFF).
The next block of lines resize the video so that the pixels are square in the final output. You need to know whether the source is fullscreen (FS) or widescreen (WS) to determine the output resolution (this example used widescreen video).
The last line converts the video to a colorspace that the x264 encoder can handle.
Now you need to create a batch file to encode (compress) the video. It should look something like this:
x264 -B 750 -f 0:0 -b 3 --b-pyramid -w -p 1 -r 1 -A none --me dia -m 1 --progress -o NUL filter.avs
x264 -B 750 -f 0:0 -b 3 --b-pyramid -w -p 2 -r 5 -A all --me umh -m 6 -8 --progress -o video.mp4 filter.avs
avs2wav filter.avs - | faac -o audio.mp4 -
mp4box -new -add audio.mp4 -add video.mp4 muxed.mp4
The first line does the first pass encoding of the video and the second line does the second pass. You might want to change the "-B 750" parameter. This sets the bitrate of the output (in kB/sec). The third line encodes the audio (around 100 KB/sec AAC). The fourth line multiplexes the audio and video streams into one MP4 file.