[x264-devel] Rescaling in real-time

Diego Carvalho Domingos diego.cdomingos2010 at gmail.com
Mon Jun 6 16:28:30 CEST 2011


I have a complex task to do. I'm receiving h264 rtp packets from the
internet and I need to change their resolution before forwarding them.
I've created a class to create a frame from the packets, decode it
with libavcodec, rescale it with libswscale, reencode it with libx264
and finally convert the frame to packets again and forward them. It's
working (altough with medium quality) but I don't know if this is the
best solution to achieve my goal (this approach uses a lot of CPU
process time). Is there a way to rescale a h264 frame without decoding
it? Another issue is that I am not sure about the parameters I am
using to encode (I couldn't find much information about this on the
internet) and I think that it is the reason of the medium quality
video:

param = new x264_param_t;
x264_param_default_preset(param, "veryfast", "zerolatency");
param->i_threads = 2;
param->i_width = m_OutWidth;
param->i_height = m_OutHeight;
param->i_fps_num = 25;
param->i_fps_den = 1;
// Intra refres:
param->i_keyint_max = 25;
param->b_intra_refresh = 1;
//Rate control:
param->rc.i_rc_method = X264_RC_CRF;
param->rc.f_rf_constant = 25;
param->rc.f_rf_constant_max = 35;
//For streaming:
param->b_repeat_headers = 1;
param->b_annexb = 1;
x264_param_apply_profile(param, "baseline");
x264_encoder = x264_encoder_open(param);

pic_in = new x264_picture_t;
x264_picture_alloc(pic_in, X264_CSP_I420, m_OutWidth, m_OutHeight);
pic_in->i_type = X264_TYPE_AUTO;
pic_in->i_qpplus1 = 0;

What would be the best parameters? I appreciate any help or suggestions. Thanks.


More information about the x264-devel mailing list