LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   How can I get top quality video with mencoder? (http://www.linuxquestions.org/questions/linux-software-2/how-can-i-get-top-quality-video-with-mencoder-636846/)

xmrkite 04-21-2008 03:30 PM

How can I get top quality video with mencoder?
 
Hello, i want to encode mpeg-2 video files from my ubuntu gutsy computer to xvids. I've seen some of the torrents where they get a whole movie in around 700mb, and the video quality is very great.

How do i achieve such quality? When i try to encode, the quality is just so so.

I've been scouring the web for good command line examples but have really not found anything. I have been able to find great lengthy tutorials, but i just want something simple as most of it is gibberish to me.

-Thanks

beadyallen 04-21-2008 04:28 PM

The most important thing is to use multipass. Without it, the bitrate won't be adhered to, so the final size will be way off. Here's the script I use for ripping dvd's (for a target size of 750meg, and 192kbps mp3 audio):
Code:

#!/bin/sh
targetsize=750
abitrate=192

#Calculate the bitrate
vidlength=`midentify "${1}" | grep 'ID_LENGTH=' | sed 's/ID_LENGTH=//'`
audiosize=$(( $abitrate*1000*${vidlength%.*}/1024/1024/8 ))
videosize=$(( $targetsize-$audiosize ))
vidbitrate=$(( $videosize*1024 ))

mencoder "${1}" -ovc xvid -xvidencopts bitrate=-$vidbitrate:pass=1:vhq=4:turbo:threads=2 -oac copy -o /dev/null
mencoder "${1}" -ovc xvid -xvidencopts bitrate=-$vidbitrate:pass=2:vhq=4:threads=2 -oac mp3lame -lameopts br=$abitrate:vol=2:aq=2:mode=0:vbr=0 -o output.avi
mv output.avi "${1}-xvid.avi"

There's plenty of other options for xvidencopts in the manpage. Have a play around to see what you want. The above is fine from my point of view. You may decide you want better quality.

xmrkite 04-21-2008 06:57 PM

Great, that works nicely. --Thanks

Electro 04-21-2008 10:01 PM

I think multiple threads will decrease quality. If the MPEG-2 has a lot of noise or is blocky, the xVid encoder will have a hard time guessing. I suggest use video filters to smooth out the noise. I have used hqdn3d with values 2:1.5:3 to clean out noisy videos (mainly DVD movies). Other video filters can be used to enhance the compression algorithm of xVid.

If the video is a DVD movie or came from a PVR card, you will have to worry about the interlace material in it. This means you will have to worry about catching all the frames and de-interlace the video if you want a progressive video.

beadyallen 04-21-2008 10:20 PM

Interesting, I didn't know about multiple threads hurting quality. To be honest the xvid encoder doesn't seem to scale over multiple threads well at highish quality. I'll have a play myself to see if it's worth it.

Thanks for the tip.

xmrkite 04-22-2008 10:58 AM

OK, so my content is from a pvr-500 tuner but i'm using my cable box and connecting it to the svideo port. --how do i apply these so called filters?

-Also, what other filters can i try? I want to try to find a one size fits all setting so that it just works for each video file and i don't have to fiddle with it for every encoding i do.

-Thanks

Electro 04-23-2008 08:42 PM

I use the following syntax to playback DVD movies.

Code:

mplayer -pp 0 -vf-clr -vf pullup,yadif=1,hqdn3d=2:1.5:3,scale=-1:-1:0 -ssf ls=100 dvd://
For MPEG-2 content from a PVR card might be different on applying video filters. I suggest check the MPlayer manual to know how to use the video filter and know what they do.

Let us assume that hqdn3d=2:1.5:3 is a good way to clean up MPEG-2 and yadif=1 is a good decent de-interlacer. I would say that the following should work ok for most content.

Code:

mplayer -vf yadif=1,hqdn3d=2:1.5:3,scale=-1:-1:0
Maybe adding -ssf ls=100 will increase the sharpness of the content to bring out the details of the video. With mencoder, it is a little different on what options you can use compared to mplayer, so play around with the settings.


All times are GMT -5. The time now is 08:44 AM.