videoio: initial FFmpeg 5.0 support#21754
Conversation
|
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. |
alalek
left a comment
There was a problem hiding this comment.
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.
|
@mshabunin, does it work if I cherry-pick this commit onto 4.5.5? |
|
@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) |
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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:
- Log with condition changed to
>=57.33.100(FFmpeg >= 3.1) - log_ffmpeg-3.1.11.txt - Log with current 4.x - log_ffmpeg-3.1.11.txt
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.
resolves #20147
closes #21766
FFmpeg@n5.0 (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-optimizationsTODO:
backport to OpenCV 3.4(?)