Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
|
|
#1 | Link |
|
Registered User
Join Date: Nov 2003
Posts: 97
|
My current mencoder methodology:
I encode xvid with mencoder and this is how do it for ntsc non-interlaced content which is the bulk of what I do. Suggestions comments and quesitons are welcome.
I use xvid's ability to store aspect ratio and I also use the mencoder modules support for autoaspect which appeared in the mplayer CVS on feb 4 a recent cvs build of mplayer. First I rip the DVD. I do this with dvd::rip because it has a nice interface for pgc ripping and has a gui for bitrate calculation. From the transcode screen on dvd::rip I select target size and the audio track I am going to use, note the resulting video bitrate. I can now close dvd::rip discarding the project. The Rest is done on the command line First I cd into the directory where the vobs are and store the bitrate in a file so I don't have to remember it dave@hammer 001 $ cd /raid/dvdrip/data/zeroeffect/vob/001/ dave@hammer 001 $ echo 1296 > bitrate Then I determine how much I need to crop with this command (I use the second vob so the opening credits don't confuse the filter) dave@hammer 001 $ mencoder -ovc lavc -oac copy -o /dev/null -vf cropdetect zeroeffect-002.vob This outputs a suggested crop. I run this command with lavc because it doesn't require and options, quicker to type. Let it run for a about thirty seconds and the run the same command on the third vob, if the values differ its usually due to some very dark scenes and it is a safe bet to take the larger of the two. ( if you want to preview the crop run mplayer with the -vf crop option. I find this unnescessary as the cropdect filter does a great job.) This movie doesn't need cropping but for examples sake I am putting a crop filter in which takes nothing off. So now I generate some samples with this script called xvid-samples: dave@hammer 001 $ /export/scripts/xvid-samples `pwd` Zero_Effect '-vf crop=720:480:0:0' or if I want to use a noise filter dave@hammer 001 $ /export/scripts/xvid-samples `pwd` Zero_Effect '-vf crop=720:480:0:0,hqdn3d' xvid-samples: #!/bin/tcsh # ${1}=path to vobs # ${2}=name of movie # ${3}=extra (eg -vf crop=) cd ${1} mkdir samples @ br=`cat bitrate` # hvs-good matrix echo "`date` ${2}.hvs-good.avi start encoding" >> xvid-samples.log mencoder -o /dev/null -ofps 23.976 -ovc xvid -xvidencopts pass=1:packed=1:turbo=1:vhq=1:quant_intra_matrix=/export/scripts/hvs-good.intra.txt:quant_inter_matrix=/export/scripts/hvs-good.inter.txt:autoaspect ${3} -endpos 2:00 -aid 128 -oac copy *2.vob echo "`date` ${2}.hvs-good.avi Pass 1 complete" >> xvid-samples.log mencoder -o samples/${2}.hvs-good.avi -ofps 23.976 -ovc xvid -xvidencopts pass=2:packed=1:turbo=1:vhq=1:bitrate=$br\:quant_intra_matrix=/export/scripts/hvs-good.intra.txt:quant_inter_matrix=/export/scripts/hvs-good.inter.txt:autoaspect ${3} -endpos 2:00 -aid 128 -oac copy *2.vob echo "`date` ${2}.hvs-good.avi Finished encoding" >> xvid-samples.log # hvs-better matrix echo "`date` ${2}.hvs-better.avi start encoding" >> xvid-samples.log mencoder -o /dev/null -ofps 23.976 -ovc xvid -xvidencopts pass=1:packed=1:turbo=1:vhq=1:quant_intra_matrix=/export/scripts/hvs-better.intra.txt:quant_inter_matrix=/export/scripts/hvs-better.inter.txt:autoaspect ${3} -endpos 2:00 -aid 128 -oac copy *2.vob echo "`date` ${2}.hvs-better.avi Pass 1 complete" >> xvid-samples.log mencoder -o samples/${2}.hvs-better.avi -ofps 23.976 -ovc xvid -xvidencopts pass=2:packed=1:turbo=1:vhq=1:bitrate=$br\:quant_intra_matrix=/export/scripts/hvs-better.intra.txt:quant_inter_matrix=/export/scripts/hvs-better.inter.txt:autoaspect ${3} -endpos 2:00 -aid 128 -oac copy *2.vob echo "`date` ${2}.hvs-better.avi Finished encoding" >> xvid-samples.log # hvs-best matrix echo "`date` ${2}.hvs-best.avi start encoding" >> xvid-samples.log mencoder -o /dev/null -ofps 23.976 -ovc xvid -xvidencopts pass=1:packed=1:turbo=1:vhq=1:quant_intra_matrix=/export/scripts/hvs-best.intra.txt:quant_inter_matrix=/export/scripts/hvs-best.inter.txt:autoaspect ${3} -endpos 2:00 -aid 128 -oac copy *2.vob echo "`date` ${2}.hvs-best.avi Pass 1 complete" >> xvid-samples.log mencoder -o samples/${2}.hvs-best.avi -ofps 23.976 -ovc xvid -xvidencopts pass=2:packed=1:turbo=1:vhq=1:bitrate=$br\:quant_intra_matrix=/export/scripts/hvs-best.intra.txt:quant_inter_matrix=/export/scripts/hvs-best.inter.txt:autoaspect ${3} -endpos 2:00 -aid 128 -oac copy *2.vob echo "`date` ${2}.hvs-best.avi Finished encoding" >> xvid-samples.log # mpeg matrix echo "`date` ${2}.mpeg.avi start encoding" >> xvid-samples.log mencoder -o /dev/null -ofps 23.976 -ovc xvid -xvidencopts pass=1:packed=1:turbo=1:vhq=1:quant_type=mpeg:autoaspect ${3} -endpos 2:00 -aid 128 -oac copy *2.vob echo "`date` ${2}.mpeg.avi Pass 1 complete" >> xvid-samples.log mencoder -o samples/${2}.mpeg.avi -ofps 23.976 -ovc xvid -xvidencopts pass=2:packed=1:turbo=1:vhq=1:bitrate=$br\:quant_type=mpeg:autoaspect ${3} -endpos 2:00 -aid 128 -oac copy *2.vob echo "`date` ${2}.mpeg.avi Finished encoding" >> xvid-samples.log # h263 matrix echo "`date` ${2}.h263.avi start encoding" >> xvid-samples.log mencoder -o /dev/null -ofps 23.976 -ovc xvid -xvidencopts pass=1:packed=1:turbo=1:vhq=1:quant_type=h263:autoaspect ${3} -endpos 2:00 -aid 128 -oac copy *2.vob echo "`date` ${2}.h263.avi Pass 1 complete" >> xvid-samples.log mencoder -o samples/${2}.h263.avi -ofps 23.976 -ovc xvid -xvidencopts pass=2:packed=1:turbo=1:vhq=1:bitrate=$br\:quant_type=h263:autoaspect ${3} -endpos 2:00 -aid 128 -oac copy *2.vob echo "`date` ${2}.h263.avi Finished encoding" >> xvid-samples.log This produces 2 minute samples from the movie encoded at my desired bitrate with good better and best hvs matrices as well as mpeg and h263. If I was unhappy with this particular sample I could do this to grab a different two minutes from 20 minutes later: dave@hammer 001 $ /export/scripts/xvid-samples `pwd` Zero_Effect '-vf crop=720:480:0:0 --ss 20:00' More often than not I will choose an hvs matrix so I run my xvid-hvs script with the following command: dave@hammer 001 $ /export/scripts/xvid-hvs `pwd` Zero_Effect best '-vf crop=720:480:0:0' Or if I am sshing into my box I will daemonize it with the at command, this also runs the process at a nice level of 2. dave@hammer 001 $ echo "/export/scripts/xvid-hvs `pwd` Zero_Effect best '-vf crop=720:480:0:0'" | at now Or add it to a batch and run it with other jobs dave@hammer 001 $ echo "/export/scripts/xvid-hvs `pwd` /raid/movies/Zero_Effect.avi best '-vf crop=720:480:0:0'" >> ~/batch.txt and later run them all at 1am while I am sleeping: dave@hammer 001 $ at -f ~/batch.txt 01:00 here is xvid-hvs: #!/bin/tcsh # ${1}=path to vobs # ${2}=filename # ${3}=hvs matrix # ${4}=extra options eg -vf crop cd ${1} @ br=`cat bitrate` echo "`date` ${2} start encoding" >> encode.log cat *.vob | mencoder -o /dev/null -ofps 23.976 -ovc xvid -xvidencopts pass=1:packed=1:vhq=1:quant_intra_matrix=/export/scripts/hvs-${3}.intra.txt:quant_inter_matrix=/export/scripts/hvs-${3}.inter.txt:autoaspect ${4} -aid 128 -oac copy - echo "`date` ${2} Pass 1 complete" >> encode.log cat *.vob | mencoder -o ${2} -ofps 23.976 -ovc xvid -xvidencopts pass=2:packed=1:vhq=1:bitrate=$br\:quant_intra_matrix=/export/scripts/hvs-${3}.intra.txt:quant_inter_matrix=/export/scripts/hvs-${3}.inter.txt:autoaspect ${4} -aid 128 -oac copy - echo "`date` ${2} Finished encoding" >> encode.log Last edited by evade; 2nd March 2004 at 15:39. |
|
|
|
|
|
#2 | Link |
|
Registered User
Join Date: May 2002
Posts: 308
|
- One of the main filter developers always suggests to crop at x16 boundaries (if necessary) to prevent the misalignment of the chroma plane, even at the expense of few rows of film.
- I never saw any difference between vhq=1 and vhq=0 (that is much faster). - actually xvid encodes 2 b frames by default; I often saw bad things with b-frames enabled |
|
|
|
|
|
#3 | Link |
|
Registered User
Join Date: Nov 2003
Posts: 97
|
Thank you unixfs, exactly the kind of feedback I was hoping for.
So that is multiples of 16 for width and height? If cropdetect says: (-vf crop=718:346:0:66) would you do -vf crop=720:336:0:66 ? At some point the xvid/mencoder module developers developers made vhq=1 and 2 bframes the default. I will do some tests and see which I prefer. Have you noticed any differences going higher like vhq=2 or vhq=4? |
|
|
|
|
|
#4 | Link | ||
|
Registered User
Join Date: May 2002
Posts: 308
|
Quote:
be x16m but the offsets too (that's why I was talking of chroma plane misalignment) Quote:
|
||
|
|
|
|
|
#5 | Link |
|
Registered User
Join Date: May 2002
Posts: 308
|
Sorry, wrong informations.
This thread in enlightening (esp. the first answer) http://www.mplayerhq.hu/pipermail/mp...ch/043325.html So cropping offsets should be simply even for horizontal and x4 (in case of interlaced or telecined content) for vertical resolution. |
|
|
|
|
|
#6 | Link |
|
Registered User
Join Date: Nov 2003
Posts: 97
|
I have been reading a bunch on the mplayer user list, this thread and others. The rules to follow seem to be:
1) crop the movie at even numbers. 2) offsets must be even. (except for interlaced content, which must be by 4) 3) The movie you encode should have width and height in multples of 16. following these guidlines with a cropdetect result of -vf crop=718:346:0:66. I want to encode at multiples of 16 height and width. I can reach that goal through any combination of cropping and scaling. The autoaspect option tracks the filter chain and preserves my aspect ratio. so I could do this: -sws 9 -vf crop=718:346:0:66,scale=704:336:0:1 This would produce a movie without any black bars that preserves all of the visible image at the closest possible to original resolution and also one that would play back perfectly fine on MPlayer or on my XBOX or on Videolan Player. Granted it would look really funny if someone tried to play it on Windows Media Player Am I on the right track or am I blathering? Last edited by evade; 3rd March 2004 at 00:23. |
|
|
|
|
|
#8 | Link |
|
Registered User
Join Date: May 2002
Posts: 308
|
Right track, but 346 doesn't divide by 4, so if you video is interlaced
you might have some problem. Generally it's better to crop a little more than a little less in order to avoid high contrast at the borders of the movie. |
|
|
|
|
|
#9 | Link |
|
Registered User
Join Date: Nov 2003
Posts: 97
|
Interlaced is a whole different story for sure. different scripts entirely. Most of what I encode is non-interlaced.
I will probably as a rule of thumb take the cropdetect result and round down to the nearest multiple of 16. If I it looks like I am losing too much picture I will crop and scale instead. If you haven't tried b-frames with xvid recently you might want to give them another shot. I think they affect the picture favorably. Thanks for your insights with the cropping. PS I think I have been on the commandline too much, I find myself trying to submit my post by hitting [esc] [colon] wq [enter] |
|
|
|
|
|
#10 | Link |
|
Registered User
Join Date: Nov 2003
Posts: 97
|
Sometimes libavcodec does a better job than XviD. Here is a script that I used for lavc encoding with hvs-best quant matrix that beat out XviD encoding Lost in Translation. Lavc produced a much cleaner picture, It smoothed some detail but produced alot less noise.
#!/bin/tcsh # ${1}=path to vobs # ${2}=filename # ${3}=vf crop cd ${1} @ br=`cat bitrate` echo "`date` ${2}.avi start encoding" >> encode.log cat *.vob | mencoder -o /dev/null -ofps 23.976 -ovc lavc -lavcopts inter_matrix=18,18,18,18,19,21,23,27,18,18,18,18,19,21,24,29,18,18,19,20,22,24,28,32,18,18,20,24,27,30,35,40,19,19,22,27,33,39,46,53,21,21,24,30,39,50,61,73,23,24,28,35,46,61,79,98,27,29,32,40,53,73,98,129:intra_matrix=8,16,16,16,17,18,21,24,16,16,16,16,17,19,22,25,16,16,17,18,20,22,25,29,16,16,18,21,24,27,31,36,17,17,20,24,30,35,41,47,18,19,22,27,35,44,54,65,21,22,25,31,41,54,70,88,24,25,29,36,47,65,88,115:vpass=1:vbitrate=$br\:v4mv:vmax_b_frames=2:vhq:trell:autoaspect ${3} -aid 128 -oac copy - echo "`date` ${2}.avi Pass 1 complete" >> encode.log cat *.vob | mencoder -o ${2}.avi -ofps 23.976 -ovc lavc -lavcopts inter_matrix=18,18,18,18,19,21,23,27,18,18,18,18,19,21,24,29,18,18,19,20,22,24,28,32,18,18,20,24,27,30,35,40,19,19,22,27,33,39,46,53,21,21,24,30,39,50,61,73,23,24,28,35,46,61,79,98,27,29,32,40,53,73,98,129:intra_matrix=8,16,16,16,17,18,21,24,16,16,16,16,17,19,22,25,16,16,17,18,20,22,25,29,16,16,18,21,24,27,31,36,17,17,20,24,30,35,41,47,18,19,22,27,35,44,54,65,21,22,25,31,41,54,70,88,24,25,29,36,47,65,88,115:vpass=2:vbitrate=$br\:v4mv:vmax_b_frames=2:vhq:trell:autoaspect ${3} -aid 128 -oac copy - echo "`date` ${2}.avi Finished encoding" >> encode.log Last edited by evade; 4th March 2004 at 04:53. |
|
|
|
|
|
#11 | Link |
|
yakisoooobaaa!!
Join Date: Sep 2003
Location: Greece
Posts: 329
|
Concerning XviD and VHQ:
You should really take a look at the new unofficial XviD FAQ: http://www.vslcatena.nl/~ronald/docs/xvidfaq.html It explains the present status of vhq. You can also find some tests portraying the impact of various vhq settings in this thread: Advantages of Trellis RD (hint: look at Soulhunter's post) I stick with at least vhq 1 (since it's now the default) I go for 4 in extreme cases... |
|
|
|
|
|
#12 | Link |
|
Registered User
Join Date: Nov 2003
Posts: 97
|
Here are the hvs quant matrices in formats to be used with Mencoder and Transcode.
The option looks like this in mencoder with xvid: quant_intra_matrix=/path/to/xvid-hvs-good.intra:quant_inter_matrix=xvid-hvs-good.inter or like this with lavc: -lavcopts inter_matrix=`cat /path/to/lavc-hvs-good.inter`:intra_matrix=`cat /path/to/lavc-hvs-good.intra` Here are the files: http://69.13.241.21/hvsquants.tar.bz2 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|