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.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 5th April 2009, 19:06   #1  |  Link
Chengbin
Registered User
 
Join Date: Oct 2007
Posts: 1,060
I thought crf=2 pass

I encoded two videos, using the same settings, except keyint is 1000 in crf and 250 in 2 pass. The 2 pass encode is 1497Kbps and the crf is 1470kbps. I thought if the final size is the same, crf=2 pass in terms of quality. In this video, at 33:30 there is an I frame, at 33:36 there is another I frame. But I noticed that in the 2 pass encode it has another I frame at 33:32, which should have an I frame, but in the crf encode there wasn't an I frame at 33:32. This resulted in the 2 pass encoding having a higher quality image at that time, and even quite noticeable on a 5'' screen (!) . Can someone explain?
Chengbin is offline   Reply With Quote
Old 5th April 2009, 19:42   #2  |  Link
nurbs
Registered User
 
Join Date: Dec 2005
Posts: 1,460
CRF and 2 pass won't give you the same file. I think even two encodes with exactly the same settings won't result in the same file if you use multiple threads.
I remember Dark Shikari posting that the encoder uses among other things the distance of the current frame to the maximum keyframe interval to decide if it should put an I frame or not, so if thats true changing the maximum keyframe intervall should have some effect on the position of I frames. I could be wrong and maybe he said distence from the minimum keyframe interval.

Your other settings would be interesting as well.
nurbs is offline   Reply With Quote
Old 5th April 2009, 19:45   #3  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
It's also possible that on your 2nd pass, x264 determined it was (and rightfully so) beneficial to place that extra I-frame.


Have a second pass is almost always beneficial, since x264 gets a second shot at analyzing for the optimal frame placement.
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 5th April 2009, 19:47   #4  |  Link
nurbs
Registered User
 
Join Date: Dec 2005
Posts: 1,460
IIRC frametype decision is done in first pass, so frame placement doesn't change on the second.
nurbs is offline   Reply With Quote
Old 5th April 2009, 19:52   #5  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by Sagekilla View Post
It's also possible that on your 2nd pass, x264 determined it was (and rightfully so) beneficial to place that extra I-frame.
I think that x264 does the frame-type decision during the first pass and doesn't alter frame-types during the second pass.
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 5th April 2009, 19:58   #6  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
Hm, why would he get an extra I-frame in the second pass then? Could that just be from the changed keyint?
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 5th April 2009, 19:58   #7  |  Link
Chengbin
Registered User
 
Join Date: Oct 2007
Posts: 1,060
Is it good to have a high keyint value if you don't care about seeking? Correct me if I'm wrong. I think keyint x means that x is the maximum amount of frames x264 can go without putting an I frame. And seeking can only seek in I frames. Having a higher keyint value can mean higher compression because maybe in some extended static scenes x264 don't have to waste bits on another useless I frame.

I'm running another crf encode now, with keyint changed to 250, and see if it makes a difference.
Chengbin is offline   Reply With Quote
Old 5th April 2009, 20:04   #8  |  Link
nurbs
Registered User
 
Join Date: Dec 2005
Posts: 1,460
Higher keyint helps compression, but the gains get less the higher the intervall is, so the difference between say 100 and 250 is probably much higher then when you go from 250 to 1000. Also there can always be situations where the encoder puts a keyframe where it probably shoudn't.
nurbs is offline   Reply With Quote
Old 5th April 2009, 20:09   #9  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
High keyint is useful when you have sequences like a camera pan or a static scene, or even animated content. Like nurbs said though, the compression gains are usually very small. Unless you're encoding video from a security camera, there's not much to be gained from using absurdly high keyints (i.e. --keyint 9999)
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 5th April 2009, 20:13   #10  |  Link
Chengbin
Registered User
 
Join Date: Oct 2007
Posts: 1,060
IMO animated content gets some benefit using high keyint (especially Family Guy).

Here are the settings for the crf and 2 pass videos

crf

cabac=1 / ref=6 / deblock=1:-1:-1 / analyse=0x1:0x111 / me=umh / subme=9 / psy_rd=1.0:1.0 / mixed_ref=1 / me_range=32 / chroma_me=1 / trellis=2 / 8x8dct=0 / cqm=0 / deadzone=21,11 / chroma_qp_offset=-4 / threads=6 / nr=0 / decimate=1 / mbaff=0 / bframes=4 / b_pyramid=1 / b_adapt=2 / b_bias=0 / direct=3 / wpredb=1 / keyint=1000 / keyint_min=25 / scenecut=40 / rc=crf / crf=22.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / ip_ratio=1.40 / pb_ratio=1.30 / aq=1:1.00

2 pass

cabac=1 / ref=6 / deblock=1:-1:-1 / analyse=0x1:0x111 / me=umh / subme=9 / psy_rd=1.0:1.0 / mixed_ref=1 / me_range=32 / chroma_me=1 / trellis=2 / 8x8dct=0 / cqm=0 / deadzone=21,11 / chroma_qp_offset=-4 / threads=6 / nr=0 / decimate=1 / mbaff=0 / bframes=4 / b_pyramid=1 / b_adapt=2 / b_bias=0 / direct=3 / wpredb=1 / keyint=250 / keyint_min=25 / scenecut=40 / rc=2pass / bitrate=1497 / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=25000 / vbv_bufsize=14000 / ip_ratio=1.40 / pb_ratio=1.30 / aq=1:1.00

The keyint 250 crf encode will be finished in 4 hours. I'm also doing another test with that video too (how much me=tesa + p4x4 actually helps), so 2 tests in one.

I'm curious, how does x264 encode a conversation between 2 people. For example, 2 people have a conversation together, the camera switches between the 2 people say like every few seconds, same background scene every time. Does x264 use an I frame every time the camera switches to another person or will it make a reference to the frames before?

Last edited by Chengbin; 5th April 2009 at 21:18.
Chengbin is offline   Reply With Quote
Old 5th April 2009, 20:30   #11  |  Link
nurbs
Registered User
 
Join Date: Dec 2005
Posts: 1,460
Quote:
Originally Posted by Chengbin View Post
IMO animated content some some benefit using high keyint (especially Family Guy).
I guess the benefit is bigger on animation, just like it is with reference frames, but I really don't think it's significant enough to warrent the loss in seekability. Saggitaire once mentioned that the difference between a keyint of 24 and an infinite lenght would only be around 10% of the bitrate, and most of it will probably already be included if you go up to 250.
Personal opinion on tesa: not worth it, but probably also better on animation. I like umh.
nurbs is offline   Reply With Quote
Old 5th April 2009, 20:34   #12  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by Sagekilla View Post
Hm, why would he get an extra I-frame in the second pass then? Could that just be from the changed keyint?
I'm pretty sure frame-type decision happens in the first pass. That's also the reason why "--b-adapt 2" can slowdown the first pass a lot, when using a high number of b-frames, but it doesn't effect the second pass' speed. Consequently the "--keyint" and "--min-keyint" options should have no effect when "--pass 2" is specified...
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 5th April 2009 at 20:46.
LoRd_MuldeR is offline   Reply With Quote
Old 5th April 2009, 21:12   #13  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
Yes, I realize that b-adapt 2 slows down first pass. But my question is why the frame type changed from pass 1 to pass 2.
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 5th April 2009, 21:21   #14  |  Link
Chengbin
Registered User
 
Join Date: Oct 2007
Posts: 1,060
We'll find out in 2 and a half hours when the keyint 250 crf encode is done. If it puts a I frame at 33:32 like the 2 pass encode, then problem solved. But we're left with the question why does a keyint of 250 put a I frame at 33:32 between 33:30 and 33:36 when an keyint 1000 doesn't. If that crf encode still doesn't put an I frame there, then we can wonder about frame type decisions.

Maybe Dark Shikari can chime in here when he's online, hopefully, and explain this to us.

BTW, how do you know if a frame is an I frame on the computer? I use MPC-HC and it doesn't tell. I know where are the I frames because my Archos 5 only seek in I frames.

Last edited by Chengbin; 5th April 2009 at 21:26.
Chengbin is offline   Reply With Quote
Old 5th April 2009, 21:53   #15  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by Chengbin View Post
BTW, how do you know if a frame is an I frame on the computer? I use MPC-HC and it doesn't tell. I know where are the I frames because my Archos 5 only seek in I frames.
Play the stream in DGAVCIndex -or- use ffdshow's "frame type" OSD option -or- use H.264 Visa
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 5th April 2009, 22:33   #16  |  Link
nurbs
Registered User
 
Join Date: Dec 2005
Posts: 1,460
Quote:
Originally Posted by Sagekilla View Post
Yes, I realize that b-adapt 2 slows down first pass. But my question is why the frame type changed from pass 1 to pass 2.
I am pretty sure my first post in this thread explains why.
nurbs is offline   Reply With Quote
Old 5th April 2009, 23:18   #17  |  Link
kemuri-_9
Compiling Encoder
 
kemuri-_9's Avatar
 
Join Date: Jan 2007
Posts: 1,348
most of everyone is seemingly confused by his initial post of '2pass w/ keyint=250, and crf w/ keyint=1000'.

i read that as he did two completely different encodes:
one using 1pass (abr) w/ keyint 250, and then running a 2nd pass on that.
and another with crf w/ keyint 1000.

and nurbs is correct in that IDR/I frames are placed based with a decision algorithm that uses the %difference between the
(current_frame - last_I/IDR_frame) and keyint values.
I/IDR frames are more likely to be placed as the current GOP size reaches the keyint value.
this is only if scenecut is enabled though.

that's why the crf w/ keyint=1000 and 2pass w/ keyint=250 (can and did) have a difference in IDR/I frames.

and on 2nd/3rdpasses, all frame decisions are kept from the stats file as is.
the only way to change the decisions for the 2nd pass from 1st pass is to actually edit/hack the stats file before encoding the 2nd pass.
__________________
custom x264 builds & patches | F@H | My Specs

Last edited by kemuri-_9; 5th April 2009 at 23:22. Reason: typo
kemuri-_9 is offline   Reply With Quote
Old 6th April 2009, 00:01   #18  |  Link
Chengbin
Registered User
 
Join Date: Oct 2007
Posts: 1,060
OK, the CRF encode finished. The file was actually 3MB bigger. Maybe keyint 250 did that, and it also showed me=tesa and p4x4 does next to nothing.


Back to business. The new CRF encode now puts a I frame there.
Chengbin is offline   Reply With Quote
Old 6th April 2009, 00:08   #19  |  Link
nurbs
Registered User
 
Join Date: Dec 2005
Posts: 1,460
You do know that you can't take size changes in crf mode to determin wheter and how much an option increases or decreases quality, right? Has been discussed to death, use search.
nurbs is offline   Reply With Quote
Old 6th April 2009, 00:09   #20  |  Link
Chengbin
Registered User
 
Join Date: Oct 2007
Posts: 1,060
Quote:
Originally Posted by nurbs View Post
You do know that you can't take size changes in crf mode to determin wheter and how much an option increases or decreases quality, right? Has been discussed to death, use search.
Yes, but we can agree that me=tesa and p4x4 does do next to nothing.
Chengbin is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:37.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.