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.
This commit is contained in:
Anton Khirnov 2023-07-25 16:01:40 +02:00
parent b39b6b7456
commit ed5caaaf22
1 changed files with 6 additions and 6 deletions

View File

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