View Full Version : mpeg2 encoding in Linux
M7S
13th September 2005, 14:56
Until now I've used quenc or HC with wine for encoding mpeg2 since I've heard that they bring better quality than native Linux solutions like mencoder. Is it any truth in this? Or is it just a question of choosing the right options for mencoder to get quality from it?
I know... The Doom9 way to do this would be to test and see for myself instead of asking what's better, but I would certainly need some suggestions on good commandline options for good quality mpeg2 encoding with mencoder (or mpeg2enc or something else if that's better), before I'm up to doing any compairing myself.
Please show me your kick-ass native mpeg2 encoding command line! ;)
Regards,
M7S
Fl0ppy
16th September 2005, 20:52
Use mpg2enc, it very good.
hellfred
17th September 2005, 12:22
Until now I've used quenc or HC with wine for encoding mpeg2 since I've heard that they bring better quality than native Linux solutions like mencoder. Is it any truth in this? Or is it just a question of choosing the right options for mencoder to get quality from it?
HC is not realted to libavcodec (the base of mencoders MPEG2 encoding), but QuEnc is. In QuEnc, xvids ratecontroll was included for 2-pass encoding. So - for one pass encoding - mencoder and QuEnc should yield the same results AFAIK. But have a look at the development threads here on doom9 forum here. (http://forum.doom9.org/forumdisplay.php?f=62)
Killer commandlines for small bitrates can be found there (http://forum.doom9.org/showthread.php?t=98633), too
Hellfred
mean
17th September 2005, 15:39
Alternatively use avidemux, since quenc ratecontrol comes from it.
M7S
17th September 2005, 19:12
Thanks for your answers.
@Fl0ppy
What encoders have you been comparing mpeg2enc against? Also, are there any problems with bitrate spikes with mpeg2enc?
@Hellfred
I know that quenc is based on lavc, but I thought Nic had made more changes than just the ratecontrol. I've been following quenc's and HC's development threads, but at times maybe not as activly as I should. I totally missed that Sagittaire included mencoder in his test when I checked out that thread some days ago, though (that's quite embarrassing as mencoder in fact was the winner :o ). Thanks for the link. Making good command lines for mencoder is apparently even harder than I thought :(.
@mean
I thought that quenc's ratecontrol comes from xvid. Or do you mean that quenc's old ratecontrol came from avidemux? In either case I should check it out. I haven't checked it out since I was under the impression that it was just a frontend for mencoder (or perhaps transcoder).
Thanks again for your answers,
M7S
mean
17th September 2005, 19:48
It is a bit more complicated
There is 2 layers :
1- bit allocation : That comes from xvid ratecontrol, unchanged
2- above that, VBV enforcement needed for DVD compliance. That comes from avidemux as xvid rc has (had ?) not strict VBV when i took it
It is the file ADM_xvidratectlVBV.cpp for the curious minds
M7S
19th September 2005, 14:18
@mean
AviDemux is a great program. I wonder why I've never tried it before.
Unfortunetly I seem to get undersized files all the time with avidemux (DVD lavc), while quenc doesn't undersize. I wonder why. Does quenc allow quant 1 while your program wont, or do quenc and AviDemux use different matrices (I used the default matrices in both cases)?
Regards,
M7S
mean
19th September 2005, 14:57
yes Quenc allows Qz=1, while avidemux only allows Qz=2 as minimum
Furthermore, Nic tweaked a bit the RC settings. You can merge his changes to see if it is better.
My opinion for what it's worth is that using Qz=1 does not cause major quality gain.
micmac
16th January 2006, 10:37
Hi guys,
this thread is a little older, but I just have to write this down :)
I tried mpeg2 encoding in Linux 2 years ago or so. I got disappointed fast and stopped.
But yesterday I was given a documentary in DivX format. I'm using VDR with the mplayer-plugin to display MPEG4 videos on my TV. It usually works ok, but it has its problems. So, anyway, I decided that I would give it a shot and try to make a DVD5 out of the file.
Mind you that the source is just a DivX file with a relatively low resolution. But the picture is ok.
file Documentary.avi
Documentary.avi: RIFF (little-endian) data, AVI, 512 x 288, 29.97 fps, video: DivX 5, audio: MPEG-1 Layer 3 (stereo, 44100 Hz
For encoding I used mplayer (with libavcodec) from CVS. A few hours later I'm watching the mpeg2 file and I'm really stunned. For sure the mplayer/ffmpeg guys really did did a great job.
This is what I used:
mencoder -sws 9 -vf scale=720:480,harddup -ofps 30000/1001 Documentary.avi -oac lavc -ovc lavc -srate 48000 -af lavcresample=48000 \
-lavcopts trell:cbp:dc=10:precmp=2:subcmp=2:cmp=2:dia=-10:predia=-10:mv0:vqmin=1:lmin=1:aspect=16/9:vcodec=mpeg2video:mbd=2: \
keyint=12:vrc_maxrate=9800:vrc_buf_size=1835:vpass=1:vbitrate=5200:acodec=ac3:abitrate=192 -o /dev/null -of mpeg -mpegopts \
format=dvd && mencoder -sws 9 -vf scale=720:480,harddup -ofps 30000/1001 Documentary.avi -oac lavc -ovc lavc -srate 48000 -af \
lavcresample=48000 -lavcopts trell:cbp:dc=10:precmp=2:subcmp=2:cmp=2:dia=-10:predia=-10:mv0:vqmin=1:lmin=1:aspect=16/9: \
vcodec=mpeg2video:mbd=2:keyint=12:vrc_maxrate=9800:vrc_buf_size=1835:vpass=2:vbitrate=5200:acodec=ac3:abitrate=192 -o \
Documentary.mpeg -of mpeg -mpegopts format=dvd
It's basically what the mplayer docs suggest. Link (http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-vcd-dvd.html).
Try it
Sebastian
snherbst
16th January 2006, 11:59
the forum @ Gentoo has a good thread about transcoding/encoding mpeg files.
Hellworm
17th January 2006, 13:59
For mpeg2 I normally use mencoder with nearly the same settings that micmac used ( I dont use the rate-distortion optimal settings: mbd=1, cmp(s)=256, no cpb ) it gives very high quality together with high speed.
micmac
17th January 2006, 15:03
Is there a scientific method to compare videos? I mean like a way to measure the difference between the encoding and the source material?
I'd really like to know the difference between ffmpeg (used in mencoder) and, say, CCE (like, which one is more like the source video) :)
Cheers
mic
Hellworm
17th January 2006, 18:38
Thats what psnr is for (and other like ssim).
But you better trust your own eyes, since these methods arent that good, only for big differences in quality.
M7S
17th January 2007, 23:35
You couldn't have chosen a better time to bump my old thread. Today I needed it for the first time in over a year and the information you posted was exactly what I needed most right now (in a few days I might show you why). I have a few questions though about the mencoder command line posted.
You use constant bitrate instead of constant quantizer in pass 1. Does this give better result with lavcenc's rate control?
In fact almost every option in first pass is identical with those in the second pass. Is it generally a bad idea to skip things like trellis in first pass?
You left out vstrict=0 that the document you were linking to recommended. Is it because you don't care about compability with stand-alones or does vstrict=0 have a noticeable negative impact on the quality?
Regards,
M7S
Edit: I'm incredibly bad at reading dates. I guess I bumped a year old thread without realizing it :o (and it took me only two weeks to figure that out....)
nm
18th January 2007, 12:45
You use constant bitrate instead of constant quantizer in pass 1. Does this give better result with lavcenc's rate control?
Yes.
In fact almost every option in first pass is identical with those in the second pass. Is it generally a bad idea to skip things like trellis in first pass?
It's probably a bad idea to skip things without knowing what the encoder does. However, you can safely use the "turbo" option for the first pass.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.