stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Olivier Langlois <olivier@trillion01.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: m.chehab@samsung.com, linux-media@vger.kernel.org,
	linux-kernel@vger.kernel.org, Stable <stable@vger.kernel.org>
Subject: Re: [PATCH] [media] uvcvideo: Fix clock param realtime setting
Date: Fri, 28 Mar 2014 17:27:08 -0400	[thread overview]
Message-ID: <1396042028.3383.34.camel@Wailaba2> (raw)
In-Reply-To: <16236471.uFSjvbT2di@avalon>

Hi Laurent,


On Fri, 2014-03-28 at 17:20 +0100, Laurent Pinchart wrote:
> Hi Olivier,
> 
> Thank you for the patch.
> 
> On Friday 28 March 2014 01:42:38 Olivier Langlois wrote:
> > timestamps in v4l2 buffers returned to userspace are updated in
> > uvc_video_clock_update() which uses timestamps fetched from
> > uvc_video_clock_decode() by calling unconditionally ktime_get_ts().
> > 
> > Hence setting the module clock param to realtime have no effect
> > before this patch.
> > 
> > This has been tested with ffmpeg:
> > 
> > ffmpeg -y -f v4l2 -input_format yuyv422 -video_size 640x480 -framerate 30 -i
> > /dev/video0 \ -f alsa -acodec pcm_s16le -ar 16000 -ac 1 -i default \
> >  -c:v libx264 -preset ultrafast \
> >  -c:a libfdk_aac \
> >  out.mkv
> > 
> > and inspecting the v4l2 input starting timestamp.
> > 
> > Signed-off-by: Olivier Langlois <olivier@trillion01.com>
> > Cc: Stable <stable@vger.kernel.org>
> 
> Before applying this, I'm curious, do you have a use case for realtime time 
> stamps ?
> 

Yes. ffmpeg uses wall clock time to create timestamps for audio packets
from ALSA device.

There is a bug in ffmpeg describing problems to synchronize audio and
the video from a v4l2 webcam.

https://trac.ffmpeg.org/ticket/692

To workaround this issue, ffmpeg devs added a switch to convert back
monotonic to realtime. From ffmpeg/libavdevice/v4l2.c:

  -ts                <int>        .D.... set type of timestamps for
grabbed frames (from 0 to 2) (default 0)
     default                      .D.... use timestamps from the kernel
     abs                          .D.... use absolute timestamps (wall
clock)
     mono2abs                     .D.... force conversion from monotonic
to absolute timestamps

If the v4l2 driver is able to send realtime ts, it is easier synchronize
in userspace if all inputs use the same clock.

Greetings,
Olivier



  reply	other threads:[~2014-03-28 21:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-28  5:42 [PATCH] [media] uvcvideo: Fix clock param realtime setting Olivier Langlois
2014-03-28 16:20 ` Laurent Pinchart
2014-03-28 21:27   ` Olivier Langlois [this message]
2014-03-28 21:48     ` Laurent Pinchart
2014-03-29  2:50       ` Olivier Langlois
2014-03-30  4:23       ` Olivier Langlois
2014-04-01 13:49         ` Laurent Pinchart
2014-04-02  4:31           ` Olivier Langlois
2014-04-08 16:57             ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1396042028.3383.34.camel@Wailaba2 \
    --to=olivier@trillion01.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).