aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-05-31 16:58:50 +0200
committerAnton Khirnov <anton@khirnov.net>2023-06-03 11:27:42 +0200
commitba32f284983037bcf65c8eb372703cd15bc35078 (patch)
treebc4bcf6f0fdd5f880ac31a5ae17a0a002c9fbe9a
parent811b0e02be44277211c3aea49f601330e2e52dcc (diff)
downloadffmpeg-ba32f284983037bcf65c8eb372703cd15bc35078.tar.gz
doc/examples/transcode: convert timestamps between filtering and encoding
The timebases do not have to match.
-rw-r--r--doc/examples/transcode.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c
index a486edc472..305181663c 100644
--- a/doc/examples/transcode.c
+++ b/doc/examples/transcode.c
@@ -441,6 +441,10 @@ static int encode_write_frame(unsigned int stream_index, int flush)
/* encode filtered frame */
av_packet_unref(enc_pkt);
+ if (filt_frame && filt_frame->pts != AV_NOPTS_VALUE)
+ filt_frame->pts = av_rescale_q(filt_frame->pts, filt_frame->time_base,
+ stream->enc_ctx->time_base);
+
ret = avcodec_send_frame(stream->enc_ctx, filt_frame);
if (ret < 0)
@@ -495,6 +499,7 @@ static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index)
break;
}
+ filter->filtered_frame->time_base = av_buffersink_get_time_base(filter->buffersink_ctx);;
filter->filtered_frame->pict_type = AV_PICTURE_TYPE_NONE;
ret = encode_write_frame(stream_index, 0);
av_frame_unref(filter->filtered_frame);