1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-23 21:54:53 +02:00

avconv: support -t as an input option.

It limits the duration of the data read from a given input.
This commit is contained in:
Anton Khirnov
2013-06-18 11:12:09 +02:00
parent 811bd07846
commit 488a0fa689
5 changed files with 19 additions and 3 deletions

View File

@@ -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;