stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Olivier Langlois <olivier@trillion01.com>
Cc: m.chehab@samsung.com, linux-media@vger.kernel.org,
	linux-kernel@vger.kernel.org, Stable <stable@vger.kernel.org>,
	ffmpeg-devel@ffmpeg.com
Subject: Re: [PATCH] [media] uvcvideo: Fix clock param realtime setting
Date: Tue, 08 Apr 2014 18:57:04 +0200	[thread overview]
Message-ID: <2912342.xkGF6kaQOW@avalon> (raw)
In-Reply-To: <1396412820.3383.111.camel@Wailaba2>

Hi Olivier,

On Wednesday 02 April 2014 00:31:59 Olivier Langlois wrote:
> On Tue, 2014-04-01 at 15:49 +0200, Laurent Pinchart wrote:
> > On Sunday 30 March 2014 00:23:01 Olivier Langlois wrote:
> > > > > Yes. ffmpeg uses wall clock time to create timestamps for audio
> > > > > packets from ALSA device.
> > > > 
> > > > OK. I suppose I shouldn't drop support for the realtime clock like I
> > > > wanted to then :-)
> > > > 
> > > > > 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.
> > > > 
> > > > That might be a stupid question, but shouldn't ALSA use the monotonic
> > > > clock instead ?
> > > 
> > > I think that I have that answer why ffmpeg use realtime clock for ALSA
> > > data. In fact ffmpeg uses realtime clock for every data coming from
> > > capture devices and the purpose is to be able to seek into the recorded
> > > stream by using the date where the recording occured. Same principle
> > > than a camera recording dates when pictures are taken.
> > > 
> > > now a tougher question is whether or not it is up to the driver to
> > > provide these realtime ts.
> > 
> > It makes sense to associate a wall time with recorded streams for that
> > purpose, but synchronization should in my opinion be performed using the
> > monotonic clock, as the wall time can jump around. I believe drivers
> > should provide monotonic timestamps only. However, given that the uvcvideo
> > driver has the option of providing wall clock timestamps, that option
> > should work, so your patch makes sense. I'd still like to remove support
> > for the wall clock though, but I don't want to break userspace. ffmpeg
> > should be fixed, especially given that most V4L devices provide monotonic
> > timestamps only.
>
> Please do not stop yourself to remove realtime ts support in your driver
> because that would not break ffmpeg, IMHO. It is just me that have tried
> to leverage options offered by your driver to remove the need to use
> ffmpeg workaround for a sync issue. I apparently have been the first
> ffmpeg user to try out!

Then let's fix it first, and then I'll remove the option :-)

> I am currently in the process to contribute the introduction of using
> CLOCK_MONOTONIC inside ffmpeg. CCing their list because I think your
> reply is relevant to the discussion we have on the topic there at the
> moment.

Very nice. Please keep me informed of the progress.

-- 
Regards,

Laurent Pinchart


      reply	other threads:[~2014-04-08 16:57 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
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 [this message]

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=2912342.xkGF6kaQOW@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=ffmpeg-devel@ffmpeg.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=olivier@trillion01.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).