summaryrefslogtreecommitdiffstats
path: root/fftools
diff options
context:
space:
mode:
authorVitaly _Vi Shukela <vi0oss@gmail.com>2017-11-18 10:36:51 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2017-11-19 04:38:29 +0100
commit80ef3c83601881ff2b6a90fa5c6e82c83aad768f (patch)
tree036456b403b8645dccd96f3dc16ddece287ff734 /fftools
parentae61bcbdf83a509553445bf0cbce1dba5ac5b208 (diff)
downloadffmpeg-streaming-80ef3c83601881ff2b6a90fa5c6e82c83aad768f.zip
ffmpeg-streaming-80ef3c83601881ff2b6a90fa5c6e82c83aad768f.tar.gz
ffmpeg: Allow "-to" on input files in addition to "-t"
For some strange reason "-t" option was only implemented for input files while both "-t" and "-to" were available for use for output files. This made extracting a range from input file inconvenient. This patch enables -to option for input so one can do ffmpeg -ss 1:23:20 -to 1:27:22.3 -i myinput.mkv ... Signed-off-by: Vitaly _Vi Shukela <vi0oss@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'fftools')
-rw-r--r--fftools/ffmpeg_opt.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 47d3841..f66f672 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -976,6 +976,21 @@ static int open_input_file(OptionsContext *o, const char *filename)
char * data_codec_name = NULL;
int scan_all_pmts_set = 0;
+ 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) {
+ int64_t start_time = o->start_time == AV_NOPTS_VALUE ? 0 : o->start_time;
+ if (o->stop_time <= start_time) {
+ av_log(NULL, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n");
+ exit_program(1);
+ } else {
+ o->recording_time = o->stop_time - start_time;
+ }
+ }
+
if (o->format) {
if (!(file_iformat = av_find_input_format(o->format))) {
av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", o->format);
@@ -3407,7 +3422,7 @@ const OptionDef options[] = {
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(recording_time) },
"record or transcode \"duration\" seconds of audio/video",
"duration" },
- { "to", HAS_ARG | OPT_TIME | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(stop_time) },
+ { "to", HAS_ARG | OPT_TIME | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(stop_time) },
"record or transcode stop time", "time_stop" },
{ "fs", HAS_ARG | OPT_INT64 | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(limit_filesize) },
"set the limit file size in bytes", "limit_size" },
OpenPOWER on IntegriCloud