From 488a0fa68973d48e264d54f1722f7afb18afbea7 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 18 Jun 2013 11:12:09 +0200 Subject: avconv: support -t as an input option. It limits the duration of the data read from a given input. --- avconv.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'avconv.c') diff --git a/avconv.c b/avconv.c index adea0ade79..7351b7757f 100644 --- a/avconv.c +++ b/avconv.c @@ -958,6 +958,7 @@ static int check_output_constraints(InputStream *ist, OutputStream *ost) static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt) { OutputFile *of = output_files[ost->file_index]; + InputFile *f = input_files [ist->file_index]; int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time; int64_t ost_tb_start_time = av_rescale_q(start_time, AV_TIME_BASE_Q, ost->st->time_base); AVPacket opkt; @@ -974,6 +975,16 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p return; } + if (f->recording_time != INT64_MAX) { + start_time = f->ctx->start_time; + if (f->start_time != AV_NOPTS_VALUE) + start_time += f->start_time; + if (ist->last_dts >= f->recording_time + start_time) { + ost->finished = 1; + return; + } + } + /* force the input stream PTS */ if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) audio_size += pkt->size; -- cgit v1.2.3