Skip to content

Commit

Permalink
ffmpegPortmonitor: Fix compatibility with ffmpeg 7
Browse files Browse the repository at this point in the history
  • Loading branch information
traversaro committed May 15, 2024
1 parent 99c5da6 commit fd90f84
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ void FfmpegMonitorObject::destroy(void)

// Check if codec context is freeable, if yes free it.
if (codecContext != NULL) {
#if LIBAVCODEC_VERSION_MAJOR < 61
// See https://github.com/FFmpeg/FFmpeg/blob/n7.0/libavcodec/avcodec.h#L2381-L2384
avcodec_close(codecContext);
#endif
avcodec_free_context(&codecContext);
codecContext = NULL;
}
Expand Down Expand Up @@ -535,7 +538,12 @@ int FfmpegMonitorObject::compress(Image* img, AVPacket *pkt) {
}

// Set presentation timestamp
#if LIBAVCODEC_VERSION_MAJOR >= 61
// See https://github.com/FFmpeg/FFmpeg/commit/6b6f7db81932f94876ff4bcfd2da0582b8ab897e
endFrame->pts = codecContext->frame_num;
#else
endFrame->pts = codecContext->frame_number;
#endif

// Send image frame to codec
ret = avcodec_send_frame(codecContext, endFrame);
Expand Down

0 comments on commit fd90f84

Please sign in to comment.