[x264-devel] Reconfiguring x264 aspect ratio in the middle of stream
Jarmo Torvinen
jarmo.torvinen at jutel.fi
Mon Jan 12 10:12:31 CET 2009
>
> Jarmo Torvinen a écrit :
> > 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.
>
> [...]
>
> > I'm ready to contribute patches.
>
> That would be a handy features, as there are many ATSC/DVB cases where
> this would be usefull. Would you like to try implementing this?
>
Sure, actually I have already made a proof-of-concept style modification
which seems to work. I'm using
to to change dynamically the aspect ratio of the video while transcoding
from a DVB ts stream to a ts containing
h264 video content.
The POC contains modifications to
-x264 encoder/encoder.c,
-ffmpeg/libavcodec/libx264.c,
-ffmpeg/libavcodec/h264.c
-ffmpeg/ffmpeg.c
The modification to the x264 encoder part is really small, actually only
couple of lines:
// add these lines to x264_encoder_reconfig()
+ h->sps->vui.i_sar_width = h->param.vui.i_sar_width;
+ h->sps->vui.i_sar_height = h->param.vui.i_sar_height;
I see some problems with this approach:
1) it is too time consuming to call the x264_encoder_reconfig() just for
the purpose
of changing the aspect ratio, I'd rather have separate API function which
just would do that.
But on the other hand, is there enough justification to add another api
call just for that purpose?
2) is it correct way to directly to modify the h->sps.* parameters, maybe
it would be better to call
x264_sps_init() instead?
3) according to initial tests, the aspect ratio changes, but the timing is
not always correct. This is because the
aspect ratio info is sent in the SPS, so the timing depends on the timing
of the scene cut. To have correct timing,
there should be some way to force a scenecut or sending a SPS through the
API when the aspect ratio changes.
Any thoughts?
Jarmo
More information about the x264-devel
mailing list