View Full Version : How to reduce the frame size when encode a high-motion(or new scene) scene for x264?
TommySailing
14th May 2009, 15:11
When a high-motion scene or new scene appear,the encoded frame size is very high(about 3 times of average size). But our application want to get a stable output stream size even losing the image quality.
My question is, how to ensure the encoded frame size more stable(I know it must be more than the average frame size in such case,but I hope it's not so high)? I know that "Ratecontrol returns one QP which is used for the whole frame",is there any way to enlarge the QP in such case? Is the QP decided by the SATD? What's the flowchart of this operation?
I just begin to study the X264 recently, and don't have any document about this.
Thanks a lot!
Dark Shikari
14th May 2009, 15:37
This is what VBV is for.
TommySailing
15th May 2009, 14:16
This is what VBV is for.
But we are using ABR. Is there a way to reduce the frame size in ABR mode?
Dark Shikari
15th May 2009, 14:20
But we are using ABR. Is there a way to reduce the frame size in ABR mode?But our application want to get a stable output stream size even losing the image quality.Your two requests seem to conflict. What you're stating there implies you want CBR, or at least capped ABR.
TommySailing
16th May 2009, 11:49
Your two requests seem to conflict. What you're stating there implies you want CBR, or at least capped ABR.
Thanks!
Yes, we want capped ABR. I saw a article about X264 rate control which give a way that self-adapting chagine the QP of mb according to rate of the SATD of the current encoded mb and the SATD of the whole frame. I think this a good way to reduce the frame size when a high-motion or new scene frame appear,because we can enlarge the QP according to the SATD rate. But I don't know where calculate the SATD of the current encoded mb and how to get the SATD of the whole frame in the source code of X264. I'm not familiar with the source code :(
Dark Shikari
16th May 2009, 11:53
Thanks!
Yes, we want capped ABR. I saw a article about X264 rate control which give a way that self-adapting chagine the QP of mb according to rate of the SATD of the current encoded mb and the SATD of the whole frame. I think this a good way to reduce the frame size when a high-motion or new scene frame appear,because we can enlarge the QP according to the SATD rate. But I don't know where calculate the SATD of the current encoded mb and how to get the SATD of the whole frame in the source code of X264. I'm not familiar with the source code :(You seem to be confused. You don't need to know anything about the source code for this. You are describing, in an incredibly oversimplified manner, how x264 already works.
x264 already supports capped ABR in the form of VBV. All capped ABR schemes can be represented using a bitrate, bufsize, and maxrate. You don't need to figure out how to add support yourself, given that it already exists.
Read the manual.
TommySailing
18th May 2009, 08:25
You seem to be confused. You don't need to know anything about the source code for this. You are describing, in an incredibly oversimplified manner, how x264 already works.
x264 already supports capped ABR in the form of VBV. All capped ABR schemes can be represented using a bitrate, bufsize, and maxrate. You don't need to figure out how to add support yourself, given that it already exists.
Read the manual.
I used '--vbv-bufsize' to limit the max frame size,it works. But it have some vibration(One frame size is greater than average bitrate,then next frame size less than average bitrate.) for the frame size when some high-motion scenes appeared. I used these build options simply: x264 -b 0 -B 384 --vbv-bufsize 45 -o Bus_Enc.264 BUS_Cut.yuv 352x288 . Is there any improvement for my build options? I tried to use '--vbv-maxrate' and '--vbv-init',but it seems dosen't work, can we use these options and how to use it? And as for '--vbv-bufsize' option,it is explained that "Enable CBR and set size of the VBV buffer (kbit)",does it mean that CBR mode must be enabled if using this option? May it be used under ABR mode?
Another question: The 'ratecontrol.txt' under directory "x264-snapshot-20090501-2245\doc\" says: "H.264 allows each macroblock to have a different QP. x264 does not do so. Ratecontrol returns one QP which is used for the whole frame." Dose it use one QP for the whole frame even using --vbv options?
Thanks a lot!
Dark Shikari
18th May 2009, 13:27
I used '--vbv-bufsize' to limit the max frame size,it works. But it have some vibration(One frame size is greater than average bitrate,then next frame size less than average bitrate.) for the frame size when some high-motion scenes appeared. I used these build options simply: x264 -b 0 -B 384 --vbv-bufsize 45 -o Bus_Enc.264 BUS_Cut.yuv 352x288 . Is there any improvement for my build options? I tried to use '--vbv-maxrate' and '--vbv-init',but it seems dosen't work, can we use these options and how to use it? And as for '--vbv-bufsize' option,it is explained that "Enable CBR and set size of the VBV buffer (kbit)",does it mean that CBR mode must be enabled if using this option? May it be used under ABR mode?
Another question: The 'ratecontrol.txt' under directory "x264-snapshot-20090501-2245\doc\" says: "H.264 allows each macroblock to have a different QP. x264 does not do so. Ratecontrol returns one QP which is used for the whole frame." Dose it use one QP for the whole frame even using --vbv options?
Thanks a lot!ratecontrol.txt is quite out of date. x264 has supported per-row ratecontrol for years.
Your options don't work because you forgot to specify maxrate.
Also, extremely small buffer sizes are not recommended. Additionally, your keyframe interval should not be smaller than (buffer size)/(maxrate).
TommySailing
20th May 2009, 14:14
ratecontrol.txt is quite out of date. x264 has supported per-row ratecontrol for years.
Your options don't work because you forgot to specify maxrate.
Also, extremely small buffer sizes are not recommended. Additionally, your keyframe interval should not be smaller than (buffer size)/(maxrate).
Thanks!
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.