Message ID | D25D22B9-12F0-4920-A512-4ADF3F3F28F6@hotmail.com |
---|---|
State | Rejected |
Headers | show |
Series | [FFmpeg-devel] libavformat/concatdev.c: use the unified time base | expand |
Context | Check | Description |
---|---|---|
yinshiyou/configure_loongarch64 | warning | Failed to apply patch |
andriy/configure_aarch64_jetson | warning | Failed to apply patch |
andriy/configure_armv7_RPi4 | warning | Failed to apply patch |
On 2022-03-01 09:46 am, Ye Chuan wrote: > In some case, the input files have different time base > even though they share the same codec and codec parameters, > > So when we replace the packet, we need use the unified time base > instead of it of each stream own, which may lead to wrong pts/dts > of the output packet. Make this optional. This 'bug' has been used to effect speed change in some inputs. Regards, Gyan > > Signed-off-by: Chuan Ye <yechuan0102@hotmail.com> > --- > libavformat/concatdec.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c > index 0603c6e254..f7067d5059 100644 > --- a/libavformat/concatdec.c > +++ b/libavformat/concatdec.c > @@ -740,6 +740,7 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt) > ConcatStream *cs; > AVStream *st; > FFStream *sti; > + AVRational output_tb; > > if (cat->eof) > return AVERROR_EOF; > @@ -782,13 +783,15 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt) > av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base), > av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base)); > > + /* replace the pkt base on the time base of target output stream */ > + output_tb = avf->streams[cs->out_stream_index]->time_base; > delta = av_rescale_q(cat->cur_file->start_time - cat->cur_file->file_inpoint, > AV_TIME_BASE_Q, > - cat->avf->streams[pkt->stream_index]->time_base); > + output_tb); > if (pkt->pts != AV_NOPTS_VALUE) > - pkt->pts += delta; > + pkt->pts = av_rescale_q(pkt->pts, st->time_base, output_tb) + delta; > if (pkt->dts != AV_NOPTS_VALUE) > - pkt->dts += delta; > + pkt->dts = av_rescale_q(pkt->dts, st->time_base, output_tb) + delta; > av_log(avf, AV_LOG_DEBUG, " -> pts:%s pts_time:%s dts:%s dts_time:%s\n", > av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base), > av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base));
Hi Gyan Thanks for suggestion Base on the different time_base, the connection between the streams, the pts and dts may be not continuate, the the codec May reporte warning. Is that ‘bug’ acceptable? Regards, Chuan Ye From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> on behalf of Gyan Doshi <ffmpeg@gyani.pro> Date: Tuesday, March 1, 2022 at 12:49 PM To: ffmpeg-devel@ffmpeg.org <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH] libavformat/concatdev.c: use the unified time base On 2022-03-01 09:46 am, Ye Chuan wrote: > In some case, the input files have different time base > even though they share the same codec and codec parameters, > > So when we replace the packet, we need use the unified time base > instead of it of each stream own, which may lead to wrong pts/dts > of the output packet. Make this optional. This 'bug' has been used to effect speed change in some inputs. Regards, Gyan > > Signed-off-by: Chuan Ye <yechuan0102@hotmail.com> > --- > libavformat/concatdec.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c > index 0603c6e254..f7067d5059 100644 > --- a/libavformat/concatdec.c > +++ b/libavformat/concatdec.c > @@ -740,6 +740,7 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt) > ConcatStream *cs; > AVStream *st; > FFStream *sti; > + AVRational output_tb; > > if (cat->eof) > return AVERROR_EOF; > @@ -782,13 +783,15 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt) > av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base), > av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base)); > > + /* replace the pkt base on the time base of target output stream */ > + output_tb = avf->streams[cs->out_stream_index]->time_base; > delta = av_rescale_q(cat->cur_file->start_time - cat->cur_file->file_inpoint, > AV_TIME_BASE_Q, > - cat->avf->streams[pkt->stream_index]->time_base); > + output_tb); > if (pkt->pts != AV_NOPTS_VALUE) > - pkt->pts += delta; > + pkt->pts = av_rescale_q(pkt->pts, st->time_base, output_tb) + delta; > if (pkt->dts != AV_NOPTS_VALUE) > - pkt->dts += delta; > + pkt->dts = av_rescale_q(pkt->dts, st->time_base, output_tb) + delta; > av_log(avf, AV_LOG_DEBUG, " -> pts:%s pts_time:%s dts:%s dts_time:%s\n", > av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base), > av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base));
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index 0603c6e254..f7067d5059 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -740,6 +740,7 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt) ConcatStream *cs; AVStream *st; FFStream *sti; + AVRational output_tb; if (cat->eof) return AVERROR_EOF; @@ -782,13 +783,15 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt) av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base), av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base)); + /* replace the pkt base on the time base of target output stream */ + output_tb = avf->streams[cs->out_stream_index]->time_base; delta = av_rescale_q(cat->cur_file->start_time - cat->cur_file->file_inpoint, AV_TIME_BASE_Q, - cat->avf->streams[pkt->stream_index]->time_base); + output_tb); if (pkt->pts != AV_NOPTS_VALUE) - pkt->pts += delta; + pkt->pts = av_rescale_q(pkt->pts, st->time_base, output_tb) + delta; if (pkt->dts != AV_NOPTS_VALUE) - pkt->dts += delta; + pkt->dts = av_rescale_q(pkt->dts, st->time_base, output_tb) + delta; av_log(avf, AV_LOG_DEBUG, " -> pts:%s pts_time:%s dts:%s dts_time:%s\n", av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base), av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base));
In some case, the input files have different time base even though they share the same codec and codec parameters, So when we replace the packet, we need use the unified time base instead of it of each stream own, which may lead to wrong pts/dts of the output packet. Signed-off-by: Chuan Ye <yechuan0102@hotmail.com> --- libavformat/concatdec.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)