Converting Video Files for Editing

Discussion in 'Technology' started by Guardian Soul, Jan 5, 2012.

  1. Guardian Soul hella sad & hella rad

    Joined:
    Jul 26, 2007
    Gender:
    Male
    794
    I don't know if this should go here or in Video Projects. Feel free to move this, if any of you feel it is necessary, staffies.

    And let it be known that this guide is meant to be used in Windows. I don't have a Mac or a Linux partition installed onto my computer but I might look into the subject and try to find a guide that can help you guys.

    ___________________________________________________________________________________________________________________​


    Video footage can come in many shapes and sizes. There's MKV, MP4, OGM, MPG, AVI, WMV, and maybe even something else. The problem with all of these though, is that they probably aren't fit for editing because they aren't compressed with a codec that is suitable for editing. You see, video files compressed with a lossy codec like Xvid, Divx or any of their variants usually throw some data away when they're being compressed to make the filesize smaller. These codecs are ideal for the final render when everything is done and ready but horrible for editing because Vegas, or any other editing program for that matter, usually needs all of the data to edit properly or you'll get problems like blockiness or the video not appearing at all sometimes. Plus working with video files that are compressed with a lossy codec(DivX, Xvid, x264) and then rendering them out again with a lossy codec leads to more data lost which leads to a drop in video quality.

    To resolve this, it's best to re-compress the video file with a lossless codec, which as the name implies, means that after compressing the video, and then decompressing it, you wind up with the exact same data as you put in. The downside to using lossless compression is that the resulting file, while perfect for editing, is very huge in filesize, like in GB range >_>. If you have a lot of hard drive space or an external hard drive though, this shouldn't really be a problem though.

    For this guide, I’ll be using “.mkv” since at the moment, it’s become a standard among fansubbers(most of us get our anime for video editing from fansubbers) because the container has many more features than other containers and supports a wide variety of codec. Fortunately, no matter what type of file you have, we can handle it the same way.

    Now in order to convert our video files into editable .avi files, we are going to be using a few programs to convert them properly.

    The programs that you'll need for this guide are:

    The Community Combined Codec Package - The best codec pack that I know of. It supports most, if not all, of the video formats in use today. Before installing it though, make sure to uninstall previous codec packs that may have on your computer. Two codec packs can lead to conflicting codec problems which can lead to your video not being able to decompress and play properly.

    Avisynth - This program isn't your typical program because it doesn't work the same way that most programs do. You don't run an .exe and use some graphical interface to change settings or anything. Avisynth insteads work in the background. It's a program that makes video editing/playback software think that it is reading a video file when in reality the footage is being generated frame by frame to your design thanks to Avisynth. To make Avisynth do its thing, you'll need to make scripts. So it's more like programming than video editing at the moment. I know it sounds complicated, but trust me, it's not that hard.

    AvsPMod - For Avisynth to do its job, you're going to need to make script. Now you could easily make these scripts in Notepad if you wanted to but I suggest using AvsPMod since it was made for editing Avisynth files. It's a text editor specifically designed for making AviSynth scripts. It has a ton of great features like syntax highlighting, autocomplete, integrated video preview, a tabbed interface for easily comparing different scripts, and so many other features that I really can't even get into them all here. Even if you don't understand what all of that means, just rest assured, it makes creating AviSynth scripts VERY easy and fast.

    VirtualDub - This is a very handy tool for viewing and compressing AVI files.

    UTVideo - A lossless codec and the best option for losslessly compressing videos at the moment.


    Now most of us know that Sony Vegas doesn't support .mkv and neither do a lot of other video editing programs as well. So you'll have to convert the file into a format which Vegas does support. No worries, there won't be a drop in quality since we will be converting losslessly.

    The program that we will be using to convert our .mkv files is VirtualDub. But unforunately VirtualDub doesn't support the .mkv format as well. This is where Avisynth along with AVSPmod comes in. All you do is write a simple text file with some commands on it and you give this file to a Video Editing program(like VirtualDub for example) to read. When the Video Program looks at the file it doesn't see the commands you wrote, it sees video. The video the program sees is what you described in your simple file. AvsPmod will be helping you make these little scripts.

    I assume you already have Avisynth installed and AVSPMod extracted. I personally put my ASVPMod folder on my desktop for easier access. After installing Avisynth, open up AvsPmod and you should get what looks like a simple text editor. The first thing you're gonna do is make simple command:

    DirectShowSource("")
    [​IMG]


    Now this command won't do anything unless you put the path to the video file in between the parenthesis. Something like this:

    DirectShowSource("C:\Users\user\Desktop\Stuff\Footage\5 Centimeters Per Second\5 Centimeters Per Second.mkv")
    [​IMG]

    Just replace the line that I put down with the path of your video file. To find the path to the video, just open the folder that the video file is in and click on the address bar at the top of the window. Copy and paste that in between the parenthesis. Afterwards, you just need to put in the name of the video file. Make sure you put file format at the end of the file's name. I’m using an .mkv file so the script will end with ".mkv". But if your video file ends with .avi then you’ll add .avi to the end and the same applies with every other file format. To see if the script works, press F5 and you'll get a preview of the video.

    [​IMG]

    Now since the video is most likely HD, the resolution is gonna be 1280x720. If that's too big for you, you just have to use a simple command to lower the resolution to something more reasonable like 848x480(Standard Widescreen). In the end, I've always found it best to work with standard size since it makes the files smaller and they usually run faster. All you need to do is add an extra line to the script:

    DirectShowSource("C:\Users\user\Desktop\Stuff\Footage\5 Centimeters Per Second\5 Centimeters Per Second.mkv")
    Spline36Resize(848,480)

    [​IMG]

    Pressing F5 again will show you that the frame size has lowered. And that's it! All you have to do now is save the script by going to "File > Save script as...".

    Now it’s time to open up this script in VirtualDub. Open up VirtualDub and open the Avisynth script that you just made by going to File > Open Video File.

    [​IMG]

    Two video screens should open in the program and if you scrub the handle at the bottom, you can look through your video.

    [​IMG]

    If everything looks okay to you, go over to Video>Compression. Now there should be 4 versions of UTVideo in the window that just opened. You'll only be needing to use one which is UT Video Codec YUV420. By pressing Configure while having the codec that you want to encode with selected, you can choose whether to optimize the video that you're about to encode for decoding speed or compression. Choosing the former makes the video load faster in Vegas while choosing the latter makes the video have a slightly smaller filesize. Pick whichever works best for you. Press OK to get out of the compression window.

    [​IMG]

    After that you should go back to the Video tab on the toolbar, but this time, you'll just be clicking on Fast Recompress which will change how the program will compress the video. After that you can take out the audio if you want to. You can do that by going to Audio>No Audio. In the end, just go File>Save as Avi. Specify where you want to put the video and press Save. It should start compressing after that and the resulting file should work just fine in whatever video program you’re using.

    BUT GS, THE FILE IS TOO BIG D:<

    Well no worries, there is another way to compress the video file and it should work just fine in any video editing program. But there will be a slight decrease in quality but the in exchange, the file will be relatively smaller and to be honest, unless somebody goes through your video frame by frame and actively looks for the decrease in quality then it shouldn’t be noticeable.

    Now the only thing you have to do is change one step of the guide. And that is the codec that we selected in the Compression window. Instead of selecting UTVideo, you will be selecting ffdshow. If you installed the Community Combined Codec Pack then it should already be in the window to select. Click on Configure and to the top right, there will be a scrollbar with the word “Encoder” next to it. Click on that and select the option “MJPEG”. After selecting the option “MJPEG”, you just need to change “Quality” which should be right below the encoder. By default, it should be set to 100. I usually change the number to somewhere between the 85-90 range. The quality drop isn’t noticeable and the file size should be relatively smaller when compared to a compression made with UTVideo.

    [​IMG]

    Thanks for reading and If you have any problems or if there’s anything you want to be cleared up, feel free to ask. I’ll most likely be making revisions to this guide later on and add a few things that might be helpful.
     
  2. Daydreamer

    Joined:
    Jan 29, 2007
    Gender:
    Male
    Location:
    Los Angeles
    137
    You can do away with recompressing and giant video files by using "fake" or "dummy" AVIs.
    Frameserving to an application without native AVS support is possible using one of these utilities.

    Also, I can say that Avisynth and VirtualDub work flawlessly on Linux under Wine.
     
  3. Guardian Soul hella sad & hella rad

    Joined:
    Jul 26, 2007
    Gender:
    Male
    794
    Most of the time when I worked with fake AVIs in the past, I found that they worked rather slowly in comparison to working with the video file directly and they can also make Avisynth crash if you were to slow down something far too much or apply too many filters. I still work with them every now and then but I usually proceed with caution. But of course, that's only from my experience. I'm sure that somebody with more memory on their computer could frameserve with barely any troubles. I guess I could write up a part about frameserving for the next update of the guide.

    Thank you for the confirmation about Linux.