replay: flush codec buffers after seeking (#34556)

* flush codec buffers after seeking

* replace avio_seek with the higher-level avformat_seek_file

* exit early
This commit is contained in:
Dean Lee
2025-02-10 05:02:43 +08:00
committed by GitHub
parent 65e478f27f
commit ad2b1edbd0
+8 -1
View File
@@ -177,7 +177,14 @@ bool VideoDecoder::decode(FrameReader *reader, int idx, VisionBuf *buf) {
break;
}
}
avio_seek(reader->input_ctx->pb, reader->packets_info[from_idx].pos, SEEK_SET);
auto pos = reader->packets_info[from_idx].pos;
int ret = avformat_seek_file(reader->input_ctx, 0, pos, pos, pos, AVSEEK_FLAG_BYTE);
if (ret < 0) {
rError("Failed to seek to byte position %lld: %d", pos, AVERROR(ret));
return false;
}
avcodec_flush_buffers(decoder_ctx);
}
reader->prev_idx = idx;