diff options
author | Anton Khirnov <anton@khirnov.net> | 2024-02-13 12:01:11 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-02-21 10:27:20 +0100 |
commit | 8f592eb35f4ba42c8516fe296d75e7589edb0359 (patch) | |
tree | 24006c57d556eb935409eadf9e72884fef5c4d9a /fftools/ffmpeg_filter.c | |
parent | 09438d6529978f636fdfa0bd2b96687aa771506d (diff) | |
download | ffmpeg-8f592eb35f4ba42c8516fe296d75e7589edb0359.tar.gz |
fftools/ffmpeg_filter: compute input trim start/end in demuxer
The computation is based on demuxer properties, so that is the more
appropriate place for it. Filter code just receives the desired
start time/duration.
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r-- | fftools/ffmpeg_filter.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index ed62e1d8ec..c411b882de 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -103,6 +103,8 @@ typedef struct FilterGraphThread { typedef struct InputFilterPriv { InputFilter ifilter; + InputFilterOptions opts; + int index; AVFilterContext *filter; @@ -673,7 +675,8 @@ static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist) ifp->ist = ist; ifp->type_src = ist->st->codecpar->codec_type; - dec_idx = ist_filter_add(ist, ifilter, filtergraph_is_simple(ifilter->graph)); + dec_idx = ist_filter_add(ist, ifilter, filtergraph_is_simple(ifilter->graph), + &ifp->opts); if (dec_idx < 0) return dec_idx; @@ -1478,7 +1481,6 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, AVBPrint args; char name[255]; int ret, pad_idx = 0; - int64_t tsoffset = 0; AVBufferSrcParameters *par = av_buffersrc_parameters_alloc(); if (!par) return AVERROR(ENOMEM); @@ -1558,13 +1560,7 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, snprintf(name, sizeof(name), "trim_in_%d_%d", f->index, ist->index); - if (copy_ts) { - tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time; - if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE) - tsoffset += f->ctx->start_time; - } - ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ? - AV_NOPTS_VALUE : tsoffset, f->recording_time, + ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us, &last_filter, &pad_idx, name); if (ret < 0) return ret; @@ -1589,7 +1585,6 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph, AVBPrint args; char name[255]; int ret, pad_idx = 0; - int64_t tsoffset = 0; ifp->time_base = (AVRational){ 1, ifp->sample_rate }; @@ -1615,13 +1610,7 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph, snprintf(name, sizeof(name), "trim for input stream %d:%d", f->index, ist->index); - if (copy_ts) { - tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time; - if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE) - tsoffset += f->ctx->start_time; - } - ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ? - AV_NOPTS_VALUE : tsoffset, f->recording_time, + ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us, &last_filter, &pad_idx, name); if (ret < 0) return ret; |