Fix T103818: Freeze frames in movie strips when timecodes are used

Timecodes were generated from read packets, but applied to decoded
frames. This works as long as delay between packet read and decoded
frame is less than GOP size or if packet does not produce multiple
frames. In this case it did not work.

Use `pkt_pos`, `pkt_dts` and `pts` from `AVFrame` instead of `AVPacket`.
This way delay can be eliminated and timecode files are more reliable.
This commit is contained in:
Richard Antalik 2023-01-13 21:25:41 +01:00
parent 2c910cb70a
commit a5c3f5b0bc
Notes: blender-bot 2023-02-14 11:34:30 +01:00
Referenced by issue #103818, VSE: frozen frames after simple edit/cut in final render
1 changed files with 11 additions and 10 deletions

View File

@ -1040,16 +1040,6 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context,
}
if (next_packet->stream_index == context->videoStream) {
if (next_packet->flags & AV_PKT_FLAG_KEY) {
context->last_seek_pos = context->seek_pos;
context->last_seek_pos_pts = context->seek_pos_pts;
context->last_seek_pos_dts = context->seek_pos_dts;
context->seek_pos = next_packet->pos;
context->seek_pos_pts = next_packet->pts;
context->seek_pos_dts = next_packet->dts;
}
int ret = avcodec_send_packet(context->iCodecCtx, next_packet);
while (ret >= 0) {
ret = avcodec_receive_frame(context->iCodecCtx, in_frame);
@ -1062,6 +1052,17 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context,
fprintf(stderr, "Error decoding proxy frame: %s\n", av_err2str(ret));
break;
}
if (next_packet->flags & AV_PKT_FLAG_KEY) {
context->last_seek_pos = context->seek_pos;
context->last_seek_pos_pts = context->seek_pos_pts;
context->last_seek_pos_dts = context->seek_pos_dts;
context->seek_pos = in_frame->pkt_pos;
context->seek_pos_pts = in_frame->pts;
context->seek_pos_dts = in_frame->pkt_dts;
}
index_rebuild_ffmpeg_proc_decoded_frame(context, next_packet, in_frame);
}
}