From 56ee3f9de7b9f6090d599a27d33a392890a2f7b8 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 15 Jun 2013 09:35:10 +0200 Subject: avconv: distinguish between -ss 0 and -ss not being used Using -ss 0 to drop frames with negative timestamps is a perfectly valid use case. --- avconv_opt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'avconv_opt.c') diff --git a/avconv_opt.c b/avconv_opt.c index f96feced9a..c8d917638b 100644 --- a/avconv_opt.c +++ b/avconv_opt.c @@ -113,6 +113,7 @@ static void init_options(OptionsContext *o) memset(o, 0, sizeof(*o)); o->mux_max_delay = 0.7; + o->start_time = AV_NOPTS_VALUE; o->recording_time = INT64_MAX; o->limit_filesize = UINT64_MAX; o->chapters_input_file = INT_MAX; @@ -658,13 +659,13 @@ static int open_input_file(OptionsContext *o, const char *filename) exit_program(1); } - timestamp = o->start_time; + timestamp = (o->start_time == AV_NOPTS_VALUE) ? 0 : o->start_time; /* add the stream start time */ if (ic->start_time != AV_NOPTS_VALUE) timestamp += ic->start_time; /* if seeking requested, we execute it */ - if (o->start_time != 0) { + if (o->start_time != AV_NOPTS_VALUE) { ret = av_seek_frame(ic, -1, timestamp, AVSEEK_FLAG_BACKWARD); if (ret < 0) { av_log(NULL, AV_LOG_WARNING, "%s: could not seek to position %0.3f\n", @@ -1212,7 +1213,8 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata) for (i = 0; i < is->nb_chapters; i++) { AVChapter *in_ch = is->chapters[i], *out_ch; - int64_t ts_off = av_rescale_q(ofile->start_time - ifile->ts_offset, + int64_t start_time = (ofile->start_time == AV_NOPTS_VALUE) ? 0 : ofile->start_time; + int64_t ts_off = av_rescale_q(start_time - ifile->ts_offset, AV_TIME_BASE_Q, in_ch->time_base); int64_t rt = (ofile->recording_time == INT64_MAX) ? INT64_MAX : av_rescale_q(ofile->recording_time, AV_TIME_BASE_Q, in_ch->time_base); -- cgit v1.2.3