[x264-devel] Reconfiguring x264 aspect ratio in the middle of stream

Jarmo Torvinen jarmo.torvinen at jutel.fi
Wed Jan 7 07:56:26 CET 2009


Is it possible to change the aspect ratio (x264_param_t.vui.i_sar_width & 
height) after the encoder
has been initialized with the x264_encoder_open()-call?

There is the x264_encoder_reconfig()-call but while inspecting the source 
it seems that the vui*-parameters are
not copied in that function call. 

Further down, the aspect_ratio_idc seems to be written at the 
x264_sps_write() call in encoder 
x264_encoder_encode():

    /* Write SPS and PPS */
    if( i_nal_type == NAL_SLICE_IDR && h->param.b_repeat_headers )
    {
        ...
 
        /* generate sequence parameters */
        x264_nal_start( h, NAL_SPS, NAL_PRIORITY_HIGHEST );
        x264_sps_write( &h->out.bs, h->sps );
        x264_nal_end( h );


x264_param_default() sets the b_repeat_headers to 1, so the SPS is written 
again by default for each IDR. 


The whole point of this exercise would be to be able to reconfigure the 
aspect ratio of x264 in the middle of the stream. 
This happens for example in DVB-streams and when transcoding the DVB MPEG2 
to 264, it would be nice 
to automatically to preseve the correct aspect ratio. Any pointers to 
correct direction would be appreciated, 
I'm ready to contribute patches.


Jarmo Torvinen


More information about the x264-devel mailing list