[FFmpeg-devel] [PATCH] Add support to video4linux2 framerate auto-set.

Stefano Sabatini stefano.sabatini-lala
Wed Jan 5 12:26:58 CET 2011

On date Wednesday 2011-01-05 08:46:05 +0100, Luca Abeni encoded:
> Hi Stefano,
> On 01/04/2011 09:52 PM, Stefano Sabatini wrote:
> >In particular, fix ffmpeg grabbing timestamps when the timebase value
> >is not set through the CLI.
> The idea looks good, but, can you move the frame rate autodetection to
> v4l2_set_parameters(), after the call to VIDIOC_S_PARM? (more precisely,
> after the "if (ap->time_base.num && ap->time_base.den)" block)
> Does it work, with such a change? (I think so, but, can you verify?)

This would require another change:
if (ap->time_base.num && ap->time_base.den) {
   // set the timebase in the driver
if (!ap->time_base.num || !ap->time_base.den) {
   // auto-select timebase and set it in the driver

which involves code duplication.

I put the framerate auto-select code just after the size auto-select
code, as that looked more symmetrical and sounded more consistent with
the overall design.

As for v4l2_set_parameters(), I suppose it should be used for setting
parameters, so the auto-selection phase should be already done when
the function is called. Currently the logic implemented is:

  1. check the size and frame rate values, if unset (i.e. if they are
     set to 0) then use the auto-select feature of the v4l driver for
     selecting the values to set

  2. set the size and frame rate values (they need to be non-0 values)

We could move 1. to v4l2_set_parameters() but I prefer to keep the two
operations in different functions.
FFmpeg = Faithless and Funny Murdering Powered Experimenting Ghost

More information about the ffmpeg-devel mailing list