[FFmpeg-devel] [RFC][PATCH] Fix timebase for filtered frames

Michael Niedermayer michaelni
Mon Nov 1 14:03:27 CET 2010


On Sat, Oct 30, 2010 at 09:53:08PM +0200, Stefano Sabatini wrote:
> On date Saturday 2010-10-30 01:53:01 -0400, Alexander Strange encoded:
> > 
> > On Oct 29, 2010, at 7:52 PM, Stefano Sabatini wrote:
> > 
> > > Check attached patch.
> > > 
> > > This is not the best solution, as one of the purposes of the timebases
> > > in the filterchain was to avoid potentially lossy PTS conversion.
> > > 
> > > For an example of a failing command try this:
> > > ffmpeg -t 5 -i INPUT -vf settb=1/100 -y OUTPUT
> > > 
> > > This actually happens only using the settb filter, but the filterchain
> > > may change anyway the timebase of the output (maybe the setpts, and
> > > the overlay, will have this power), so that needs to be fixed.
> > > 
> > > Anyway looking at the ffmpeg.c code I got lost, for example:
> > > 
> > > static double
> > > get_sync_ipts(const AVOutputStream *ost)
> > > {
> > >    const AVInputStream *ist = ost->sync_ist;
> > >    return (double)(ist->pts - start_time)/AV_TIME_BASE;
> > > }
> > > 
> > > start_time is expressed in AV_TIME_BASE, and the code seems to assume
> > > that ist->pts is also expressed in AV_TIME_BASE, which is not just the
> > > case as it is usually expressed using the timebase in
> > > ist->st->time_base.
> > 
> > ist->pts is always in AV_TIME_BASE, it's converted at the top of output_packet().
> 
> Uhm OK, so I was doing another erroneous assumption, patch updated.
>  
> > In case you want to get rid of that, here's two patches I wrote but
> > never tested beyond compiling.
> 
> Thanks, but I have enough unfinished patches queued.
> -- 
> FFmpeg = Faithless and Freak Majestic Philosophical Elaborated Gospel

>  ffmpeg.c |    5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 0e32dee9fcb4ed692c3d28a74e4043fe8c146d7d  0001-Fix-timebase-for-filtered-frames.patch
> From 12cae1a942ef87f5779ba8f2d34e0e2074a56750 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> Date: Sat, 30 Oct 2010 21:46:42 +0200
> Subject: [PATCH] Fix timebase for filtered frames.
> 
> The timebase for all the buffered frames are scaled against
> AV_TIME_BASE_Q, and need to be scaled back to AV_TIME_BASE_Q when they
> are extracted from the filterchain.
> 
> Fix timestamp computation when the timebase changes during filtering.

looks good if tested

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101101/62291b26/attachment.pgp>



More information about the ffmpeg-devel mailing list