[FFmpeg-devel] Fwd: Fwd: libavformat/segment : add option to increment timecode

Martin Vignali martin.vignali at gmail.com
Fri Feb 5 11:41:06 CET 2016


2016-01-30 10:44 GMT+01:00 Stefano Sabatini <stefasab at gmail.com>:

> On date Friday 2016-01-29 17:38:13 +0100, Martin Vignali encoded:
> > 2016-01-29 12:35 GMT+01:00 Stefano Sabatini <stefasab at gmail.com>:
> [...]
> > > +        AVDictionaryEntry * tcr = av_dict_get(s->metadata, "timecode",
> > > NULL, 0);
> > > > +        if (tcr){
> > > > +            if (s->nb_streams > 0){
> > >
> > > > +                rate = s->streams[0]->avg_frame_rate;//Get fps from
> > > first stream
> > >
> > > this looks a bit arbitrary, why the first stream?
> > >
> > > > +                err = av_timecode_init_from_string(&tc, rate,
> > > tcr->value, s);
> > > > +                if (err < 0)
> > > > +                    return err;
> > >
> > > > +                tc.start += (int)(seg->time / 1000000.) *
> > > av_q2d(rate);//second count * fps
> > >
> > > You're losing precision here. Consider using the rescaling utilities
> > > in libavutil/mathematics.h or something like (seg->time * rate.num) /
> > > (rate.den * 1000000).
> [...]
> > Thanks you for your comments, i will make the modifications.
> >
> > For the fps issue, you're right, i use the first stream because in my
> tests
> > it's always the video stream.
> > Is there a better way, to get fps ? without choosing one of the stream ?
>
> My guess is that timecode is always related to a video stream, right?
>
> In this case you can loop through the streams and selects the first
> video stream (check also the select_reference_stream() function in
> segment.c).
>
>
I follow your proposal, and search the first video stream, to take fps.

In attach the new patch (and a documentation).

Best regards

Martin



ping
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-add-increment-timecode-option-using-segment-v2.patch
Type: application/octet-stream
Size: 3483 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160205/f8eefbc1/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-doc-for-increment_tc-in-segment.patch
Type: application/octet-stream
Size: 958 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160205/f8eefbc1/attachment-0001.obj>


More information about the ffmpeg-devel mailing list