Apply fixes based on FFmpeg 5.0

See README.md for more details
This commit is contained in:
Stephen Seo 2022-02-18 15:24:31 +09:00
parent 2f62762ea7
commit 41c291f51c
3 changed files with 15 additions and 23 deletions

View file

@ -30,27 +30,6 @@ find_package(PkgConfig REQUIRED)
pkg_check_modules(FFMPEG_LIBAVCODEC REQUIRED
libavcodec libavformat libavutil libswscale)
if(${FFMPEG_LIBAVCODEC_libavcodec_VERSION} VERSION_GREATER "58.134.100"
OR
${FFMPEG_LIBAVCODEC_libavformat_VERSION} VERSION_GREATER "58.76.100"
OR
${FFMPEG_LIBAVCODEC_libavutil_VERSION} VERSION_GREATER "56.70.100"
OR
${FFMPEG_LIBAVCODEC_libswscale_VERSION} VERSION_GREATER "5.9.100")
message(FATAL_ERROR "FFmpeg version is newer than expected, please use FFmpeg version 4.4")
# The following may be necessary when moving to FFmpeg 5.0
#elseif(${FFMPEG_LIBAVCODEC_libavcodec_VERSION} VERSION_LESS_EQUAL "58.91.100"
# OR
# ${FFMPEG_LIBAVCODEC_libavformat_VERSION} VERSION_LESS_EQUAL "58.45.100"
# OR
# ${FFMPEG_LIBAVCODEC_libavutil_VERSION} VERSION_LESS_EQUAL "56.51.100"
# OR
# ${FFMPEG_LIBAVCODEC_libswscale_VERSION} VERSION_LESS_EQUAL "5.7.100")
# message(FATAL_ERROR "FFmpeg version is older than expected, please use FFmpeg version 4.4")
else()
message("FFmpeg version is OK")
endif()
target_include_directories(DitheringProject PUBLIC
${OpenCL_INCLUDE_DIRS}
${PNG_INCLUDE_DIRS}

View file

@ -2,14 +2,19 @@
## Note about Maintenance and Versions
The project at tag `1.0.0` refers to the state of the project upon completion
~~The project at tag `1.0.0` refers to the state of the project upon completion
of the course. Newer versions are meant to be maintenance releases; fixes that
keep the project working. As of 2022-01-18, there may be (after now) a version
`1.1.0` or `1.0.1` due to keeping up to date with the FFmpeg dependency as a new
major version of FFmpeg was released (version `5.0`).
To be clear, version `1.0.0` of this project is expected to work with FFmpeg
version `4.4`.
version `4.4`.~~
Fixes were applied for FFmpeg version 5. A macro is used to change incompatible
code based on what version of FFmpeg is specified in the headers, so external
checking of version is not necessary. Thus, the latest version of this repo
should work with both FFmpeg 5.0 and 4.4.
## Background

View file

@ -74,7 +74,11 @@ bool Video::DitherVideo(const std::string &output_filename, Image *blue_noise,
}
// Get "best" video stream
#if LIBAVFORMAT_VERSION_MAJOR >= 59
const AVCodec *dec_codec = nullptr;
#else
AVCodec *dec_codec = nullptr;
#endif
return_value = av_find_best_stream(
avf_dec_context, AVMediaType::AVMEDIA_TYPE_VIDEO, -1, -1, &dec_codec, 0);
if (return_value < 0) {
@ -193,7 +197,11 @@ bool Video::DitherVideo(const std::string &output_filename, Image *blue_noise,
// set output video codec (h264)
AVCodecContext *enc_codec_context = nullptr;
#if LIBAVCODEC_VERSION_MAJOR >= 59
const AVCodec *enc_codec = nullptr;
#else
AVCodec *enc_codec = nullptr;
#endif
// get H264 codec
if (!output_as_pngs) {