[FFmpeg-devel] [PATCH] ffmpeg_opt: add -to option

Michael Niedermayer michaelni at gmx.at
Tue Feb 26 16:24:04 CET 2013


On Mon, Feb 25, 2013 at 05:13:52PM +0100, Jean First wrote:
> 
> Signed-off-by: Jean First <jeanfirst at gmail.com>
> ---
> Updated as requested.
> 
>  doc/ffmpeg.texi |    8 ++++++++
>  ffmpeg.h        |    1 +
>  ffmpeg_opt.c    |   32 ++++++++++++++++++++++++++++++--
>  3 files changed, 39 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
> index 3db1e98..77dba53 100644
> --- a/doc/ffmpeg.texi
> +++ b/doc/ffmpeg.texi
> @@ -256,6 +256,14 @@ libx264, and the 138th audio, which will be encoded with libvorbis.
>  Stop writing the output after its duration reaches @var{duration}.
>  @var{duration} may be a number in seconds, or in @code{hh:mm:ss[.xxx]} form.
>  
> +-to and -t are mutually exclusive and -t has priority.
> +
> + at item -to @var{position} (@emph{output})
> +Stop writing the output at @var{position}.
> + at var{position} may be a number in seconds, or in @code{hh:mm:ss[.xxx]} form.
> +
> +-to and -t are mutually exclusive and -t has priority.
> +
>  @item -fs @var{limit_size} (@emph{output})
>  Set the file size limit, expressed in bytes.
>  
> diff --git a/ffmpeg.h b/ffmpeg.h
> index c64a015..012e772 100644
> --- a/ffmpeg.h
> +++ b/ffmpeg.h
> @@ -114,6 +114,7 @@ typedef struct OptionsContext {
>      int chapters_input_file;
>  
>      int64_t recording_time;
> +    int64_t stop_time;
>      uint64_t limit_filesize;
>      float mux_preload;
>      float mux_max_delay;
> diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
> index b2a913f..92aa68a 100644
> --- a/ffmpeg_opt.c
> +++ b/ffmpeg_opt.c
> @@ -96,6 +96,7 @@ static int do_psnr            = 0;
>  static int input_sync;
>  
>  static int64_t recording_time = INT64_MAX;
> +static int64_t stop_time = INT64_MAX;
>  
>  static void uninit_options(OptionsContext *o, int is_input)
>  {
> @@ -128,16 +129,27 @@ static void uninit_options(OptionsContext *o, int is_input)
>      av_freep(&o->streamid_map);
>      av_freep(&o->attachments);
>  
> -    if (is_input)
> +    if (is_input) {
>          recording_time = o->recording_time;
> -    else
> +        stop_time = o->stop_time;
> +    } else {
>          recording_time = INT64_MAX;
> +        stop_time = INT64_MAX;
> +    }
>  }
>  
>  static void init_options(OptionsContext *o, int is_input)
>  {
>      memset(o, 0, sizeof(*o));
>  
> +    if (!is_input && stop_time != INT64_MAX) {
> +        o->stop_time = stop_time;
> +        av_log(NULL, AV_LOG_WARNING,
> +                "-to is not an input option, keeping it for the next output;"
> +                " consider fixing your command line.\n");

this is just a hack for -t with existing scripts that specify it in
the wrong place
without this hack the patch should be much simpler

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

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130226/9def9263/attachment.asc>


More information about the ffmpeg-devel mailing list