Difference between revisions of "Avs"
From SDA Knowledge Base
Ballofsnow (Talk | contribs) m |
Ballofsnow (Talk | contribs) m (outline stuff) |
||
(15 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | __NOTOC__ | ||
[[AviSynth|quick link to old guide]] | [[AviSynth|quick link to old guide]] | ||
<br>[http://en.wikipedia.org/wiki/How_to_edit quick link to wiki editing] | <br>[http://en.wikipedia.org/wiki/How_to_edit quick link to wiki editing] | ||
− | |||
<br> | <br> | ||
− | |||
Line 15: | Line 14: | ||
<u>Ideas for guide</u> | <u>Ideas for guide</u> | ||
− | * No more follow-these-steps-blindly instructions this time | + | * No more follow-these-steps-blindly instructions this time. |
− | * Include more pictures. | + | * Include more pictures. Use thumbnails when necessary. |
− | + | ||
* At the start of each section, show a typical script in progress. | * At the start of each section, show a typical script in progress. | ||
* Include exercises with downloadable packages containing a video and a partial script. | * Include exercises with downloadable packages containing a video and a partial script. | ||
− | <b>Stuff to do:</ | + | <b>Stuff to do:</b> |
− | + | ||
− | + | <u>The script</u> | |
− | + | * Loading the source files - capture card | |
− | + | ||
− | * Loading the source files | + | |
− | + | ||
− | + | ||
* Appending | * Appending | ||
* Deinterlacing | * Deinterlacing | ||
Line 39: | Line 33: | ||
* SDA StatID | * SDA StatID | ||
* QuickTime compatibility | * QuickTime compatibility | ||
+ | |||
+ | <u>Extras</u> | ||
* Sample scripts | * Sample scripts | ||
* Script verification | * Script verification | ||
+ | |||
+ | <u>Fixes</u> | ||
+ | * Fixing Constant audio desync | ||
+ | * Fixing Progressive audio desync | ||
+ | |||
+ | |||
+ | |||
Line 47: | Line 50: | ||
#[[#workenvironment | Setting up your work environment]] | #[[#workenvironment | Setting up your work environment]] | ||
#[[#installation | Installation]] | #[[#installation | Installation]] | ||
+ | #[[#walkthrough | Walkthrough]] | ||
+ | #[[#loadsource | Loading the source files]] | ||
+ | #[[#deinterlacing | Deinterlacing]] | ||
Line 55: | Line 61: | ||
IMPORTANT NOTE: AviSynth scripting is an advanced topic. All beginners are recommended to use [[Anri-chan]] instead. | IMPORTANT NOTE: AviSynth scripting is an advanced topic. All beginners are recommended to use [[Anri-chan]] instead. | ||
− | + | [[Glossary of terms]] | |
Line 65: | Line 71: | ||
You'll very likely need to rename file extensions but they may be hidden by the operating system. | You'll very likely need to rename file extensions but they may be hidden by the operating system. | ||
# open Windows Explorer | # open Windows Explorer | ||
− | # open the <font color= | + | # open the <font color=lightblue>Tools</font> menu |
− | # select <font color= | + | # select <font color=lightblue>Folder Options</font> |
− | # select the <font color= | + | # select the <font color=lightblue>View</font> tab |
− | # choose to <font color= | + | # choose to <font color=lightblue>Show hidden files and folders</font> |
− | # uncheck <font color= | + | # uncheck <font color=lightblue>Hide extensions for known file types</font> |
# click OK to apply changes. | # click OK to apply changes. | ||
Line 76: | Line 82: | ||
+ | <br> | ||
<b>Association of avs file extension with text editor</b> | <b>Association of avs file extension with text editor</b> | ||
Now that you can see file extensions, let's associate the avs file extension with Notepad or other text editor of your choice. | Now that you can see file extensions, let's associate the avs file extension with Notepad or other text editor of your choice. | ||
# open Windows Explorer | # open Windows Explorer | ||
− | # open the <font color= | + | # open the <font color=lightblue>File</font> menu |
− | # select <font color= | + | # select <font color=lightblue>New</font> |
− | # select <font color= | + | # select <font color=lightblue>Text Document</font> |
− | # rename the new text file to <font color= | + | # rename the new text file to <font color=lightblue>New Text Document.avs</font>. It should show up as an unknown type. |
# open the avs file or right-click and select Open With. Windows will ask which program you want to use. | # open the avs file or right-click and select Open With. Windows will ask which program you want to use. | ||
− | # select <font color= | + | # select <font color=lightblue>Notepad</font> in the list |
− | # place a checkmark in the box that says <font color= | + | # place a checkmark in the box that says <font color=lightblue>Always use the selected program to open this kind of file</font> |
# click OK | # click OK | ||
Line 98: | Line 105: | ||
<b>Download and install a stable release version of [http://avisynth.org/ AviSynth]</b><br> | <b>Download and install a stable release version of [http://avisynth.org/ AviSynth]</b><br> | ||
* [http://sourceforge.net/project/showfiles.php?group_id=57023 AviSynth download page] | * [http://sourceforge.net/project/showfiles.php?group_id=57023 AviSynth download page] | ||
− | <font color= | + | <font color=lightgreen>The picture below identifes a stable release.</font><br> |
[[Image:AviSynth_download.png]] | [[Image:AviSynth_download.png]] | ||
+ | <br> | ||
<b>Download and install necessary AviSynth plugins</b> | <b>Download and install necessary AviSynth plugins</b> | ||
* [[Media:avisynthplugins.zip|SDA plugins]]. | * [[Media:avisynthplugins.zip|SDA plugins]]. | ||
Line 111: | Line 119: | ||
# Copy the files from inside the AviSynth plugins zip file to the Avisynth plugins directory window you just opened. | # Copy the files from inside the AviSynth plugins zip file to the Avisynth plugins directory window you just opened. | ||
− | <font color= | + | <font color=lightgreen>The plugins directory should look similar to what's shown in the picture. AviSynth will automatically load dll and avsi files.</font><br> |
[[Image:AviSynth_pluginsdir.png]] | [[Image:AviSynth_pluginsdir.png]] | ||
+ | <br> | ||
+ | <font color=red><b>Special instructions for those working with DVD sources</b></font><br> | ||
+ | If you followed the instructions on the [[DVD#DVD_software_installation |DVD page]] properly you should already have DGMPGDec installed. You need to copy a dll file from this directory to the AviSynth plugins directory in order for AviSynth to be able to load DVD video. | ||
+ | # navigate to the DGMPGDec directory. Should be <font color=lightblue>C:\Program Files\DGMPGDec</font> | ||
+ | # copy <font color=lightblue>DGDecode.dll</font> to the AviSynth plugins directory. | ||
+ | |||
+ | |||
+ | <br> | ||
<b>Download and install [http://www.virtualdub.org/ VirtualDub]</b><br> | <b>Download and install [http://www.virtualdub.org/ VirtualDub]</b><br> | ||
* [http://www.virtualdub.org/download.html VitualDub download page] | * [http://www.virtualdub.org/download.html VitualDub download page] | ||
Line 121: | Line 137: | ||
+ | <br> | ||
<b>Verify that everything is installed properly</b><br> | <b>Verify that everything is installed properly</b><br> | ||
Line 129: | Line 146: | ||
<!-- <font color=red>Move to a troubleshooting section?</font> - If AviSynth complains that the MSVCR71.dll file is missing, you can download it at http://www.dll-files.com/. Place it in your "C:\WINDOWS\SYSTEM32\" directory. | <!-- <font color=red>Move to a troubleshooting section?</font> - If AviSynth complains that the MSVCR71.dll file is missing, you can download it at http://www.dll-files.com/. Place it in your "C:\WINDOWS\SYSTEM32\" directory. | ||
<br> --> | <br> --> | ||
+ | |||
+ | |||
+ | |||
+ | <br> | ||
+ | <div id="walkthrough" style="background:#198d3a;width:100%;"><font size="+1" color="#FFFFFF"> Walkthrough of a typical AviSynth script</font></div> | ||
+ | |||
+ | Before starting your own script you should have an idea of how AviSynth operates. The following script is typical for DVD video. AviSynth will execute each line of code sequentially; in this walkthrough you will see what the video looks like after each step. | ||
+ | |||
+ | <pre><nowiki> | ||
+ | Ac3Source(MPEG2source("VTS_01_1.d2v", upconv=1),"VTS_01_1 T80 2_0ch 192Kbps DELAY 0ms.ac3") | ||
+ | mvbob() | ||
+ | trim(13801,13900) | ||
+ | Lanczos4Resize(640,480) | ||
+ | </nowiki></pre> | ||
+ | |||
+ | |||
+ | <b>A glance at the work folder</b> | ||
+ | |||
+ | As you can see, the VOB has already been processed by DGIndex generating the files: | ||
+ | * VTS_01_1.d2v | ||
+ | * VTS_01_1 T80 2_0ch 192Kbps DELAY 0ms.ac3 | ||
+ | |||
+ | [[Image:AviSynth_walkthrough_workfolder.png]] | ||
+ | |||
+ | |||
+ | <b>Load audio/video</b> | ||
+ | |||
+ | I open my_AviSynth_script.avs in Notepad and add the line below to load the Ac3 audio and MPEG2 video. VirtualDub shows that both have loaded succesfully. | ||
+ | |||
+ | <font color=orange>Ac3Source(</font><font color=magenta>MPEG2source("VTS_01_1.d2v", upconv=1)</font><font color=orange>,"VTS_01_1 T80 2_0ch 192Kbps DELAY 0ms.ac3")</font> | ||
+ | |||
+ | [[Image:AviSynth_walkthrough_loadsource.png]] | ||
+ | |||
+ | |||
+ | <b>Deinterlace</b> | ||
+ | |||
+ | I've identified that the video is D1 F1 3D (will go into this later) so the appropriate deinterlacing method is mvbob. Notice how the number of frames has doubled from approximately 10000 frames to 20000. | ||
+ | |||
+ | <font color=orange>mvbob()</font> | ||
+ | |||
+ | [[Image:AviSynth_walkthrough_deinterlace.png]] | ||
+ | |||
+ | |||
+ | <b>Trimming the fat</b> | ||
+ | |||
+ | I've decided, for the sake of this walkthrough, to <u>keep</u> only 20 frames. | ||
+ | |||
+ | <font color=orange>trim(17451,17470)</font> | ||
+ | |||
+ | [[Image:AviSynth_walkthrough_trim.png]] | ||
+ | |||
+ | |||
+ | <b>Resize</b> | ||
+ | |||
+ | My NTSC DVD has a resolution of 720x480. I need to resize to 640x480 resolution so that the aspect ratio is correct and everything doesn't look so wide. | ||
+ | |||
+ | <font color=orange>Lanczos4Resize(640,480)</font> | ||
+ | |||
+ | [[Image:AviSynth_walkthrough_resize.png]] | ||
+ | |||
+ | |||
+ | There are more commands you will use in your script, but the above are the essentials. | ||
+ | |||
+ | |||
+ | <br> | ||
+ | <div id="loadsource" style="background:#194BA2;width:100%;"><font size="+1" color="#FFFFFF"> Loading the source files</font></div> | ||
+ | |||
+ | Let's start with a new AviSynth script. Remember when you created an avs text file back in [[#workenvironment | Setting up your work environment]]? That's all an AviSynth script really is, a text file with an avs file extension. We'll create the High Quality script first and move on to the other SDA qualities later. Open mygame_HQ.avs in Notepad. | ||
+ | |||
+ | # open Windows Explorer | ||
+ | # open the <font color=lightblue>File</font> menu | ||
+ | # select <font color=lightblue>New</font> | ||
+ | # select <font color=lightblue>Text Document</font> | ||
+ | # rename the new text file to <font color=lightblue>mygame_HQ.avs</font>. | ||
+ | |||
+ | |||
+ | This chapter will diverge into three sections. Depending on how you recorded your video, follow the appropriate link. | ||
+ | |||
+ | * [[#PC game recorded with Fraps / Camtasia / other screen capture software | PC game recorded with Fraps / Camtasia / other screen capture software]] | ||
+ | * [[#Console game recorded with DVD recorder / capture card using DVD settings | Console game recorded with DVD recorder / capture card using DVD settings]] | ||
+ | * [[#Console game recorded with capture card to AVI file | Console game recorded with capture card to AVI file]] | ||
+ | |||
+ | |||
+ | ==PC game recorded with Fraps / Camtasia / other screen capture software== | ||
+ | |||
+ | Screen capture software typically creates an AVI file containing both video and audio. All we need is the <b>AviSource()</b> command with your AVI file as the argument. | ||
+ | |||
+ | <pre><nowiki> | ||
+ | avisource("clip1.avi") | ||
+ | </nowiki></pre> | ||
+ | |||
+ | |||
+ | Simple, isn't it? What if you have more than one file and want to append them together, as is usually the case when recording for longer periods of time? Let's bring in the <b>AlignedSplice()</b> command with AviSource as the arguments. | ||
+ | |||
+ | <pre><nowiki> | ||
+ | a = avisource("clip1.avi") | ||
+ | b = avisource("clip2.avi") | ||
+ | namedoesntmatter = avisource("clip3.avi") | ||
+ | |||
+ | AlignedSplice(a,b,namedoesntmatter) | ||
+ | </nowiki></pre> | ||
+ | |||
+ | |||
+ | <font color=lightgreen>An example of three videos that were split by Fraps being joined together in AviSynth.</font> | ||
+ | [[Image:AviSynth_loadsource_pcgame.png]] | ||
+ | |||
+ | |||
+ | <br> | ||
+ | ==Console game recorded with DVD recorder / capture card using DVD settings== | ||
+ | |||
+ | There are three main types of audio when working from a DVD source: AC3, MPA and sometimes even PCM (wav). When you indexed the VOB files with DGIndex as per the [[DVD#Creating_the_project_file_.28.d2v.29 | DVD guide]] it should have created the d2v file and an audio file. Notice how the d2v file is only 19 KB in size since it only contains data <i>about</i> the VOB MPEG2 video stream; you still need that VOB file! | ||
+ | |||
+ | |||
+ | <font color=lightgreen>The picture below shows that an AC3 audio file was extracted with an audio desync of 78 milliseconds.</font> | ||
+ | [[Image:AviSynth_loadsource_DVDdir.png]] | ||
+ | |||
+ | |||
+ | Here are the different ways to load AC3 / MPA / PCM (WAV). The first example would work with the files in the picture above. | ||
+ | |||
+ | |||
+ | <b>AC3 with a -78 ms desync.</b> | ||
+ | <pre><nowiki> | ||
+ | Ac3Source(MPEG2source("VTS_01_1.d2v", upconv=1),"VTS_01_1 T80 2_0ch 192Kbps DELAY -78ms.ac3").DelayAudio(-0.078) | ||
+ | </nowiki></pre> | ||
+ | |||
+ | <b>MPA with a +46 ms desync.</b> | ||
+ | <pre><nowiki> | ||
+ | AudioDub(MPEG2source("VTS_01_1.d2v", upconv=1),MPASource("vob T01 2_0ch 192Kbps DELAY 46ms.mpa")).DelayAudio(0.046) | ||
+ | </nowiki></pre> | ||
+ | |||
+ | <b>PCM with no desync.</b> | ||
+ | <pre><nowiki> | ||
+ | AudioDub(MPEG2source("VTS_01_1.d2v", upconv=1),WAVSource("vob T01 2_0ch 192Kbps DELAY 0ms.wav")) | ||
+ | </nowiki></pre> | ||
+ | |||
+ | |||
+ | <font color=lightgreen>DVD MPEG2 in all its interlaced glory...</font> | ||
+ | [[Image:AviSynth_loadsource_DVD.png]] | ||
+ | |||
+ | <br> | ||
+ | ==Console game recorded with capture card to AVI file== | ||
+ | |||
+ | <font color=red>Write me!</font> | ||
+ | |||
+ | |||
+ | |||
+ | <br> | ||
+ | <div id="deinterlacing" style="background:#194BA2;width:100%;"><font size="+1" color="#FFFFFF"> Deinterlacing</font></div> | ||
+ | |||
+ | <b>Outline</b> | ||
+ | * Intro, with image of interlaced / deinterlaced frame. | ||
+ | * What is an interlaced frame? | ||
+ | * Make new image with concept of the [[AviSynth#What_is_deinterlacing.3F | ABCD ]] split but say "Field 1", "Field 2", etc. | ||
+ | * Above idea but actual game footage screens (thumbnail link to massive 3600 width pic) | ||
+ | * Go through each method of deinterlacing for all the qualities. Show images!!! | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | If you recorded a PC game with screen capture software such as Fraps or Camtasia, there is a 99.9% chance that your video does not need to be deinterlaced and you can skip this entire section. For just about everyone else, your video probably needs to be deinterlaced. | ||
+ | |||
+ | <font color=lightgreen>The animated picture below shows the difference between interlaced and progressive/deinterlaced.</font> | ||
+ | |||
+ | [[Image:AviSynth_deinterlacing_ipanim.gif]] | ||
+ | |||
+ | |||
+ | ===What is an interlaced frame?=== | ||
+ | |||
+ | An interlaced frame has two fields. Think of it as a single frame with two smaller frames inside. Those two fields (the smaller frames) represent two different moments in time. Take the picture as an example, with four different fields numbered 1 to 4: | ||
+ | |||
+ | [[Image:AviSynth_deinterlacing_fields1234_i.png]] | ||
+ | |||
+ | |||
+ | The fields have been separated. | ||
+ | |||
+ | [[Image:AviSynth_deinterlacing_fields1234_i2.png]] | ||
+ | |||
+ | |||
+ | Demonstrating how the top field (fields 1 and 3) is on even numbered lines, while the bottom field (fields 2,4) is on odd numbered lines. | ||
+ | |||
+ | [[Image:AviSynth_deinterlacing_fields1234_izoom.png]] | ||
+ | |||
+ | |||
+ | The sequence of frames is now deinterlaced and is progressive. | ||
+ | |||
+ | [[Image:AviSynth_deinterlacing_fields1234_p.png]] | ||
+ | |||
+ | |||
+ | |||
+ | Here is an example from a game. | ||
+ | |||
+ | (a more complete version is available: [[Media:AviSynth_deinterlacing_fields_game.jpg | jpg, 1.18 MB]] / [[Media:AviSynth_deinterlacing_fields_game.png | png, 5.75 MB]] - 3600×2047) | ||
+ | |||
+ | [[Image:AviSynth_deinterlacing_fields_game_thumb.jpg]] | ||
+ | |||
+ | |||
+ | You'll notice that the height has been cut in half and Dante looks too short (or too wide). Not to worry, we'll be fixing that later on. | ||
+ | |||
+ | |||
+ | ===Determining the framerate of the game=== | ||
+ | |||
+ | Right now your AviSynth script is one measly line of code, e.g.: | ||
+ | <pre><nowiki> | ||
+ | Ac3Source(MPEG2source("segment1.d2v",upConv=1),"segment1 192Kbps DELAY -48ms.ac3").DelayAudio(-0.048) | ||
+ | </nowiki></pre> | ||
+ | |||
+ | I'm going to <i>temporarily</i> add <b>SeparateFields</b> at the end of the script solely for the purpose of determining the framerate of the game. This will do exactly what is shown in the previous section "What is an interlaced frame?". | ||
+ | <pre><nowiki> | ||
+ | Ac3Source(MPEG2source("segment1.d2v",upConv=1),"segment1 192Kbps DELAY -48ms.ac3").DelayAudio(-0.048) | ||
+ | SeparateFields | ||
+ | </nowiki></pre> | ||
+ | |||
+ | The script is saved and loaded into VirtualDub(Mod). The amount of frames and the framerate have both doubled. | ||
+ | |||
+ | [[Image:AviSynth_deinterlacing_framerate_loadvdub.png]] | ||
+ | |||
+ | |||
+ | |||
+ | <b>Example of a game that runs at half framerate or 29.97 frames per second</b> | ||
+ | |||
+ | [[Image:F2_animation.gif]] | ||
+ | |||
+ | |||
+ | |||
+ | <b>Example of a game that runs at full framerate or 59.94 frames per second</b> | ||
+ | |||
+ | <font color=red>to do</font> | ||
+ | |||
+ | |||
+ | <b>Example of a game that runs at one third framerate or 19.98 frames per second</b> | ||
+ | |||
+ | <font color=red>to do</font> | ||
+ | |||
+ | |||
+ | ===Determining if the video is top or bottom field first=== | ||
+ | |||
+ | <font color=red>to do</font> | ||
+ | |||
+ | |||
+ | ===Determining the resolution of the game=== | ||
+ | |||
+ | This section requires a bit of your own research. Wikipedia is a good place to start. Older consoles like the NES and Sega Genesis can only output in low resolution, however the SNES, N64 and PS1 are capable of high resolution. From the PS2 and onwards, high resolution for games is more probable. | ||
+ | |||
+ | You may find your game in our [[DF | list of dimensions and framerates]]. | ||
+ | |||
+ | |||
+ | ===Deinterlacing scenarios=== | ||
+ | |||
+ | <font color=red>to do</font> | ||
+ | |||
+ | |||
+ | ====Scenario 1: D1 F1==== | ||
+ | |||
+ | <font color=red>to do</font> | ||
+ | |||
+ | |||
+ | ====Scenario 2: D1 F2==== | ||
+ | |||
+ | <font color=red>to do</font> | ||
+ | |||
+ | |||
+ | ====Scenario 3: D1 F3==== | ||
+ | |||
+ | <font color=red>to do</font> | ||
+ | |||
+ | |||
+ | ====Scenario 4: D4 F1==== | ||
+ | |||
+ | <font color=red>to do</font> | ||
+ | |||
+ | |||
+ | ====Scenario 5: D4 F2==== | ||
+ | |||
+ | <font color=red>to do</font> | ||
+ | |||
+ | |||
+ | ====Scenario 6: D4 F3==== | ||
+ | |||
+ | <font color=red>to do</font> | ||
+ | |||
+ | [http://speeddemosarchive.com/forum/index.php/topic,9956.15.html use decimate() from f2 for d4 f3] | ||
+ | |||
+ | |||
+ | ====Scenario 7: One pixel bob==== | ||
+ | |||
+ | <font color=red>to do</font> | ||
+ | |||
+ | |||
+ | ====Scenario 8: Quarter pixel bob==== | ||
+ | |||
+ | <font color=red>to do</font> |
Latest revision as of 12:36, 19 September 2009
quick link to old guide
quick link to wiki editing
Snow's new AviSynth guide. Yeah, I hope I actually finish this.
Ideas for layout
- Custom table of contents, not so linear.
- Use PNG! Lossless is cool.
- Color headings.
Ideas for guide
- No more follow-these-steps-blindly instructions this time.
- Include more pictures. Use thumbnails when necessary.
- At the start of each section, show a typical script in progress.
- Include exercises with downloadable packages containing a video and a partial script.
Stuff to do:
The script
- Loading the source files - capture card
- Appending
- Deinterlacing
- Trimming
- Resizing
- Sharpening
- Cropping / Adding borders
- Color / Brightness
- SDA StatID
- QuickTime compatibility
Extras
- Sample scripts
- Script verification
Fixes
- Fixing Constant audio desync
- Fixing Progressive audio desync
Table of contents:
- Introduction
- Setting up your work environment
- Installation
- Walkthrough
- Loading the source files
- Deinterlacing
IMPORTANT NOTE: AviSynth scripting is an advanced topic. All beginners are recommended to use Anri-chan instead.
File extensions
You'll very likely need to rename file extensions but they may be hidden by the operating system.
- open Windows Explorer
- open the Tools menu
- select Folder Options
- select the View tab
- choose to Show hidden files and folders
- uncheck Hide extensions for known file types
- click OK to apply changes.
Association of avs file extension with text editor
Now that you can see file extensions, let's associate the avs file extension with Notepad or other text editor of your choice.
- open Windows Explorer
- open the File menu
- select New
- select Text Document
- rename the new text file to New Text Document.avs. It should show up as an unknown type.
- open the avs file or right-click and select Open With. Windows will ask which program you want to use.
- select Notepad in the list
- place a checkmark in the box that says Always use the selected program to open this kind of file
- click OK
Download and install a stable release version of AviSynth
The picture below identifes a stable release.
Download and install necessary AviSynth plugins
- Go to Start menu
- [All] Programs
- AviSynth
- Plugin Directory. (This is where AviSynth stores its plugins.)
- Copy the files from inside the AviSynth plugins zip file to the Avisynth plugins directory window you just opened.
The plugins directory should look similar to what's shown in the picture. AviSynth will automatically load dll and avsi files.
Special instructions for those working with DVD sources
If you followed the instructions on the DVD page properly you should already have DGMPGDec installed. You need to copy a dll file from this directory to the AviSynth plugins directory in order for AviSynth to be able to load DVD video.
- navigate to the DGMPGDec directory. Should be C:\Program Files\DGMPGDec
- copy DGDecode.dll to the AviSynth plugins directory.
Download and install VirtualDub
This program will be useful for testing your script as you go along.
Verify that everything is installed properly
Download the following package and unzip the contents anywhere you'd like. Run VirtualDub and drag and drop the avs file into the window. You should see a frame that says "So far so good..".
Before starting your own script you should have an idea of how AviSynth operates. The following script is typical for DVD video. AviSynth will execute each line of code sequentially; in this walkthrough you will see what the video looks like after each step.
Ac3Source(MPEG2source("VTS_01_1.d2v", upconv=1),"VTS_01_1 T80 2_0ch 192Kbps DELAY 0ms.ac3") mvbob() trim(13801,13900) Lanczos4Resize(640,480)
A glance at the work folder
As you can see, the VOB has already been processed by DGIndex generating the files:
- VTS_01_1.d2v
- VTS_01_1 T80 2_0ch 192Kbps DELAY 0ms.ac3
Load audio/video
I open my_AviSynth_script.avs in Notepad and add the line below to load the Ac3 audio and MPEG2 video. VirtualDub shows that both have loaded succesfully.
Ac3Source(MPEG2source("VTS_01_1.d2v", upconv=1),"VTS_01_1 T80 2_0ch 192Kbps DELAY 0ms.ac3")
Deinterlace
I've identified that the video is D1 F1 3D (will go into this later) so the appropriate deinterlacing method is mvbob. Notice how the number of frames has doubled from approximately 10000 frames to 20000.
mvbob()
Trimming the fat
I've decided, for the sake of this walkthrough, to keep only 20 frames.
trim(17451,17470)
Resize
My NTSC DVD has a resolution of 720x480. I need to resize to 640x480 resolution so that the aspect ratio is correct and everything doesn't look so wide.
Lanczos4Resize(640,480)
There are more commands you will use in your script, but the above are the essentials.
Let's start with a new AviSynth script. Remember when you created an avs text file back in Setting up your work environment? That's all an AviSynth script really is, a text file with an avs file extension. We'll create the High Quality script first and move on to the other SDA qualities later. Open mygame_HQ.avs in Notepad.
- open Windows Explorer
- open the File menu
- select New
- select Text Document
- rename the new text file to mygame_HQ.avs.
This chapter will diverge into three sections. Depending on how you recorded your video, follow the appropriate link.
- PC game recorded with Fraps / Camtasia / other screen capture software
- Console game recorded with DVD recorder / capture card using DVD settings
- Console game recorded with capture card to AVI file
PC game recorded with Fraps / Camtasia / other screen capture software
Screen capture software typically creates an AVI file containing both video and audio. All we need is the AviSource() command with your AVI file as the argument.
avisource("clip1.avi")
Simple, isn't it? What if you have more than one file and want to append them together, as is usually the case when recording for longer periods of time? Let's bring in the AlignedSplice() command with AviSource as the arguments.
a = avisource("clip1.avi") b = avisource("clip2.avi") namedoesntmatter = avisource("clip3.avi") AlignedSplice(a,b,namedoesntmatter)
An example of three videos that were split by Fraps being joined together in AviSynth.
Console game recorded with DVD recorder / capture card using DVD settings
There are three main types of audio when working from a DVD source: AC3, MPA and sometimes even PCM (wav). When you indexed the VOB files with DGIndex as per the DVD guide it should have created the d2v file and an audio file. Notice how the d2v file is only 19 KB in size since it only contains data about the VOB MPEG2 video stream; you still need that VOB file!
The picture below shows that an AC3 audio file was extracted with an audio desync of 78 milliseconds.
Here are the different ways to load AC3 / MPA / PCM (WAV). The first example would work with the files in the picture above.
AC3 with a -78 ms desync.
Ac3Source(MPEG2source("VTS_01_1.d2v", upconv=1),"VTS_01_1 T80 2_0ch 192Kbps DELAY -78ms.ac3").DelayAudio(-0.078)
MPA with a +46 ms desync.
AudioDub(MPEG2source("VTS_01_1.d2v", upconv=1),MPASource("vob T01 2_0ch 192Kbps DELAY 46ms.mpa")).DelayAudio(0.046)
PCM with no desync.
AudioDub(MPEG2source("VTS_01_1.d2v", upconv=1),WAVSource("vob T01 2_0ch 192Kbps DELAY 0ms.wav"))
DVD MPEG2 in all its interlaced glory...
Console game recorded with capture card to AVI file
Write me!
Outline
- Intro, with image of interlaced / deinterlaced frame.
- What is an interlaced frame?
- Make new image with concept of the ABCD split but say "Field 1", "Field 2", etc.
- Above idea but actual game footage screens (thumbnail link to massive 3600 width pic)
- Go through each method of deinterlacing for all the qualities. Show images!!!
If you recorded a PC game with screen capture software such as Fraps or Camtasia, there is a 99.9% chance that your video does not need to be deinterlaced and you can skip this entire section. For just about everyone else, your video probably needs to be deinterlaced.
The animated picture below shows the difference between interlaced and progressive/deinterlaced.
What is an interlaced frame?
An interlaced frame has two fields. Think of it as a single frame with two smaller frames inside. Those two fields (the smaller frames) represent two different moments in time. Take the picture as an example, with four different fields numbered 1 to 4:
The fields have been separated.
Demonstrating how the top field (fields 1 and 3) is on even numbered lines, while the bottom field (fields 2,4) is on odd numbered lines.
The sequence of frames is now deinterlaced and is progressive.
Here is an example from a game.
(a more complete version is available: jpg, 1.18 MB / png, 5.75 MB - 3600×2047)
You'll notice that the height has been cut in half and Dante looks too short (or too wide). Not to worry, we'll be fixing that later on.
Determining the framerate of the game
Right now your AviSynth script is one measly line of code, e.g.:
Ac3Source(MPEG2source("segment1.d2v",upConv=1),"segment1 192Kbps DELAY -48ms.ac3").DelayAudio(-0.048)
I'm going to temporarily add SeparateFields at the end of the script solely for the purpose of determining the framerate of the game. This will do exactly what is shown in the previous section "What is an interlaced frame?".
Ac3Source(MPEG2source("segment1.d2v",upConv=1),"segment1 192Kbps DELAY -48ms.ac3").DelayAudio(-0.048) SeparateFields
The script is saved and loaded into VirtualDub(Mod). The amount of frames and the framerate have both doubled.
Example of a game that runs at half framerate or 29.97 frames per second
Example of a game that runs at full framerate or 59.94 frames per second
to do
Example of a game that runs at one third framerate or 19.98 frames per second
to do
Determining if the video is top or bottom field first
to do
Determining the resolution of the game
This section requires a bit of your own research. Wikipedia is a good place to start. Older consoles like the NES and Sega Genesis can only output in low resolution, however the SNES, N64 and PS1 are capable of high resolution. From the PS2 and onwards, high resolution for games is more probable.
You may find your game in our list of dimensions and framerates.
Deinterlacing scenarios
to do
Scenario 1: D1 F1
to do
Scenario 2: D1 F2
to do
Scenario 3: D1 F3
to do
Scenario 4: D4 F1
to do
Scenario 5: D4 F2
to do
Scenario 6: D4 F3
to do
use decimate() from f2 for d4 f3
Scenario 7: One pixel bob
to do
Scenario 8: Quarter pixel bob
to do