[FFmpeg-devel] [PATCH] movenc: add timescale option

Robert Krüger krueger at lesspain.de
Thu May 16 11:25:01 CEST 2013


Hi,


On Thu, May 16, 2013 at 11:10 AM, Jean First <jeanfirst at gmail.com> wrote:

> Signed-off-by: Jean First <jeanfirst at gmail.com>
> ---
>
>  Sometimes it is useful to specify a specific timescale for a track.
>  f.ex when concatenating files.
>
>  libavformat/movenc.c | 11 ++++++++---
>  libavformat/movenc.h |  1 +
>  2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 8b3ad7f..2e1e039 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -62,6 +62,7 @@ static const AVOption options[] = {
>      { "frag_size", "Maximum fragment size", offsetof(MOVMuxContext,
> max_fragment_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX,
> AV_OPT_FLAG_ENCODING_PARAM},
>      { "ism_lookahead", "Number of lookahead entries for ISM files",
> offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0,
> INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
>      { "use_editlist", "use edit list", offsetof(MOVMuxContext,
> use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1,
> AV_OPT_FLAG_ENCODING_PARAM},
> +    { "timescale", "set a specific track timescale",
> offsetof(MOVMuxContext, timescale), AV_OPT_TYPE_INT, {.i64 = 0}, 0,
> INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
>      { NULL },
>  };
>
> @@ -3622,9 +3623,13 @@ static int mov_write_header(AVFormatContext *s)
>                  }
>                  track->height = track->tag>>24 == 'n' ? 486 : 576;
>              }
> -            track->timescale = st->codec->time_base.den;
> -            while(track->timescale < 10000)
> -                track->timescale *= 2;
> +            if (mov->timescale) {
> +                track->timescale = mov->timescale;
> +            } else {
> +                track->timescale = st->codec->time_base.den;
> +                while(track->timescale < 10000)
> +                    track->timescale *= 2;
> +            }
>              if (track->mode == MODE_MOV && track->timescale > 100000)
>                  av_log(s, AV_LOG_WARNING,
>                         "WARNING codec timebase is very high. If duration
> is too long,\n"
> diff --git a/libavformat/movenc.h b/libavformat/movenc.h
> index a5db895..0f52877 100644
> --- a/libavformat/movenc.h
> +++ b/libavformat/movenc.h
> @@ -168,6 +168,7 @@ typedef struct MOVMuxContext {
>      AVIOContext *mdat_buf;
>
>      int use_editlist;
> +    int timescale;
>  } MOVMuxContext;
>
>  #define FF_MOV_FLAG_RTP_HINT 1
> --
>

Since this only affects the timescale of video tracks it should be named
and documented accordingly, e.g. ("video_track_timescale", "set timescale
of all video tracks").


More information about the ffmpeg-devel mailing list