Video Encoding, Other Formats


Table of Contents

Converting AVIs to (S)VCDs using avidemux 
Discuss this article 
Converting AVIs to (S)VCDs using lav2mpeg 
Basic Info 
Help 
Trying History 

Converting AVIs to (S)VCDs using avidemux 

http://www.linuxquestions.org/questions/answers/262

Posted by: JoeDuncan on 09-04-2004.

First of all you will need the following tools:

avidemux http://fixounet.free.fr/avidemux/ which is the VirtualDub equivalent in Linux mjpegtools http://mjpeg.sourceforge.net/ which will actually split the files for you (it splits mpegs… but I'm getting ahead of myself…) vcdimager http://www.gnu.org/software/vcdimager/vcdimager.html which will prepare the VCD/SVCD images for you and last but not least: cdrdao http://cdrdao.sourceforge.net/ which will actually burn the CDs.

I have used this setup for awhile and it works beautifully for me. All of these pieces of software should be available as a binary package for your distribution.

Ok, the first thing you have to know is that (S)VCDs are MPEGs, not AVIs, so you have to convert from AVI to MPEG. This is where Avidemux comes in. You use it to save the audio and video into different streams (demultiplex) of the proper format to merge (multiplex) back in to an MPEG.

So, open Avidemux (I use version 2.0.24 so yours may be a bit different) and load your avi file (File->Open or the "Open" button on the toolbar).

Then click on the "Video Filter" button on the left.

In the "Video Filters" box, select either "SVCD res" or "VCD res" depending on which one you are going to make (I have found that a 700 mb avi splits almost evenly across 2 SVCDs).

Then click close.

Now click on the "Video Codex" button on the left toolbar. Select either "SVCD" or "VCD" for your codec and click "OK"

Then click on the "Video Process" button, this will tell Avidemux to only process the video.

Now click on "File->Save->Save Video" and enter "filename.m1v" for the file name to save as. Now sit back and wait, as this usually takes 2-3 hours on my P3 1.4 GHz machine (your mileage may vary - I usually do this part overnight)…

Ok, that takes care of splitting off (demultiplexing) the video. Now for the audio…

The first thing you want to do is to click on the "Info" button on the toolbar and then select the "audio" tab in the info box. If it says "variable" or "VBR" in there anywhere, then your AVI file is using variable bit rate audio, and you will need to build a timemap or you will have audio sync problems.. but don't worry, building a time map is easy, just select "Audio->Build VBR Time map". That will usually take about 10 minutes… Also take a note of the frequency of the audio.

Next, click on "Audio Filter" in the left toolbar. Select "Normalize" (to adjust the volume to a standard level) and then either no resampling, "44.1 to 48 kHz resampling" (usually this one as most AVIs are in 48000 hz frequency, or if your audio is already in 44100 or 48000hz frequency, enter "44100" in the "Resample to hz" box. Then click OK.

Ok, now click on "Audio Codec" on the left toolbar.

Select "FFmpeg mpeg audio" as your codec and then click "Configure"

Select a bit rate of 224kbits/second and stereo sound and click OK twice.

Now, click "Audio Process" on the left toolbar (to tell Avidemux to only process audio).

Then select "Audio->Save Audio" and enter "filename.mp2" as your audio stream file name and click ok. This will approx 30 minutes (again on my P3 1.4 GHz…)

Ok, now we have split our file we need to recreate the video as an mpeg. Close Avidemux and open up a console.

In the console (make sure you are in the right directory) type this:

mplex -S 790 -f 4 -o filename.mpg filename.m1v filename.mp2

What this says is to remultiplex your two streams into filetype 4 (-f 4) which is SVCD, with output file (-o) called "filename.mpg". The "-S 790" tells it to split the created MPEG into files that will each fit on a CD. (-S means size, although I'm not sure what the units are, it's not megabytes, but 790 fits perfectly onto one standard blank CD). IIRC it adds a "1" or "2" or "3" after the filename if it has to split them…

(-f 1 will tell it to make VCDs)

This should only take about 5 minutes.

Now, once you have your completed MPEGs, test them with your favorite video viewer. All should be well. If the audio is slightly out of sync, this can be corrected by deleting the audio track and recreating it with Avidemux, but using the "Time shift" filter option to shift the audio X milliseconds, then remultiplexing.

Ok, now you have your MPEG videos, you need to burn them to CD. So create the (S)VCD image like so (you will have to do them one at a time if your file has been split):

vcdimager -t svcd filename.mpg

This will create a file called "videocd.cue" which is the (S)VCD image. (Use "-t vcd20" to create VCDs).

Then you can burn your image like so:

cdrdao write --device /dev/scd0 videocd.cue

Now your SCSI dev file for your burner may be different, just sub yours in. Also, you may need to make your regular user part of your distros "CDRW" (or equivalent) user group in order to access the writer properly.

That should do it. Also, note that Avidemux can be called entirely from the command line (see their website for the appropriate switches for all the functions mentioned above) which should allow you to create a completely automated script to do all of this for you.

Avidemux is an awesome tool, it will also let you edit the AVIs themselves (remove bad frames, append videos etc…)

Good luck!