Transcoding Tools From Dvdripping-Guid


Table of Contents

Transcoding Divx to VCD, SVCD, CVCD, etc. under Linux 
Basic concepts: 
Tools: 
Divx2VCD: 
Divx2CVCD: 
Divx2SVCD: 
Subtitles: 
Divx2CVCD test run 
cmd:divx2cvcd 
Info 
Source 
Comments 
cmd:divx2svcd 
Source 
Comments 
Trying History 
Ripping DVDs to VCD and AVI to VCD with mencvcd (Linux) 
Why CVCD is better 
Why CVCD is better 
Why CVCD is better 
Why CVCD is better 
To solve wrong colours problem 
To solve wrong colours problem 

Transcoding Divx to VCD, SVCD, CVCD, etc. under Linux 

http://dvdripping-guid.berlios.de/Divx-to-VCD_en.html

by paranouei

LinuxMalaga

News(06/09/2003): New script divx2cvcd available. This new script doesn't use transcode anymore so now supports more codecs and its more customizable. http://dvdripping-guid.berlios.de/divx2cvcd-new

News(20/01/2003): New forum available. You can ask there your questions about this guide.

So you just came from shopping with your brand new DVD player, and now you would like to transcode your Divx files to VCD to enjoy them in your big TV at the living room…

This task can be done in linux, you can even automate it so you just have to type i.e. divx2vcd <file.avi>, go for a walk, and when you are back you have a fresh .bin and .cue files ready to burn.

Ok, let's see a few basic concepts before we begin:

Basic concepts: 

  • VCD: Video CD. It's an MPEG-1 stream, at 352x288 and 25 fps (PAL), or 352x240 and 29.976 fps (NTSC). It has constat bitrate at 1150kbps and the audio is MPEG layer 2 at 224 kbps. You can fit as many minutes as the CD says (74 or 80).
  • SVCD: Super Video CD. It's an MPEG-2 stream, at 480x576 and 25 fps (PAL), or 480x480 and 29.976 fps (NTSC). The bitrate may be variable up to 2600kbps, and the audio can be between 32 and 384 kbps. Depending on the bitrate you choose you can fit more or less minutes, but you can usually fit between 40 and 55 minutes per CD.
  • XVCD, CVCD..: These are modifications of the standard, with different bitrates, etc., and they could not work on all DVDs. But today's DVD players can play almost everything.

For instance, CVCD is just a VCD with variable bitrate. This way, "easy" scenes take a lower bitrate so you have more space left and you can fit more minutes. You can fit this way more than 90 minutes in a CD.

Tools: 

  • Mplayer. This will be our input filter for transcode. This way, transcode will be able to handle everthing mplayer can read (divx, realmedia, subtitles…)
  • Transcode. This is the main tool. It's for transcoding between almost any imaginable format.
  • MJPEG Tools. This will be our output filter. Also, in includes tools for multiplexing the mpg.
  • VCDImager. This tool is for creating the .bin and .cue files from the mpg.

Also, my scripts use some basic utils like bc (calculator) and perl.

Well, once you've got that, let's start ;)

Divx2VCD: 

I wrote the following script "divx2vcd", it takes care of the calculations to get an image with the same aspect ratio (adding black borders if needed). It uses constant, so it's fully VCD standard. The maximum file size (to make them fit in a CD), it's in CDSIZE variable. The script creates the video and audio with transcode, then it multiplexes them with mplex, and finally it creates de images. You can download it from here. I'm gonna paste it here so you can see it (sorry comments are in spanish):

Divx2CVCD: 

New script Divx2CVCD (16/12/2002). This scripts gets all information from the .avi file, and then calculates automatically the video bitrate to make it fit in a CD in CVCD format (VCD with variable bitrate). You can change the QUANTUM variable. It's the quality (like the CQ-Constant Quality from TMPGenc), it must be between 2 and 31, the smaller it is, the biggest quality. With a value under 8 you get good quality. You can change AUDIORATE too. The script is available here, and I'm pasting it here:

News(06/09/2003): New script divx2cvcd available. This new script doesn't use transcode anymore so now supports more codecs and its more customizable.

Divx2SVCD: 

For the SVCD creation is basically the same script, I only adjusted it to create a SVCD. You can change CDSIZE, QUANTUM, MAXVIDEORATE and AUDIORATE. You don't need to create an bbmpeg template because it creates it automatically.. Like before, you can download the script from here

Subtitles: 

If we've got a divx file in a foreign language, and a subtitles file it is also possible to transcode them when we create the *VCD. The subtitles will be recorded as part of the movie (so you can't disable them when watching the *VCD).

The method is quite simple, you just have to have a subtitles file supported by mplayer (subrip, microdvd… mplayer supports almost everything), and put the file in the same folder as the .avi, and rename the file so it has exactly the same name as the .avi file (except the extension of course). This way we make mplayer to autoload the subtitles. You can try if it works before transcoding, just do mplayer <file.avi> and see if the subtitles are autoloaded.

Well, I hope this little guide was helpful for you ;).

Divx2CVCD test run 

$ divx2cvcd ~+1/"f1.avi"
[tcprobe] RIFF data, AVI video
Video Output: 352x240
alto sin bordes: 180, con borde: 30
INFO:   Multiplexing file Pelicula00.mpg
*** Multiplexing: 99% - 90263 of 91169  A/V units. (99)%
INFO:   Finished multiplexing Pelicula00.mpg
*** Multiplexing: 100% - 91169 of 91169  A/V units. (100)%
Playing Pelicula00.mpg.
Cache fill:  0.00% (0 bytes)    MPEG-PS file format detected.
VIDEO:  MPEG1  352x240  (aspect 12)  23.976 fps    0.0 kbps ( 0.0 kbyte/s)
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
MP3lib: init layer2&3 finished, tables done
AUDIO: 44100 Hz, 2 ch, 16 bit (0x10), ratio: 16000->176400 (128.0 kbit)
Selected audio codec: [mp3] afm:mp3lib (mp3lib MPEG layer-2, layer-3)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
The selected video_out device is incompatible with this codec.
VDecoder init failed :(
Opening video decoder: [libmpeg2] MPEG 1/2 Video decoder libmpeg2-v0.3.1
Selected video codec: [mpeg12] vfm:libmpeg2 (MPEG 1 or 2 (libmpeg2))
==========================================================================
Checking audio filter chain for 44100Hz/2ch/16bit -> 44100Hz/2ch/16bit...
XF86VM: Selected video mode 640x400 for image size 352x264.
X11 error: BadMatch (invalid parameter attributes)
MPlayer interrupted by signal 6 in module: decode_video
- MPlayer crashed. This shouldn't happen.
$ cat log
*************** FILE INFO ***************
Frame Size: 640x360  -   FPS: 23.976
Length: 35112   -  Seconds: 1464
0 hours, 24 minutes, 24 seconds
Recommended averagge video bitrate: 4320
Using max video bitrate: 2000
mplayer -noframedrop -vo yuv4mpeg -ao pcm -waveheader     -v -osdlevel 0  "/lfs/dl
Cache1/movies/bt/Madlax/[Ayu]_Madlax_02_[F59ADC24].avi" &
(cat stream.yuv | yuvscaler -v 0 -M WIDE2STD -O VCD -n n |     mpeg2enc -v 0 -s -f
 2 -b 2000 -q 3 -F 1 -n n -4 2 -2 1        -o /lfs/toBurn/tmp/Pelicula.mpv) &