[FFmpeg-cvslog] fftools/ffmpeg_mux: use correct timebases for bitstream filtering
Anton Khirnov
git at videolan.org
Wed Aug 30 13:00:07 EEST 2023
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Tue Jul 25 16:01:40 2023 +0200| [ed5caaaf221bda5b4efbe8a3631d0a3438b0d32c] | committer: Anton Khirnov
fftools/ffmpeg_mux: use correct timebases for bitstream filtering
Bitstream filtering input timebase is not always necessarily equal to
OutputStream.mux_timebase. Also, set AVPacket.time_base correctly for
packets output by bitstream filters
Do not rescale at all in of_output_packet() when not doing bitstream
filtering, as it's unnecessary - write_packet() will rescale to the
actual muxer timebase.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ed5caaaf221bda5b4efbe8a3631d0a3438b0d32c
---
fftools/ffmpeg_mux.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 24cdf00469..ab9bb398c1 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -340,16 +340,13 @@ int of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
if (pkt && pkt->dts != AV_NOPTS_VALUE)
ost->last_mux_dts = av_rescale_q(pkt->dts, pkt->time_base, AV_TIME_BASE_Q);
- /* rescale timestamps to the muxing timebase */
- if (pkt) {
- av_packet_rescale_ts(pkt, pkt->time_base, ost->mux_timebase);
- pkt->time_base = ost->mux_timebase;
- }
-
/* apply the output bitstream filters */
if (ms->bsf_ctx) {
int bsf_eof = 0;
+ if (pkt)
+ av_packet_rescale_ts(pkt, pkt->time_base, ms->bsf_ctx->time_base_in);
+
ret = av_bsf_send_packet(ms->bsf_ctx, pkt);
if (ret < 0) {
err_msg = "submitting a packet for bitstream filtering";
@@ -367,6 +364,9 @@ int of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
goto fail;
}
+ if (!bsf_eof)
+ ms->bsf_pkt->time_base = ms->bsf_ctx->time_base_out;
+
ret = submit_packet(mux, bsf_eof ? NULL : ms->bsf_pkt, ost);
if (ret < 0)
goto mux_fail;
More information about the ffmpeg-cvslog
mailing list