Skip to content

Commit b574ff8

Browse files
committed
Add compatibility with FFmpeg 8.0
key_frame was deprecated in 2023 (FFmpeg 6.1): 2023-05-04 - 0fc9c1f6828 - lavu 58.7.100 - frame.h Deprecate AVFrame.interlaced_frame, AVFrame.top_field_first, and AVFrame.key_frame. Add AV_FRAME_FLAG_INTERLACED, AV_FRAME_FLAG_TOP_FIELD_FIRST, and AV_FRAME_FLAG_KEY flags as replacement.
1 parent faffd5c commit b574ff8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

torchvision/csrc/io/decoder/video_stream.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ int VideoStream::copyFrameBytes(ByteStorage* out, bool flush) {
122122
void VideoStream::setHeader(DecoderHeader* header, bool flush) {
123123
Stream::setHeader(header, flush);
124124
if (!flush) { // no frames for video flush
125+
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(58,7,100)
126+
header->keyFrame = (frame_)->flags & AV_FRAME_FLAG_KEY;
127+
#else
125128
header->keyFrame = frame_->key_frame;
129+
#endif
126130
header->fps = av_q2d(av_guess_frame_rate(
127131
inputCtx_, inputCtx_->streams[format_.stream], nullptr));
128132
}

0 commit comments

Comments
 (0)