summaryrefslogtreecommitdiff
path: root/avconv.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-06-18 11:12:09 +0200
committerAnton Khirnov <anton@khirnov.net>2013-08-05 10:54:19 +0200
commit488a0fa68973d48e264d54f1722f7afb18afbea7 (patch)
tree7b7862548be5012cef6405ea48fc45ce5a2e32e3 /avconv.c
parent811bd0784679dfcb4ed02043a37c92f9df10500e (diff)
avconv: support -t as an input option.
It limits the duration of the data read from a given input.
Diffstat (limited to 'avconv.c')
-rw-r--r--avconv.c11
1 files changed, 11 insertions, 0 deletions
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;