[FFmpeg-devel] [PATCH][RFC] avcodec/avutil: Add timeline side data

Michael Niedermayer michael at niedermayer.cc
Wed Mar 28 21:12:47 EEST 2018


On Tue, Mar 27, 2018 at 08:44:01PM +0100, Derek Buitenhuis wrote:
> Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
> ---
>  libavcodec/avcodec.h |   8 +++
>  libavutil/timeline.h | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 168 insertions(+)
>  create mode 100644 libavutil/timeline.h
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 50c34db..6f54495 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1358,6 +1358,14 @@ enum AVPacketSideDataType {
>      AV_PKT_DATA_ENCRYPTION_INFO,
>  
>      /**
> +     * This side data contains timeline entries for a given stream. This type
> +     * will only apear as stream side data.
> +     *
> +     * The format is not part of the ABI, use av_timeline_* method to access.
> +     */
> +    AV_PKT_DATA_TIMELINE,
> +
> +    /**
>       * The number of side data types.
>       * This is not part of the public API/ABI in the sense that it may
>       * change when new side data types are added.
> diff --git a/libavutil/timeline.h b/libavutil/timeline.h
> new file mode 100644
> index 0000000..f1f3e1b
> --- /dev/null
> +++ b/libavutil/timeline.h
> @@ -0,0 +1,160 @@
> +/*
> + * Copyright (C) 2018 Derek Buitenhuis
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#ifndef AVUTIL_TIMELINE_H
> +#define AVUTIL_TIMELINE_H
> +
> +#include <stddef.h>
> +#include <stdint.h>
> +
> +#include "rational.h"
> +
> +typedef struct AVTimelineEntry {
> +    /**
> +     * The start time of the given timeline entry, in stream timebase units.
> +     * If this value is AV_NOPTS_VALUE, you must display black for the duration
> +     * of the entry. For audio, silence must be played.
> +     */
> +    int64_t start;
> +
> +    /**
> +     * The duration of the given timeline entry, in steam timebase units.
> +     */
> +    int64_t duration;
> +
> +    /**
> +     * The rate at which this entry should be played back. The value is a multipier
> +     * of the stream's rate, for example: 1.2 means play back this entry at 1.2x speed.
> +     * If this value is 0, then the first sample (located at 'start') must be displayed
> +     * for the duration of the entry.
> +     */
> +    AVRational media_rate;
> +} AVTimelineEntry;
> +
> +/**
> + * Describes a timeline for a stream in terms of edits/entries. Each entry must be
> + * played back in order, according to the information in each. Each stream may have
> + * multiple timelines which need to be correlated between different streams.
> + */
> +typedef struct AVTimeline {
> +    /**
> +     * The ID of a given timeline. Since each stream may have multiple timelines
> +     * defined, this value is used to correlated different streams' timelines
> +     * which should be used together. For example, if one has two streams,
> +     * one video, and one audio, with two timelines each, the timelines
> +     * with matching IDs should be used in conjuction, to assure everything
> +     * is in sync and matches. The concept is similar to that of EditionUID
> +     * in Matroska.
> +     */
> +    uint32_t id;
> +
> +    /**
> +     * An in-order array of entries for the given timeline.
> +     * Each entry contains information on which samples to display for a
> +     * particular edit.
> +     */
> +    AVTimelineEntry *entries;

This is problematic as its non extensible. (unless iam missing something)
Consider that a field is added to AVTimelineEntry, the entries array would
have a larger element size and that would require all user apps to be rebuild

Also, if you want to support quicktime more fully theres more needed.
QT can for example switch even between codecs mid stream IIRC
not sure we want to support this

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180328/6db1ee69/attachment.sig>


More information about the ffmpeg-devel mailing list