[x264-devel] X264 dynamic rate control
Ralf Globisch
rglobisch at csir.co.za
Thu Nov 5 10:07:26 CET 2015
Hi,
I'm experimenting with x264 rate control, specifically with changing the target rate to adapt to network congestion.
>From what I've read (http://forum.doom9.org/archive/index.php/t-153168.html), this should be possible by doing the following:
On initialisation:
x264_param_t p;
x264_param_default_preset(&p, "ultrafast", "zerolatency");
p.i_threads = 1;
p.i_width = _width;
p.i_height = _height;
p.i_fps_num = _fps;
p.i_fps_den = 1;
p.i_log_level = X264_LOG_DEBUG;
p.rc.i_rc_method = X264_RC_ABR ;
p.rc.i_bitrate = bitrate_kbps;
p.i_nal_hrd = X264_NAL_HRD_CBR;
p.rc.i_vbv_buffer_size = bitrate_kbps;
cbr_factor = 0.8;
p.rc.i_vbv_max_bitrate = bitrate_kbps * cbr_factor;
encoder = x264_encoder_open(&p)
And then to change rate at some time later:
x264_param_t p;
x264_encoder_parameters( encoder, &p );
p.rc.i_bitrate = new_bitrate_kbps;
p.rc.i_vbv_buffer_size = new_bitrate_kbps;
p.rc.i_vbv_max_bitrate = new_bitrate_kbps *cbr_factor;
int res = x264_encoder_reconfig(encoder, &p);
x264_encoder_reconfig doesn't return an error, but there seems to be no effect on bitrate.
Using a test sequence of 300 frames, if the starting bitrate is 100 kbps, and I switch to 200 kbps at frame 150,
there is no noticeable adjustment in encoded frame size, and x264 outputs close to the starting bitrate when it finishes.
Is there something (obviously) wrong in the configuration?
Thanks for any input.
Ralf
--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard.
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.
This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean.
Please consider the environment before printing this email.
More information about the x264-devel
mailing list