Quantcast Mencoder: Mencoding Divxs/DVDs Using 2 Pass VBR - digitalFAQ.com Forums [Archives]
  #1  
04-09-2004, 08:56 PM
vmesquita vmesquita is offline
Invalid Email / Banned / Spammer
 
Join Date: May 2003
Posts: 3,726
Thanks: 0
Thanked 0 Times in 0 Posts
I decided to open a new thread to post this because the main mencoder thread is discussing mainly one pass VBR and DVD sources.

After some tweaking, I was able to come up with a internal filter combo that gave me results close to the ones obtained via DialHot v4 Script+CCE. CCE gave me 19 fps, while mencoder was working at 30 fps using my latest compile (posted in the main thread) optimized for my AtlhonXP. So if you consider that some time would be spent in prediction, let's say 20% of the encoding time, 2pass VBR in mencoder is taking near the same time 1passVBR takes in CCE with prediction. Seems very good, considering that the results are nice good, and CCE used to be the fastest encoder around.
Plus Mencoder has the advantage of using longer GOPs, while CCE only allows up to 15. If you're in NTSC you can go up to 18 without breaking the standard.

So this is avi.ini we are going to use for both passes, for DivX/XVid sources:
Code:
of=rawvideo=1
ovc=lavc=1
nosound=1
noskip=1
vf=yuvcsp,pp=hb:100:100/vb/dr,hqdn3d=10:0:5,scale=480:352:0:0:7,noise=5u,expand=480:480
sws=9
lavcopts=vcodec=mpeg2video:vrc_eq=tex:vmax_b_frames=2:
vrc_maxrate=9800:keyint=18:vrc_buf_size=1835:preme=2:precmp=2:
vstrict=-1:autoaspect=1:scplx_mask=0.3:vqblur=0:mbqmin=1:vqmin=1:
mbqmin=1:lmin=1:intra_matrix=8,9,12,22,26,27,29,34,9,10,14,26,27,29,
34,37,12,14,18,27,29,34,37,38,22,26,27,31,36,37,38,40,26,27,29,36,39,
38,40,48,27,29,34,37,38,40,48,58,29,34,37,38,40,48,58,69,34,37,38,40,
48,58,69,79:inter_matrix=16,18,20,22,24,26,28,30,18,20,22,24,26,28,30,
32,20,22,24,26,28,30,32,34,22,24,26,30,32,32,34,36,24,26,28,32,34,34,
36,38,26,28,30,32,34,36,38,40,28,30,32,34,36,38,42,42,30,32,34,36,38,
40,42,44
ofps=23.976
fps=23.976
This is the dvd.ini for DVD sources:
Code:
of=rawvideo=1
ovc=lavc=1
nosound=1
noskip=1
vf=filmdint,yuvcsp,scale=704:352:0:0:5,expand=704:480
sws=9
lavcopts=vcodec=mpeg2video:vrc_eq=tex:vmax_b_frames=2:
vrc_maxrate=9800:keyint=18:vrc_buf_size=1835:preme=2:precmp=2:
vstrict=-1:autoaspect=1:scplx_mask=0.3:vqblur=0:mbqmin=1:vqmin=1:
mbqmin=1:lmin=1:intra_matrix=8,9,12,22,26,27,29,34,9,10,14,26,27,29,
34,37,12,14,18,27,29,34,37,38,22,26,27,31,36,37,38,40,26,27,29,36,39,
38,40,48,27,29,34,37,38,40,48,58,29,34,37,38,40,48,58,69,34,37,38,40,
48,58,69,79:inter_matrix=16,18,20,22,24,26,28,30,18,20,22,24,26,28,30,
32,20,22,24,26,28,30,32,34,22,24,26,30,32,32,34,36,24,26,28,32,34,34,
36,38,26,28,30,32,34,36,38,40,28,30,32,34,36,38,42,42,30,32,34,36,38,
40,42,44
ofps=23.976
fps=29.97
dvd-device=f:
Of course, scale, expand, dvd-device and must be replaced with the correct values. B-Frames are working.

Command-lines for AVI:
Code:
mencoder -include avi.ini -lavcopts vbitrate=1500:vpass=1 MyAVIMovie.AVI -o 1pass.m2v
mencoder -include avi.ini -lavcopts vbitrate=1500:vpass=2 MyAVIMovie.AVI -o 2pass.m2v
Command-lines for DVD:
Code:
mencoder -include dvd.ini -lavcopts vbitrate=1500:vpass=1 dvd://1 -o 1pass.m2v
mencoder -include avi.ini -lavcopts vbitrate=1500:vpass=2  dvd://1 -o 2pass.m2v
Replace 1500 with the bitrate wanted, and in dvd://1, replace 1 with the VTS number (check using DVDDecrypter in which VTS the movie is)

This filtering can of course be improved, I am just putting my latest combination for AVIs. The DVD settings does not filter at all, this can be of course improved. The settings used are basically the latest from bilu in the main mencoder thread.

I am really thinking about implementing this in DIKO now!

<edit> Improved settings.
<edit2> forgot vrc_buf_size setting.
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Site Staff / Ad Manager
 
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
04-09-2004, 09:10 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by vmesquita

I am really thinking about implementing this in DIKO now!
The future looks bright

-kwag
Reply With Quote
  #3  
04-10-2004, 04:27 AM
rds_correia rds_correia is offline
Free Member
 
Join Date: Apr 2003
Location: Chinese Democracy starts now!
Posts: 2,563
Thanks: 1
Thanked 0 Times in 0 Posts
Hya,
Nice to see you're working with other mencoder possibilities, like 2-pass.
Hope Diko can get faster with Mencoder
I just would like them to check the rate control...and we (1-pass guys) would be back in biz.
P.S.-How did you check B-frames were ok? looking at BV?
Cheers
__________________
Rui
Reply With Quote
  #4  
04-10-2004, 08:18 AM
jorel jorel is offline
Invalid Email / Banned / Spammer
 
Join Date: Aug 2002
Location: Brasil - MG - third stone from the sun
Posts: 5,570
Thanks: 0
Thanked 0 Times in 0 Posts


MenDIKO
Reply With Quote
  #5  
04-10-2004, 08:32 AM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by jorel


MenDIKO


Then followed by "MenDikumcizer" HAHAHA

-kwag
Reply With Quote
  #6  
04-10-2004, 08:52 AM
vmesquita vmesquita is offline
Invalid Email / Banned / Spammer
 
Join Date: May 2003
Posts: 3,726
Thanks: 0
Thanked 0 Times in 0 Posts


@rds_correa
B-Frames are OK, I checked in BV. But you have to use them in both passes, if you specify b-frames only in second pass, it doesn't work.
Reply With Quote
  #7  
04-10-2004, 10:33 AM
digitall.doc digitall.doc is offline
Free Member
 
Join Date: Jul 2003
Location: Valencia (España)
Posts: 741
Thanks: 0
Thanked 0 Times in 0 Posts
vmesquita,
just to make sure I understood your way... First pass you make it with constant quantizer (vqscale=1), but, doesn't it make useless vqmin and lmin parameters? I mean, since quantizers are fixed with vqscale, there'd be no need to set qmin and lmin.
And secong pass you make it with vqcomp=1:vqmin=1:mbqmin=1:lmin=1 (that is, constant quality) with vbitrate=1500. That's OK. But I thought we'd better use similar settings in frist and second pass, and from first to second you change your way...
Anyway, in first pass you keep quantizers at 1 (and I can imagine very high bitrate peaks) and in second pass you set a high constant quality setting, and a vbitrate value to moderate those high bitrate peaks and get a good final quality... is that a possible explanation of your way?. Tell me about your output: what bitrate and what Q value do you get with tihs approach?.
Reply With Quote
  #8  
04-10-2004, 10:47 AM
vmesquita vmesquita is offline
Invalid Email / Banned / Spammer
 
Join Date: May 2003
Posts: 3,726
Thanks: 0
Thanked 0 Times in 0 Posts
digitall.doc,

Thanks for your observations. Actually I just grabbed Bilu latest settings and did a few modifications for 2-pass. I am not really sure about how most of the parameters work.

The idea of doing first pass with vqscale=1 I took from XVid, I read somewhere that it is done that way now. But I am no t sure about that.
About your explanation: that's what I expected to get and I had good results yesterday. But I am testing a DVD source right now, and mencoder is not following the bitrate I asked... I am using vbitrate 1500 and it's coming 2000... I'll try with the default settings and vbitrate in first pass, maybe rate control is really broken.
Reply With Quote
  #9  
04-10-2004, 11:07 AM
digitall.doc digitall.doc is offline
Free Member
 
Join Date: Jul 2003
Location: Valencia (España)
Posts: 741
Thanks: 0
Thanked 0 Times in 0 Posts
vmesquita,
don't erase the first pass video file, and make sure if it was encoded at constant Q value of 1.
From bilu advise, I understood that you had to keep the same parameters in first and second pass, but in first pass you use vqscale=2 (1 is not advised in man_page, but also wasn't for vqmin and lmin... ) that is substituted by vbitrate in second pass. And I would also test with and without vqblur in second pass (just an idea, to see if mencoder can adjust better bitrate with some quantizer delay)
Reply With Quote
  #10  
04-10-2004, 12:30 PM
vmesquita vmesquita is offline
Invalid Email / Banned / Spammer
 
Join Date: May 2003
Posts: 3,726
Thanks: 0
Thanked 0 Times in 0 Posts
I found out the problem. Looks like vrc_max_rate is broken in current CVS, using it causes many problems. Another interesting thing: using the goal vbitrate in first pass instead of vscale=1 gives better quality. Check this:

http://www.jltoca.uaivip.com.br/images/cqvsfixed1.png
http://www.jltoca.uaivip.com.br/images/cqvsfixed3.png
http://www.jltoca.uaivip.com.br/images/cqvsfixed4.png
http://www.jltoca.uaivip.com.br/imag...ed5-smooth.png

Doing a constant quality first pass causes less smoothing in calm scenes, but on the other hand, more blockness in action scenes. Now let's see how 1pass with vbitrate and the rest of the settings the same as 2pass compare:

http://www.jltoca.uaivip.com.br/images/1passvs2pass.png
http://www.jltoca.uaivip.com.br/imag...ssvs2pass2.png
http://www.jltoca.uaivip.com.br/imag...ssvs2pass3.png

I'll edit the first post with the working settings.
Reply With Quote
  #11  
04-10-2004, 02:58 PM
digitall.doc digitall.doc is offline
Free Member
 
Join Date: Jul 2003
Location: Valencia (España)
Posts: 741
Thanks: 0
Thanked 0 Times in 0 Posts
sorry vmesquita, didn't understand your last post.
So you're now using the same settings in first and second pass, isn't it?. Instead of vqscale in first pass and vbitrate in second pass, you use vbitrate in both pass... did I understand you well?. Ok, and you get better quality. Nice. And you adjust quantizers through the same settings in first and second pass, with vqmin:lmin:mbqmin... Looks nice.
In your settings I just miss the rate control mode: if you don't set vqcomp=1, default is vqcomp=0.5, and that isn't constant quality. Check if in your tests you used vqcomp=1, and if not (and if you have time ) redo your test with vqcomp=1 and tell us the output.
How does it look the first pass file?, is it veeeery big?, does it give quality enough to avoid second pass? I guess not, due to impossibility to respect vbitrate in 1 pass.
In this two pass tests, did you get the desired average bitrate?. Is it good the bitrate allocation?.
I see you're not using trellis quantitation, nor mbd=2. They made wonders in my 1pass tests. But maybe in 2pass we can drop them (at least trell, that slows down encoding.... or not that much?. Did you test with and without it?).
And, finally (by now ), tell us something about the filters you're using. Maybe it isn't necessary at all to use scplx_mask.
Sorry if I ask you a lot, but I don't have now many time, and my computer is faaaar slooow (I'm taking profit of your tests )
Reply With Quote
  #12  
04-10-2004, 03:28 PM
vmesquita vmesquita is offline
Invalid Email / Banned / Spammer
 
Join Date: May 2003
Posts: 3,726
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by digitall.doc
So you're now using the same settings in first and second pass, isn't it?.
Instead of vqscale in first pass and vbitrate in second pass, you use vbitrate in both pass... did I understand you well?. Ok, and you get better quality. Nice. And you adjust quantizers through the same settings in first and second pass, with vqmin:lmin:mbqmin... Looks nice.
Yes, you got all this right.
Quote:
In your settings I just miss the rate control mode: if you don't set vqcomp=1, default is vqcomp=0.5, and that isn't constant quality. Check if in your tests you used vqcomp=1, and if not (and if you have time ) redo your test with vqcomp=1 and tell us the output.
I'll try that. Actually I was revising Bilu settings just now, and discovered I forgot about rate control (vrc_eq), I was using the default settings. Using vrc_eq=AvgTex is sbout the same thing, since the original equation is Tex^vqcomp. I am also testing with naq=1;
Quote:
How does it look the first pass file?, is it veeeery big?, does it give quality enough to avoid second pass? I guess not, due to impossibility to respect vbitrate in 1 pass.
In this two pass tests, did you get the desired average bitrate?. Is it good the bitrate allocation?.
Using vqscale, it's very big. Using vbitrate, the average asked is more or less achived (I ask 1500 and get 1490 or 1510). Actually there's no problem with vrc_maxrate, I just tested in both passes and it's working fine, I don't know what was broken before because I tested so many settings today...
1 Pass didn't look bad. But it does what you can expect from a encoder that doesn't know what comes next: smooth less in calm scenes and block more in action scenes. I think the second pass is worth it (you saw the screenshots)

Quote:
I see you're not using trellis quantitation, nor mbd=2. They made wonders in my 1pass tests. But maybe in 2pass we can drop them (at least trell, that slows down encoding.... or not that much?. Did you test with and without it?).
No I didn't. I just used mainly bilu settings.
Quote:
And, finally (by now ), tell us something about the filters you're using. Maybe it isn't necessary at all to use scplx_mask.
The filters I posted are for AVI only. They do post-processing, then a temporal and spatial denoise in chorma, and then add some uniform noise to avoid the DCT killed to come back. It's about what DialHot V4 script for AVI does (which was my inspiration). And of course there's the resizing.
I don't know exactly what scplx_mask is for, maybe it's not needed after all.
Quote:
Sorry if I ask you a lot, but I don't have now many time, and my computer is faaaar slooow (I'm taking profit of your tests )
Be my guest.

Edit: just tested with naq and vrc_eq=AvgTex. It looks much worse, some scenes are completelly distorted.
Edit2: naq alone made some parts better, some other parts worse. I don't think it's worth using.
Edit3: vrc_eq=avgTex also helpend in some parts and made others worse .
Reply With Quote
  #13  
04-10-2004, 05:31 PM
digitall.doc digitall.doc is offline
Free Member
 
Join Date: Jul 2003
Location: Valencia (España)
Posts: 741
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by vmesquita
Edit: just tested with naq and vrc_eq=AvgTex. It looks much worse, some scenes are completelly distorted.
Edit2: naq alone made some parts better, some other parts worse. I don't think it's worth using.
Edit3: vrc_eq=avgTex also helpend in some parts and made others worse .
I advise you to use vqcomp=1 or vrc_eq=tex (it's the same) that gives, in theory, the best quality. And I think that bilu tested it and came to this same conclusion. Not vrc_eq=avgTex.
And give mbd=2 and mv0=1 a shot. I don't dare to suggest you again trell... maybe I'll test by myself before asking you such a slow (in theory) thing.
Quote:
Originally Posted by vmesquita
The filters I posted are for AVI only. They do post-processing, then a temporal and spatial denoise in chorma, and then add some uniform noise to avoid the DCT killed to come back. It's about what DialHot V4 script for AVI does (which was my inspiration). And of course there's the resizing.
Do you think you could do a similar work with the MA script?. I've been thinking about it, as there are spatial and temporal filters. But I don't find anything similar to undot, and don't see how can we make a motion-adaptive routine... Anyway, for KDVD, with DVD as a source, we don't usually use the MA script, but something smoother (like undot, STMedianfilter with low parameters, light TemporalSoftening,...).
Quote:
Originally Posted by vmesquita
Be my guest.
You're really kind, man. You make me feel at home.
Reply With Quote
  #14  
04-10-2004, 05:47 PM
bilu bilu is offline
Free Member
 
Join Date: Jan 2004
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
@vmesquita

Not all my mencoder testings are on the same thread

My new settings, with BV screenshots **LATEST**
http://www.kvcd.net/forum/viewtopic.php?t=10132

Mencoder ratecontrol
http://www.kvcd.net/forum/viewtopic.php?t=10101

Set of 4 Mencoder tests: mind borrowing us some CPU?
http://www.kvcd.net/forum/viewtopic.php?t=9759

Need help on becoming practical
http://www.kvcd.net/forum/viewtopic.php?t=9260


Bilu
Reply With Quote
  #15  
04-10-2004, 05:57 PM
bilu bilu is offline
Free Member
 
Join Date: Jan 2004
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
naq is only needed when using *_mask settings.

If you use lmin=2:scplx_mask=0.3 or lmin=1:scplx_mask=0.4 (maximum acceptable values on video for me, not anime) ***WITHOUT*** naq, you can considerably lower the bitrate. If you use naq, avg bitrate can become bigger than when not using *_mask settings at all

About vrc_eq settings, I only use vrc_eq=tex now.


Bilu
Reply With Quote
  #16  
04-10-2004, 06:08 PM
bilu bilu is offline
Free Member
 
Join Date: Jan 2004
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
Test proposal for 2-pass encoding:

1st pass without B-frames, 2nd with B-frames.

Since B-frames are generated from info from the previous and next frames it shouldn't affect quality and should be faster.

Inspired on XVID's Turbo Mode: 1-pass disable some search techniques used by QuarterPixel (MPEG-4 only) and B-frames.


Bilu
Reply With Quote
  #17  
04-10-2004, 06:19 PM
vmesquita vmesquita is offline
Invalid Email / Banned / Spammer
 
Join Date: May 2003
Posts: 3,726
Thanks: 0
Thanked 0 Times in 0 Posts
@digitall.doc
vrc_eq=tex improved quality. Finaly! Tested many things: naq=1, mbd=1, mbd=2, trellis, mbcmp=6, mbcmp=2, encoding without b-frames. They all make quality worse or slighlly better in some parts and worse in others. I'll try mv0=1 (looks like your tips are hot)
MA is not possible with the current filters, since you can't vary their streight according to the ammount of action, which is the idea of MA... But maybe we can find a good static filtering combo to get more compressibility.

@bilu
Thanks, looks like I missed some threads. I tried naq with scplx_mask=0.3:vqblur=0:mbqmin=1:lmin=2.49 and didn't like the results. I'll try "lmin=1:scplx_mask=0.4" as you suggested.
Doing first pass without bframes doesn't work: in the second pass bframes are not created
Reply With Quote
  #18  
04-10-2004, 06:32 PM
bilu bilu is offline
Free Member
 
Join Date: Jan 2004
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by vmesquita
Doing first pass without bframes doesn't work: in the second pass bframes are not created
Maybe I'm completely wrong and that's not way that the Turbo mode works

Bilu
Reply With Quote
  #19  
04-10-2004, 06:36 PM
bilu bilu is offline
Free Member
 
Join Date: Jan 2004
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by vmesquita
@digitall.doc
vrc_eq=tex improved quality. Finaly! Tested many things: naq=1, mbd=1, mbd=2, trellis, mbcmp=6, mbcmp=2, encoding without b-frames. They all make quality worse or slighlly better in some parts and worse in others. I'll try mv0=1 (looks like your tips are hot)
Have a look here also:
http://www.kvcd.net/forum/viewtopic.php?p=70130#70130


Bilu
Reply With Quote
  #20  
04-10-2004, 07:10 PM
digitall.doc digitall.doc is offline
Free Member
 
Join Date: Jul 2003
Location: Valencia (España)
Posts: 741
Thanks: 0
Thanked 0 Times in 0 Posts
Thanx vmesquita, but as bilu says these are our tips, since we all have been testing all the parameters in mencoder to take the best out of it.
And is you follow the main mencoder thread, you'll see that we dropped and then revisited lots of parameters and values.
And you're now giving it a new "empurrâo" (push) with your 2pass tests.
BTW, the results you post are always related to avi sources, or you get the same results with DVD sources?.
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Mencoder: Question about MEncoder 1 pass black prince Video Encoding and Conversion 32 06-05-2004 08:06 AM
Mencoder: Mencoder two-pass encoding questions Prodater64 Video Encoding and Conversion 13 05-05-2004 03:33 PM
Mencoder: Changing/Setting field order in mencoder tuco1979 Video Encoding and Conversion 1 04-17-2004 09:06 AM
FFMPEG: Mencoder 2-pass japie Video Encoding and Conversion 9 11-04-2003 09:20 AM
Encoding single-pass KVCD vs. two-pass logan555 Video Encoding and Conversion 1 12-04-2002 09:18 AM

Thread Tools



 
All times are GMT -5. The time now is 11:42 PM  —  vBulletin © Jelsoft Enterprises Ltd