[MPlayer-users] encode2mpeg: a new tool to create VCD/SVCD/DVD/DIVX

Giacomo Comes comes at naic.edu
Thu Jun 10 06:54:07 CEST 2004


Announcing the first public test relase of encode2mpeg.
encode2mpeg is a new tool to create VCD/SVCD/DVD/DIVX, it can be 
considered an evolution of mencvcd. From the README:



This program is essentially an interface between mplayer/mencoder
and the mjpegtools.
It is able to convert any kind of video that mplayer can play in
a format suitable for VCD/SVCD/DVD.
It has all the capabilities of mencvcd and a lot more. The idea of 
mencvcd is the following:
                  ____________ 
                 |            |
 source video -> |  mplayer   | -> final video
    (DVD)        | mjpegtools |     (S/VCD)
                 |____________|

One serious problem I found using mencvcd is that it fails to deal with
source videos that have video frame rate different from the one of the
target mpeg stream. If you have a video with variable frame rate, non 
standard (i.e. 15fps) frame rate, some exotic NTSC telecined dvd or 
simply you want to convert from PAL to NTSC or vice versa, then
mencvcd will not help you.
At some point I was bored of this and I started to figure out how to 
solve the problem. The solution is quite simple. I introduced another stage.
                  __________                   ____________ 
                 |          |                 |            |
 source video -> | mencoder | -> avi video -> |  mplayer   | -> final video
                 |          |      (DIVX)     | mjpegtools |  (VCD/SVCD/DVD)
                 |__________|                 |____________|

Mencoder is quite good in creating an avi with the properties necessary
to generate the desidered mpeg stream, then I use this avi to create
the final video.
This different design give, as a bonus, the capability for encode2mpeg to
replace also divx2svcd.
I started patching mencvcd but at some point I decided to rewrite 
from scratch the program, so encode2mpeg was born :-).
I kept all the features and many options of mencvcd and I added many more.
Here is a list of the main differences:
 - support for DVD compliant output stream
 - support for DIVX AVI
 - support for more then one audio stream (SVCD/DVD/AVI)
 - support for custom quantization matrices (thanks to mjpegtools 1.6.2)
 - support for VCD/MPEG1 variable bit rate
 - support for AC3 and LPCM audio
 - extraction of vobsub subtitles
 - nice log file that tells you what is going on
 - capability to pass any exotic option to all the tools


What do you need:

mjpegtools 1.6.2 or later (http://mjpeg.sourceforge.net/)
MPlayer 1.0pre3
You can use 1.0pre4 but you will have problems with:
  multiple audio streams (ODML issue, fixed in CVS but not tested yet)
  use of -srate to resample with mencoder.

The following programs are optional, but if you don't have all of them
encode2mpeg can still do a partial or complete job:

	lame (http://www.mp3dev.org)
	sox (http://sox.sourceforge.net/)
	toolame (http://users.tpg.com.au/adslblvi/)
	normalize (http://www1.cs.columbia.edu/~cvaill/normalize/)
	avimerge[transcode] (http://www.transcoding.org/)
	rar (http://www.exit1.org/dvdrip/contrib/rarlnx271.sfx.bin)
	vcdimager (http://www.vcdimager.org/)
	dvdauthor (http://dvdauthor.sourceforge.net/)
	cdrdao (http://cdrdao.sourceforge.net/)
	growisofs (http://fy.chalmers.se/~appro/linux/DVD+RW/)

This is the first public release. I tried to remove all the bugs, but
surely many of them escaped my hunt :-).
Please test it and report any problem to:
	encode2mpeg at katamail dot com
or to this mailing list.
At the moment a part not well tested is the dvd authoring one.
I'm not currently a dvdauthor user and I don't know all his features.
Please send me any comments, suggestions and examples.

Source download:
	http://spazioinwind.libero.it/encode2mpeg/encode2mpeg-0.1.0.tar.bz2


Some words about the creation of divx avi.
encode2mpeg creates divx avi for two different reasons:
1) it is necessary for creating a mpeg without a/v sync problems
2) you want to encode your source video to divx
In both cases I wanted the divx to preserve as much as possible the quality of 
the source video and then I set the video bitrate of the mpeg4 very high: 16000.
To tell encode2mpeg to generate divx video use the option -encode. It has 
different preset values (0-4) and I will give you an overview of what to expect 
with the different values.
In my example the source video is a 720x480 16/9 NTSC dvd movie. The raw mpeg2 
video stream and the ac3 audio stream is 3699878452 bytes long. Here are the 
results with the different argument of -encode:

encode  avi size   job time	mnemonic help
  0    2802969788    0h50m
  1    2743809930    1h01m	  1 pass
  2    2742878702    1h52m
  3    1628534896   11h15m 	  3 pass
  4    1582011700   11h55m	  4 B frames

If your final objective is the mpeg video, use 2 as argument of -encode. The 
quality of the intermediate avi is good and the time necessary is not that
bad. The use of 1 give you an increment in speed, but it use one pass encoding 
and the quality of the avi is not the best possible. 0 is there only for 
curiosity/debug, you should never use it.
If your final objective is the creation of the divx for storage purpose, then
you should use 3. There is a huge gain in file size, but there is a tremendous 
slowdown. Keep in mind that I ran my test on a 3GHz Pentium4, so on a slower
machine the time will be higher. I tried all the possible options of libavcodec
that were able to reduce the file size and were not deteriorating a lot the 
video. This is why for the value of 3 I use libavcodec with only 2 B frames. The
documentation says that a higher value is not recommended. But it is possible, 
so with the value of 4 libavcodec uses 4 B frames. There is a further gain in 
file size, but I don't know how much worst the quality of the video is.
Keep also in mind that the avi is encoded at the same resolution of the source
video and I use the autoaspect feature of libavcodec. This means that probably 
only mplayer will be able to play the avi with the correct aspect ratio.
If this is an issue the option -setaspect is your friend. Its purpose is to
scale the movie keeping the correct aspect ratio and then encode it. Here are
the results with -encode 3 and -setaspect 1-4

setaspect  avi size   job time	resolution
    4      623333314    3h00m    384x224
    3      825142384    4h52m    512x288
    2     1405223690    9h56m    720x414
    1     1766823208   13h59m    864x480

See the online help for a list and an explanation of all the options.




More information about the MPlayer-users mailing list