JPHiP Radio (19/200 @ 128 kbs)     Now playing: Tommy heavenly6 - Ruby Shoes

Author Topic: ~Dan~'s guide to encoding using Virtualdub  (Read 9363 times)

Offline ~Dan~

  • Happyyyy~~~
  • Member+
  • Posts: 2885
~Dan~'s guide to encoding using Virtualdub
« on: March 11, 2006, 12:58:00 AM »
I've been planning on doing this for a while, and since ebc did a guide for Gordian Knot I did one for Virtualdub.

TOOLS
VirtualdubMPG2
VirtualdubMOD
LAME mp3 codec (Rightclick on LameACM.inf and select "Install".  If it asks you for a disc, select the folder that you just unzipped.)
Subtitler filter for virtualdub (All you need to do is copy subtitler.vdf into the PLUGINS\ directory in the VirtualDub program directory)


First of all you need a version of Virtualdub.
I use plain Virtualdub for most things, and VirtualdubMPG2 for mpg2.
There's also VirtualdubMOD which has a different menu layout for it's audio streams so I try and stick with the first 2.

Virtualdub can handle most types of avi and mpg1.
VirtualdubMPG2 is the same but can also handle mpg2 and vob.
VirtualdubMOD can handle everything the first 2 can as well as the more weird filetypes like .mkv(matroska).
None of them will do wmv.  There's an older version of Virtualdub that people say will do wmv, but I've tried it and it doesn't.


It's also advisable to have the LAME mp3 codec if you're planning on encoding any mpg files, otherwise you can only use the crappy windows codec which will only allow a crappy 56kbps.


BASIC (RE-)ENCODING.

Open virtualdub, and open the file you wish to encode (file-open video file, and select the file).  A shortcut to using the file menu is simply to drag and drop the file onto Virtualdub.


VIDEO MENU

Make sure 'full processing mode' is selected, then select 'compression' and select your encoding type. I assume most people will want to encode to divX/xvid.  I use divX.  Xvid doesn't seem to have any noticeable benefits over divX and uses more processor power - not a problem to me now but with my old pc I was forever re-encoding xvid to divx so I could watch it and there's still people who's pc's struggle with xvid.



In mine, I choose "DivXR 6.0 Codec", other people may have it listed as 5.0 not 6.0. I also have an entry for "DivXR 6.0 YV12 Codec".  Don't choose that by mistake or you'll maybe find people don't have the codec to play it!
When you've selected that, click "configure" and then enter the bitrate.

CHOOSING A BITRATE

A performance would need a higher bitrate than something less lively like a talk.
A bitrate of 1200 would give you approx 10mb per minute, good enough for a talk.
A bitrate of 2400 would give you approx 20mb per minute and for a 3 min performance would give a file of around 60mb.
A bitrate of 3600 would give a file of around 90mb for a 3 min performance.
(bitrates based on the assumption that you're encoding at 640x480.  For higher/lower screen resolution you can raise/lower the bitrate accordingly.)

Choose your bitrate depending on the contents of the video.  To stay good quality anything with fast movements need a higher bitrate.  Something with less movement like a video with a fixed camera (like some of the flets or a dance shot pv) where the background doesnt move and so has less movement won't need such a high bitrate.)



AUDIO MENU

If you're re-encoding an avi you can select 'direct stream copy' and 'source audio' and you don't have to choose a bitrate.  This will use the original audio with no re-encoding.  This is fine for all avi's except for maybe something you capped yourself that might have wav audio which would need re-encoding.

For mpg files or avi's that need the audio re-encoding, select 'source' audio', 'full processing mode' and 'compression' to get to the compression menu.  Select Lame MP3.  If you don't have it then install it!

Select a bitrate.

For music I recommend 192kbps.  Actually you can use 192 for everything, but if you're trying to keep filesize down then you can use something lower for mainly speech-based or longer files, I'd recommend 128.  Using lower bitrates, for example 56kbps can sometimes result in the video getting out of sync.

In the picture you can see I've selected 192kbps.  You'll see that to the right it says 24KB/s.  When I was using win98 it would only display the KB/s and not the kbps.  If this happens for you then just remember that 24KB/s = 192, etc..., or refer to the pic.



At this stage, for a basic encode you can now select "save as avi" in the file menu and Virtualdub will start to re-encode your file.

Unticking 'show input video' and 'show output video' speeds things up a bit.  If it's using too much of your processor you can lower the priority.  Lowering it from 'normal' to the next lowest setting makes little or no difference to the time it takes to encode.

While you're encoding it'd a very good idea not to have winamp, media player, or any other audio/video players running.  Unless you have a very fast pc the progs might freeze.



HOWEVER, WAIT A MOMENT, before you save the file you probably might want to do other stuff first such as resize, crop, change the aspect ratio of an incorrectly encoded file, deinterlace, encode a video with subtitles or whatever, so before you save the file you'll want to add some filters... I'll deal with filters in the next post.
Sig gone. Tinypic is no more.

Offline ~Dan~

  • Happyyyy~~~
  • Member+
  • Posts: 2885
~Dan~'s guide to encoding using Virtualdub
« Reply #1 on: March 11, 2006, 12:58:35 AM »
FUN WITH FILTERS



I'll be dealing with 3 types of filter:

deinterlace
resize
subtitler

The order the filters appear is important.  They should appear in the order listed above, although you won't always need to use all of them - only use the filters you need!



Go into the filters section and click on 'add'.  Doubleclicking one of the filters in the list will select it.




DEINTERLACE FILTER

If you're encoding an mpg2 you need to get rid of the interlacing lines.  Select deinterlace.  Use the default (Blend Fields), and click ok.
Some avi files have interlacing too, although they're not as common.
If in doubt close the filters menu and have a look through the video using the 2 buttons with little yellow keys on them to move backwards and forwards through the video, and the forwards arrow on your keyboard to "play" through the video (don't press the back arrow to move backwards as it takes a long time for each frame for technical reasons.  Don't go mad clicking on those little icons or you'll queue up a lot of keypresses and jam up the program.)
I can't actually find an example of interlace lines so I borrowed an example from ebc's post, I hope he doesn't mind.  You're looking for interlace lines in parts of the video with some movement.  People sitting still and chatting won't have many interlace lines but a performance will have loads.



That's basically the sort of lines you want to get rid of.



RESIZE FILTER

This is the most useful one.  If you're re-encoding an mpg2 it'll probably be 720x480.  This is the wrong ratio so you'll need to resize it to 640x480.
Click 'add' then doubleclick 'resize'.



For width type 640, and width 480 (or whatever else you might want to resize to).  For filter mode select 'precise bilinear'.  Don't forget this part or your video will look crappy.  Click ok to finish.

You might be resizing a video to a smaller size, for example if someone on dialup requests a smaller file.  In this case you might be resizing it smaller.  When you do, make sure you don't use random numbers and mess up the aspect ratio.  I wouldn't recommend going as small as mpg1 size (320 x 240), try and meet somewhere in the middle, say 480x360.  For an example for a dialup sized version of Hello! Morning, something like 480x360, divx bitrate 600 would encode it to a little over 200mb with a quality similar to an mpg1.  It'd still be a 14-hour download on dialup though!


SUBTITLER FILTER

If you have a .ssa script and wish to encode the subtitles onto a video (known as 'hard subs') then select the subtitler filter and click the "..." button and find your subtitle file and select it, then click ok to finish.



You'll now have your 3 filters set, which will look something like this.



Remember you won't always be using all 3 filters, this is just an example.  Only use the ones you need!


Now, before you click 'OK' to exit the filters menu there's something else you might want to do.  Some videos, particularly those 720x480 mpg2's have little annoying black lies down the sides of the image.
To get rid of these, highlight the RESIZE filter and click 'cropping'



This will take you to the cropping part.  With a video that has the black lines you'll see something like this.



Notice the black lines down the sides.  Click the little X1/X2 offset buttons to crop the black lines.  If there's small black lines across the top and bottom crop those as well (don't do it to a widescreen vid though or it'll look very strange, although there is something you can do with a widescreen vid that I'll mention later).



When you've selected the cropping, click OK.  Removing the black lines will mean the video is stretched to full screen.  As long as the black lines are small as they usually are there won't be any noticeable difference to the aspect ratio, and it'll look tidier.  Another useful use of cropping is if a video is from and old videotape and has an annoying tracking line at the bottom - just crop the bottom few pixels.

Now you've set all the necessary filters you can save the video.  There's other filters for changing the brightness and stuff but I've not really looked into those.  You can have fun experimenting with them if you like.

--------------------------

If you have a video that's widescreen, but in a 640x480 ratio, you'll have black bars across the top and bottom of the picture.  You can resize to 640x360 and crop the unused parts off, for example...



...so you'd end up with a video that's 640x360 without wasting some space on encoding those black bars.  (The white bars in the Sexy Boy video look quite nice so don't use that one, I'm just using it as an example.)
Sig gone. Tinypic is no more.

Offline ~Dan~

  • Happyyyy~~~
  • Member+
  • Posts: 2885
~Dan~'s guide to encoding using Virtualdub
« Reply #2 on: March 11, 2006, 12:58:50 AM »
JOINING 2 OR MORE FILES TOGETHER

Open the first file as normal, then in the file menu select "append avi segment" and choose the next file.  You can add as many as you like.

THIS ONLY WORKS IF THE FILES ARE THE SAME BITRATE.  They probably won't be and it won't work.  The only solution is to encode each one first if you really want them as one file.

If you join too many files, the later part of the video will get more and more out of sync with each file you add, so it's not recommended you join too many files.

Loading 2 files together like this can be used in conjunction with the re-encoding stuff I mentioned earlier.



REPAIRING AN AVI THAT WON'T PLAY

Sometimes you'll have an avi that's damaged or won't play.  Open the file and select direct stream copy in the video menu and save it.  Direct stream copy streams the file and doesn't re-encode so there'll be no loss of quality.

In most cases this should repair the video.



I REPAIRED A VIDEO BUT IT'S NOT SEEKABLE

When you open the file, tick "popup extended open options"...



...open the file, and you get another menu...



...tick "re-derive keyframe flags" and click ok.  It'll take a while to rebuild the keyframes, but once it's done, select direct stream copy in the video menu and save the video.  It'll now be seekable.
Sig gone. Tinypic is no more.

Offline ~Dan~

  • Happyyyy~~~
  • Member+
  • Posts: 2885
~Dan~'s guide to encoding using Virtualdub
« Reply #3 on: March 11, 2006, 02:50:36 AM »
(reserved for other stuff)
Sig gone. Tinypic is no more.

JPHiP Radio (19/200 @ 128 kbs)     Now playing: Tommy heavenly6 - Ruby Shoes