LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-21-2008, 02:30 PM   #1
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Rep: Reputation: 30
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
 
Old 04-21-2008, 03:28 PM   #2
beadyallen
Member
 
Registered: Mar 2008
Location: UK
Distribution: Fedora, Gentoo
Posts: 209

Rep: Reputation: 36
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.
 
Old 04-21-2008, 05:57 PM   #3
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Original Poster
Rep: Reputation: 30
Great, that works nicely. --Thanks
 
Old 04-21-2008, 09:01 PM   #4
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
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.
 
Old 04-21-2008, 09:20 PM   #5
beadyallen
Member
 
Registered: Mar 2008
Location: UK
Distribution: Fedora, Gentoo
Posts: 209

Rep: Reputation: 36
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.
 
Old 04-22-2008, 09:58 AM   #6
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Original Poster
Rep: Reputation: 30
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
 
Old 04-23-2008, 07:42 PM   #7
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
No sound in video recorded with mencoder sammckee Linux - Software 5 05-26-2007 06:15 PM
LXer: Get top-quality scans from your scanner with Lprof LXer Syndicated Linux News 0 11-16-2006 02:21 AM
LXer: Visioneering Releases Four New IPTV Set-top Boxes; Sonata IPTV(TM) Delivers Unmatched Video Quality Over Broadband LXer Syndicated Linux News 0 06-22-2006 01:03 PM
mencoder with Archos video jukebox johngcarlsson Linux - Software 0 11-19-2004 11:42 AM
mencoder quality low gonniff Linux - Software 10 09-16-2003 05:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration