From 2d7044683f3c0fa87445bf60854f1bd7ab0faf4f Mon Sep 17 00:00:00 2001 From: Jean First Date: Wed, 27 Feb 2013 00:18:41 +0100 Subject: ffmpeg_opt: add -to option to specify stop time Signed-off-by: Jean First Signed-off-by: Michael Niedermayer --- ffmpeg_opt.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'ffmpeg_opt.c') diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 2e45e47450..fc5e1c86a5 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -145,6 +145,7 @@ static void init_options(OptionsContext *o, int is_input) " consider fixing your command line.\n"); } else o->recording_time = INT64_MAX; + o->stop_time = INT64_MAX; o->mux_max_delay = 0.7; o->limit_filesize = UINT64_MAX; o->chapters_input_file = INT_MAX; @@ -1656,6 +1657,20 @@ loop_end: exit(1); } + if (o->stop_time != INT64_MAX && o->recording_time != INT64_MAX) { + o->stop_time = INT64_MAX; + av_log(NULL, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n"); + } + + if (o->stop_time != INT64_MAX && o->recording_time == INT64_MAX) { + if (o->stop_time <= o->start_time) { + av_log(NULL, AV_LOG_WARNING, "-to value smaller than -ss; ignoring -to.\n"); + o->stop_time = INT64_MAX; + } else { + o->recording_time = o->stop_time - o->start_time; + } + } + GROW_ARRAY(output_files, nb_output_files); if (!(output_files[nb_output_files - 1] = av_mallocz(sizeof(*output_files[0])))) exit(1); @@ -2389,6 +2404,8 @@ const OptionDef options[] = { { "t", HAS_ARG | OPT_TIME | OPT_OFFSET, { .off = OFFSET(recording_time) }, "record or transcode \"duration\" seconds of audio/video", "duration" }, + { "to", HAS_ARG | OPT_TIME | OPT_OFFSET, { .off = OFFSET(stop_time) }, + "record or transcode stop time", "time_stop" }, { "fs", HAS_ARG | OPT_INT64 | OPT_OFFSET, { .off = OFFSET(limit_filesize) }, "set the limit file size in bytes", "limit_size" }, { "ss", HAS_ARG | OPT_TIME | OPT_OFFSET, { .off = OFFSET(start_time) }, -- cgit v1.2.3