Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

mshabunin
Copy link
Contributor

@mshabunin mshabunin commented Mar 19, 2022

resolves #20147
closes #21766

[email protected] (debug)

./configure \
  --enable-shared --disable-static --enable-pic --enable-gpl --enable-nonfree \
  --enable-libxvid --enable-libx264 --enable-swresample \
  --prefix=/home/user/ffmpeg/install \
  --enable-debug=3 --disable-stripping --extra-cflags="-gstabs+ -Og -g -fno-inline -fno-omit-frame-pointer" --disable-optimizations 

TODO:

  • check HW acceleration support (va)
  • check and fix compatibility with older FFmpeg versions (up to 2.0 releases)
  • backport to OpenCV 3.4(?)
build_contrib:Custom=OFF
build_contrib:Custom Win=OFF

build_shared:Custom=OFF
build_examples:Custom=OFF

build_image:Linux AVX2=ubuntu:20.04

Xbuild_image:Win64=msvs2019

force_builders=Custom,Custom Win,Linux AVX2
Xbuild_image:Custom=centos:7
Xbuild_image:Custom=ubuntu:20.04
build_image:Custom=gstreamer:16.04
buildworker:Custom=linux-1,linux-4,linux-6
test_opencl:Custom=ON

build_image:Custom Win=ffmpeg
Xbuild_image:Custom Win=ffmpeg-plugin
buildworker:Custom Win=windows-2
test_modules:Custom Win=videoio
test_opencl:Custom Win=ON

@mshabunin mshabunin marked this pull request as ready for review March 30, 2022 08:57
@mshabunin
Copy link
Contributor Author

I think this patch is ready for review now. I've tested most of FFmpeg versions starting from 2.0 (only on Linux), most with VA acceleration, some with MFX, results seem to be the same. I did not test Windows plugin build, OSX or other platforms and libav compatibility.

Copy link
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! Thank you 👍

  • Validated with FFmpeg 5.0

There are several memory leaks in errors handling code. I will fix them in a separate PR.

@opencv-pushbot opencv-pushbot merged commit ed1439f into opencv:4.x Apr 1, 2022
@mshabunin mshabunin deleted the fix-ffmpeg5 branch April 1, 2022 21:01
@opencv-pushbot opencv-pushbot mentioned this pull request Apr 23, 2022
@tomchen1000
Copy link

@mshabunin, does it work if I cherry-pick this commit onto 4.5.5?

@mshabunin
Copy link
Contributor Author

@tomchen1000 , probably yes, but there could be merge conflicts. Maybe several more commits should be picked too in order to reduce conflicts (up to 25 Dec 2021 - https://github.com/opencv/opencv/commits/5440fd6cb43ea65a056c46b691fcdab1a425e92d/modules/videoio/src/cap_ffmpeg_impl.hpp).


// AVStream.codec deprecated in favor of AVStream.codecpar
// https://github.com/FFmpeg/FFmpeg/blob/b6af56c034759b81985f8ea094e41cbd5f7fecfb/doc/APIchanges#L1039-L1040
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(59, 16, 100)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mshabunin Can you remember why you used

#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(59, 16, 100)

instead of

//#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(57, 33, 100)

or even better which tests failed?

I am writing a PR to encapsulate raw encoded video using cv::VideoWriter to enable cudacodec::Videowriter to output video to containers instead of just raw .h264[5], without first initializing the encoder inside cv::VideoWriter. This works perfectly on versions of FFMpeg >= 59.16.100 but on earlier versions after AVStream.codec was depreciated it fails as it is expecting the AVStream.codecpar struct to be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some issues with tests for FFmpeg >=3.1. I've tested it using this repository: https://github.com/mshabunin/videoio-ffmpeg-check I don't remember which tests I had run that time, but at this moment several synthetic and acceleration tests fail:

I decided that this functionality was not mature before FFmpeg 5.0 and thus set condition to >=59.16.100. I did not investigate this issue in details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to compile with ffmpeg videoio: build issues with upcoming FFmpeg 5.0

5 participants