View previous topic :: View next topic |
Author |
Message |
Sujao l33t
Joined: 25 Sep 2004 Posts: 677 Location: Germany
|
Posted: Sun Jan 16, 2005 4:10 pm Post subject: looking for explanation of XVID enconding parameters |
|
|
Hi I am trying to encode some movies with XVID and would like to know what all the options mean. I found a documentaion of mencoder(its the manpage in HTML) where they are explained, but I don't understand 70% of the technical terms so I dont know whats good and whats not. Of course I know a little about the basic terms but I dont
Do you know any manual where the options are explained in plain words and maybe also with examples. |
|
Back to top |
|
|
fireflymantis n00b
Joined: 02 Jan 2005 Posts: 43 Location: Edmonton, Alberta, Canada
|
Posted: Sun Jan 16, 2005 10:37 pm Post subject: |
|
|
Allright, I'm not totally an expert but i do have a fair bit of experiance with encoding video, so i'll try to explain what i can, if i make any serious mistakes, anyone out there is welcome to point them out.
i'll just go through the list of xvid options and do my best to explain it.
pass=<1|2> -- if you want the best quality/compression ratio, you probably want to use 2 pass encoding. generally what you do when you use this option is to calculate motion compensation and other non lossy compression related tweaks (qpel, trellis, gmc. bframe placement. etc ) and then on the second pass where the compression is done, you will acheive better quality vs compression.
bitrate=<value> fairly self explanitory. higher = better quality with larger files, and lower = less quality with smaller files. with some optimizations you can get near dvd quality with around 700, VCD quality around 300-400 and internet streaming quality around 80-150. size makes a big diffrerence here. if you want high quality on a 720x480 sized movie, you will need ~800kb/s+. but that really isn't too bad. each hour of move = about 600-700MB.
fixed_quant=<1-31> you generally want to use the variable quantisizer which will switch between the modes automagically to obtain best size/quality ratio. leave this option be unless you have specific needs.
interlacing if you are planning to not resize the video again, you probably want to enable this. what interlacing does is combine the frames together. so each frame is actually made up of the the current frame on even lines and the theoretical half frame after it on odd lines. this makes the movie seem to play smoother with the same fps.
4mv this is allready included with the me_quality option, which i skepped over becasue it's default value is 6. you probably don't need to play with it.
generally you don't need to play with the rc_* options unless you are preparing the movie for webcast or other bitrate dependant implementations. because a movie can quickly switch between calm scenes to high action scenes, the encoder will take a few moments to adjust the encoding system. these options control that
(min|max)_key_intraval=<value> because xvid is a keyframe based encoder. it takes a 'full' copy of the image every so often and then just fills in the stuff in between. you can change how little or how often xvid buils a keyframe. if the movie does not have a lot of movment in it. you can probably set the max to 20*fps (30fps * 20 = 600). default is 10*fps.
keyframe_boost=<0-1000> increases the quality of the keyframes at the expence of the quality of the stuff in between. if you have a very 'slow/lowaction' movie. you can increase this to taste. if you have a high action movie. keep it at teh default of 0.
kfthreshold=<value> this sets teh threshhold that keyframes are allowed to be between. the default of 10, means that keyframes closer then 10 frames apart will be of reduced quality as specified by the option kfreduction=<0-100>
leave the (no)greyscale option as is, default is on. lets some dencoders speed up chroma plane calculations. setting it to nogreyscale saves you about 100-500kb.
don't bother with the (no)packed option. will only cause you headaches with no noticible gain.
Ahh. our good friend the Bframe. generally, unless you are a nazi for size. leave these settings as is. if you happen to be a size nazi. be careful, as this can make you video look ugly. if you have something like a slideshow, where you are displaying static images, b-frames are for you. if have lots of scenes where there is virtually no movement. b-frames are good. if you have a scene with littel movemest with the exeption of one or two things. b-frames will make you want to kill yourself. have fun. and don't even bother if you have lots of action.
frame_drop_ratio=<1-100> (only if max_bframes=0) if you have a video that has a fair amount of static/still scenes, turn this option up a notch or two to save some file size with littel drop in quality. it will reuse previous frames to build the current one.
qpel. doubles the accuracy of motion compensation. sometimes increses bitrate use, sometimes decreses it. take a small patch of you video and try it with it on, and with it off and see which one looks better. because you probably set your bitrate manually, sometimes qpel will use up more of that memory thereby decreasing quality. othertimes teh increased motion compinsation ends up saving memory and thereby increasing quality.
trellis. it is like vhq mode, but uses some nice hacks to get some better speed, if encoding speed is an issue. use trellis. if not. use vhq.
(no)cartoo.. if your encoding a cartoon/anime turn this on. else leave it be.
quant_type=<mpeg|h265> use mpeg for high bitrate movies >700-800kb/s and h263 for low bitrate movies <600-700kb/s. nuff said.
(no)chroma_me this can sometimes help a lot with motion estimation. try it on and see if it helps. if the movie has a lot of contrast (outdoor shots, cartoons, bright lights, etc. usually this will help. if teh contrast is low, (dark indoor, night, low quality source) then leave it as is.
(no)chroma_opt if you can spare some time during encoding, turn this on. best improvment on 2pass encoding. increases the quality a lot withough hurting the filesize. helps get rid of blogs around edges in the movie.
(no)hg_ac turn this on. it will make motion compensation use wheighted calculations bases on neighboring compression blocks. this will decrease blockiness and decrease 'tearing' with fast moving objects in the movie.
vhq=<0-4> mmmm this is probably one of the more important ones. set it to 4 whenever possible for best quality, at teh expence of a large time increase while encoding.
leave the *quant settings as is. unless you are doing some crazy custom matrix editing the defaults are fine.
curve_compression_*=<0-100> changes distribution model of how bits get allocated between high actions scenes and low actions scenes. usually a stetting of 5-10 can smooth out the video a little.
overflow_control_strength=<0-100> deafault is 5. this controls how fast teh encoder changes bitrates. if you are using 2pass encoding this is taken care for you fairly well and can be left at the default.
max_overflow_improvement=<0-100> default is 5. i use 15. that allows a bit more flexability when it comes to distribution of the bitrate.
leave the degredation setting to teh default.
don't worry about the overhead either unless you are trying to hit a very precise target bitrate/size.
unless you have very specific needs. the default pixel aspect ration (par) is fine. the aspect/autoaspect option will take care of this.
aspect=<x/y | f> here is where we set teh aspect ration if you want to do it manually. some common ones are 4/3 and 16/9.
autoaspect let mencoder handel the aspect ratio.
if you want to know teh computed 'quality' of the encoded video is. use the psnr option. the hight teh number the better.
and finally. if you happen to have the the XviD 1.1.x or better. and you are using (shudder) b-frames you can use teh bvhq=1 option to help out the quality of them a fair bit.
well. that is about it. hope this little refreance helps you and anyone else the reads it. ciao 4 now.
--Marty _________________ I'm Bored. Give me Ideas. feed my brain. w/e. marty@pixelalmighty.com
Sanguine Happiness |
|
Back to top |
|
|
Sujao l33t
Joined: 25 Sep 2004 Posts: 677 Location: Germany
|
|
Back to top |
|
|
beandog Bodhisattva
Joined: 04 May 2003 Posts: 2072 Location: /usa/utah
|
Posted: Sat Feb 05, 2005 3:28 pm Post subject: |
|
|
fireflymantis wrote: | Allright, I'm not totally an expert but i do have a fair bit of experiance with encoding video, so i'll try to explain what i can, if i make any serious mistakes, anyone out there is welcome to point them out. |
Marty, that is an AWESOME reference!! Do you mind if I put that in the Gentoo wiki?
gentoo-wiki.com _________________ If it ain't broke, tweak it. dvds | blurays | blog | wiki |
|
Back to top |
|
|
frodoontop Tux's lil' helper
Joined: 19 Jan 2004 Posts: 86
|
Posted: Sat Feb 05, 2005 7:47 pm Post subject: |
|
|
I thought I can just share my way of ripping a DVD with settings which proved to be very usefull, this is assuming you use XVID cvs:
First identify the part of the dvd containing the video:
-Most of the time this is dvd://1
-If not try try dvd://2, dvd://3 etc.
-The command would be mplayer dvd://1 -dvd-device /dev/hd*
-* is your adress of the dvdrom
Get all the information of the movie:
-mplayer dvd://1 -dvd-device /dev/hd* -vo null -ao null -frames 0 -v 2>&1 | grep sid >log.txt && mplayer dvd://1 -dvd-device /dev/hdd -vo null -ao null -frames 0 -v 2>&1 | grep aid >>log.txt
Use vobcopy to copy the disc:
-vobcopy -l -t video.vob
-Make sure you're dvd-drive is mounted or it may complain
-Copy the .IFO file beloning to the movie part (dvd://number) from pathtodvd/VIDEO_TS/VTS_number_0.ifo
Detect the black borders:
-mplayer video.vob -vf cropdetect
-Skip through the video to let it do it's work
-Note the suggested crop values in log.txt
Detect the filelength (for I never see the credits)
-mplayer video.vob -osdlevel 3
-Skip to the end, note down the time where the video ends in log.txt
-If you want to include the credits, please ignore this step, it will cost quality though
Run the first pass of Xvid (fast):
-mencoder video.vob -endpos hh:mm:ss -nosound -o pass1.avi -sws 2 -vf crop=xxx:xxx:xx:xx,scale=576:320 -ovc xvid -xvidencopts pass=1:chroma_me:max_bframes=2:bvhq=1:vhq=1:trellis
-Your endpos is in your log.txt
-The cropvalue in in your log.txt
If the size of the first pass is reasonable, you can encode the audio and then run the second pass.
-The size is reasonable if the resulting video-only file has to be about <=30% smaller.
-Don't forget some MB for the audio
-If the resulting file has to be bigger, increase the resolution in steps of 32. For example try 640:352. Rerun the first pass with changed settings.
-If the compression would be higher than 30%, rerun the first pass with a denoise filter or decide to go for 2 CD's. Recommended denoise filter: hqdn3d=2:1:3 (Put it right after cropping with a ",")
-Based on the amount the video has to compress, choose a quality for the audio. I recommend using vorbis for movies. For hard to compress movies use vorbis at q0, otherwise stick to q2, or with real good compression q4. (Higher has no usage, for you won't possibly hear, if you insist just use the AC3 file)
Encode the audio:
-mplayer -vo null -vc dummy -ao pcm -aofile 2channels.wav video.vob -aid 128
-oggenc -q2 2channels.wav
-vorbisgain 2channels.ogg (Pumping up the volume without distortion)
-The -aid number you want is in your log.txt
Rip the subtitles:
-mencoder video.vob -ifo movie.ifo -vobsubout subtitles -vobsuboutindex 0 -sid 0 -ovc frameno -nosound
-for every extra subtitle you want to rip, increase vobsuboutindex with 1. With sid you can specify the languages found in your log.txt
-One subtitle usually costs you about 1,5 MB (compressed)
-Best way to measure the final size is to mux the subtitles only in a matroska file --> see end of instructions
Compute the bitrate:
vbr=(totalsize-audiosize-subtitlesize)*fps*8/frames
vbr=(734003200-62861936)*25*8/150750
vbr=870926
-These are examplevalues
-Bitrate is quite good, usually an undersize of about 1-2 MB.
-We'll use this bitrate for the second pass
Run the second pass:
mencoder video.vob -endpos hh:mm:ss -nosound -o pass2.avi -sws 2 -vf crop=xxx:xxx:xx:xx,scale=576:320 -ovc xvid -xvidencopts pass=2:bitrate=870926:chroma_me:max_bframes=2:bvhq=1:vhq=1:trellis
Now mux it all together and check for audio sync:
-Use mkvtoolnix (mmg to start)
-Open from mmg: pass2.avi, 2channel.ogg and subtitle.idx
-Set aspect-ratio of the video according the information outputted at the end of pass1/2
-Mux!
-Check if the audio is in sync with mplayer (mplayer pass2.mkv)
-Use control + or control - to see if it's getting better
-Redo the muxing with an other audio offset. This is positive if you used control +.
Enjoy your new quality rip! |
|
Back to top |
|
|
fireflymantis n00b
Joined: 02 Jan 2005 Posts: 43 Location: Edmonton, Alberta, Canada
|
Posted: Sat Feb 05, 2005 11:15 pm Post subject: |
|
|
Sure sdibb, that would be great. _________________ I'm Bored. Give me Ideas. feed my brain. w/e. marty@pixelalmighty.com
Sanguine Happiness |
|
Back to top |
|
|
Sujao l33t
Joined: 25 Sep 2004 Posts: 677 Location: Germany
|
Posted: Sat Feb 05, 2005 11:39 pm Post subject: |
|
|
fireflymantis wrote: | I'm Bored. Give me Ideas. feed my brain |
What is the question for "42"? |
|
Back to top |
|
|
fireflymantis n00b
Joined: 02 Jan 2005 Posts: 43 Location: Edmonton, Alberta, Canada
|
Posted: Sun Feb 06, 2005 2:51 am Post subject: |
|
|
I believe the generally accepted question, after some deliberation by the white mice, is "what is 6x7?"
Also, thank you for noticing my sig. makes me feel all warm and squigy inside. _________________ I'm Bored. Give me Ideas. feed my brain. w/e. marty@pixelalmighty.com
Sanguine Happiness |
|
Back to top |
|
|
Sujao l33t
Joined: 25 Sep 2004 Posts: 677 Location: Germany
|
Posted: Sun Feb 06, 2005 3:18 am Post subject: |
|
|
There is a book/tv series called "The hitchhickers guide to universe" . A super intelligent computer should answer the question for: "What is the meaning of Life, the Universe, Everything!" After 8 million years of thinking his answer was "42"! When asked for an explanation of the answer he told that they should have asked the right question. When asked what that question should be he told that he wasnt able to answer this question.
P.S. What does "squigy" mean? Although I get the idea, I couldnt find it in the dictionary. |
|
Back to top |
|
|
fireflymantis n00b
Joined: 02 Jan 2005 Posts: 43 Location: Edmonton, Alberta, Canada
|
Posted: Sun Feb 06, 2005 11:16 pm Post subject: |
|
|
1) it is the "Hichhikers guide to teh galaxy
2) it is a Radioplay, which evolved into a book, which evolved into a really crappy TV series, which is currently being evolved into a Movie.
3) it was only 20,000 years, not 8 million I do believe.
4) the super computer was named Deep Thought
5) the question was to be figured out by an even more powerful computer, the most powerful computer ever built, and it was called earth. unfortunatly it got blown up 5 minutes before it solved it.
6) Squigy, a combination of squishy and gooey, with a bit of goop on top. _________________ I'm Bored. Give me Ideas. feed my brain. w/e. marty@pixelalmighty.com
Sanguine Happiness |
|
Back to top |
|
|
Sujao l33t
Joined: 25 Sep 2004 Posts: 677 Location: Germany
|
Posted: Mon Feb 07, 2005 12:01 am Post subject: |
|
|
1.) you are absolutely right
2.) It was a long time ago I watched "the crappy tv series"
3.) I didnt want to go to much into detail so I skipped some facts.
|
|
Back to top |
|
|
fireflymantis n00b
Joined: 02 Jan 2005 Posts: 43 Location: Edmonton, Alberta, Canada
|
Posted: Mon Feb 07, 2005 12:03 am Post subject: |
|
|
_________________ I'm Bored. Give me Ideas. feed my brain. w/e. marty@pixelalmighty.com
Sanguine Happiness |
|
Back to top |
|
|
beandog Bodhisattva
Joined: 04 May 2003 Posts: 2072 Location: /usa/utah
|
|
Back to top |
|
|
R!tman Veteran
Joined: 18 Dec 2003 Posts: 1303 Location: Zurich, Switzerland
|
Posted: Tue Feb 08, 2005 11:19 pm Post subject: |
|
|
Oh, this thread was sooo what I was looking for. Thanks for all the info. |
|
Back to top |
|
|
beandog Bodhisattva
Joined: 04 May 2003 Posts: 2072 Location: /usa/utah
|
|
Back to top |
|
|
woZa Guru
Joined: 18 Nov 2003 Posts: 340 Location: The Steel City - UK
|
Posted: Sun Apr 03, 2005 9:23 am Post subject: |
|
|
Great post... Thought I would add this little snippet
A great little frontend for mencoder to rip and compress dvd's _________________ A few months struggling with gentoo is better than a lifetime struggling with windoze! |
|
Back to top |
|
|
mallchin l33t
Joined: 21 Jan 2003 Posts: 655 Location: United Kingdom
|
Posted: Thu May 19, 2005 10:43 pm Post subject: |
|
|
fireflymantis wrote: |
2) it is a Radioplay, which evolved into a book, which evolved into a really crappy TV series, which is currently being evolved into a Movie.
|
2a) It was an awesome TV series and light-years ahead for its time. Full thumbs up, and it even guest starred Douglas Adams! _________________ 6700 @ 2.66GHz, 4Gb RAM, 2 x 500Gb, 8800 GTX, PhysX, X-Fi, 24" Widescreen, Tux mascot |
|
Back to top |
|
|
paramthegreat Tux's lil' helper
Joined: 12 Aug 2002 Posts: 78
|
Posted: Wed Jan 04, 2006 4:24 pm Post subject: ripping issue |
|
|
1st of all, thanx for the great guide. I have been having a peculair issue with ripping the movie "day after tommorrow". i used dvdshrink on windows to make a backup of the dvd to my hdd. now whenever i try to use mencoder to rip the movie, throughout the ripping process i get the message
i am getting a very choppy rip in the sense that each frame is excellent, but transition from one frame to the next is quite jerky. especially evident in the scenes that have snow. playing the backed up dvd with mplayer does not show the jerkiness. i also had same problem with a couple other movies with same error message. however, they did not have as much motion so it was bearable.
is there anyway to get around this except for maybe changing the source.
thanx,
parminder _________________ Parminder
guptaparminder at yahoo dot com |
|
Back to top |
|
|
Budda n00b
Joined: 23 Aug 2006 Posts: 16
|
Posted: Wed Aug 23, 2006 3:42 pm Post subject: Does mencoder can encode files into mpeg2 format? |
|
|
Does mencoder can encode files into mpeg2 format? I have try such command:
Quote: | mencoder vts_01_1.vob -o vts_mpeg2.avi -oac lavc -lavcopts acodec=ac3 -ovc lavc -lavcopts vcodec=mpeg2video | end obtain a vts_mpeg2.avi file. It is played with mplayer, but no one other player (DivX, XviD, VirtualDub, WinDVD...).
Can somebody help me?
Does lavc's codec "mpeg2video" create an mpeg2 file-format? |
|
Back to top |
|
|
DooBeDooBeDo Apprentice
Joined: 21 Aug 2002 Posts: 220 Location: UK
|
Posted: Wed Aug 23, 2006 5:51 pm Post subject: Re: Does mencoder can encode files into mpeg2 format? |
|
|
Budda wrote: | Does mencoder can encode files into mpeg2 format? I have try such command:
Quote: | mencoder vts_01_1.vob -o vts_mpeg2.avi -oac lavc -lavcopts acodec=ac3 -ovc lavc -lavcopts vcodec=mpeg2video | end obtain a vts_mpeg2.avi file. It is played with mplayer, but no one other player (DivX, XviD, VirtualDub, WinDVD...).
Can somebody help me?
Does lavc's codec "mpeg2video" create an mpeg2 file-format? |
It looks like you're re-encoding a vob (which is already mpeg2) to mpeg2 with ac3 audio and putting it inside an avi container. Mpeg2 in avi container is not strictly valid. Mplayer will play it but nothing else will (avidemux will probably open it too).
What are you trying to achieve? |
|
Back to top |
|
|
Budda n00b
Joined: 23 Aug 2006 Posts: 16
|
Posted: Thu Aug 24, 2006 12:54 pm Post subject: Re: Does mencoder can encode files into mpeg2 format? |
|
|
2DooBeDooBeDo: thank you for answer.
DooBeDooBeDo wrote: |
It looks like you're re-encoding a vob (which is already mpeg2) to mpeg2 with ac3 audio and putting it inside an avi container. Mpeg2 in avi container is not strictly valid. |
Resulting file extension t is not a problem for me. Can it be a 'vob' again?
Quote: | Mplayer will play it but nothing else will (avidemux will probably open it too). |
You right: nothing play "my" file except of mplayer.
Quote: | What are you trying to achieve? |
I simply want to copy dvd-film to my PC and burn it into the my personal DVD. I also can output into another vob-file.
But yesterday I have found, that it is possible to to execute such command:
Quote: | mencoder vts_01_1.vob -o vts_mpeg2.avi -oac lavc -lavcopts acodec=ac3 -ovc lavc -lavcopts vcodec=mpeg2video -of mpeg | (I have add output format mpeg). As a result I obtain file in mpeg2 which is putted into avi and is played with at least by VirtualDub.
Am I correct in my approach? Is some another way to copy dvd film in mpeg2?
And the last question: do you know, how to copy ALL audio tracks FROM dvd to my resulting file? How copy DVD-disk menu?
Thanks! _________________ http://vfm.1gb.ru/ |
|
Back to top |
|
|
DooBeDooBeDo Apprentice
Joined: 21 Aug 2002 Posts: 220 Location: UK
|
Posted: Thu Aug 24, 2006 2:46 pm Post subject: |
|
|
If you're just trying to copy a DVD to a DVDR check out k9copy, it's in portage. I think it'll do everything you want. |
|
Back to top |
|
|
Budda n00b
Joined: 23 Aug 2006 Posts: 16
|
Posted: Fri Aug 25, 2006 9:22 am Post subject: |
|
|
I am a programmer, and I have sources of mplayer/mencoder. This give me possibility create my home conversion tool with a lot of options.
But thanks, I will look k9copy obviously. Can you say why it is better then mencoder? _________________ http://vfm.1gb.ru/ |
|
Back to top |
|
|
Budda n00b
Joined: 23 Aug 2006 Posts: 16
|
Posted: Fri Aug 25, 2006 9:34 am Post subject: |
|
|
k9copy works under unix only? I have found it, but it is aimed on unix only? Or I mistakened? _________________ http://vfm.1gb.ru/ |
|
Back to top |
|
|
Larcen Apprentice
Joined: 21 Mar 2004 Posts: 174
|
Posted: Sat Aug 26, 2006 2:04 pm Post subject: |
|
|
First let me explain what I have been doing, then I'll get to what I want to do.
I first merged my *.VOB files into one: cat VTS_01_*.VOB >> VTS.VOB
Next I've been trying a multitude of mencoder command line examples I've found throughout the wiki and searching the forums and some fail, some result in only a 50-100mb file, and other times out of sync when the movie completes. I've since added the -vf harddup option which seems to have reduced the duplicate frame errors from hundreds to only 2 or 3.
Now, this is what I'm looking to achive. I don't care really how long it takes to create but what I look forward to is taking one of my DVD's and converting it to a high quality .avi to play in my standalone home entertainment system. Whether it be -oac copy or another codec, I don't care, so long as it's crisp and clear. Same with Video, I only want it to be one 700mb file though, and the framerate to be nice and smooth. 1 pass, 2 pass, 3 or more passes, like I said before I care little about the time it takes. Quality over Quantity right?
I've been doing this for about 4 years, converting my purchased DVD's to SVCD's using my wife's windows machine, but I want to cut the disc usage down to 1 and raise the quality at the same time. Oh, and use my computer of course.
--EDIT--
More times than not now it appears I'm getting this error as well.
MPEG: No audio stream found -> no sound. |
|
Back to top |
|
|
|