videoio/FFmpeg: added CV_16UC1 read/write support#22894
videoio/FFmpeg: added CV_16UC1 read/write support#22894opencv-pushbot merged 1 commit intoopencv:4.xfrom
Conversation
|
Is there a codec that supports CV_16UC1 that has also FFMPEG video acceleration support? |
|
At least my Linux/Intel Tigerlake/Media Driver system doesn't have a straight-forward way. vainfo -a 2>&1 | grep BPP | sort | uniq
VA_RT_FORMAT_RGB32_10BPP
VA_RT_FORMAT_YUV420_10BPP |
|
Looks like libva does not support single channel 16 bit images, there is no such format defined at least: https://intel.github.io/libva/group__api__core.html#gaff38bc6c01b65c6e9d473e40bdde9df6 |
You are right! I missed the |
|
Build fails for me: build.log ccmake -DCMAKE_BUILD_TYPE=Release -DOPENCV_FFMPEG_ENABLE_LIBAVDEVICE=ON -DWITH_OPENGL=ON -DWITH_QT=ON DWITH_FFMPEG=ON -DOPENCV_FFMPEG_SKIP_BUILD_CHECK=ON -DWITH_VA=ON -DWITH_VA_INTEL=ON -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF ..FFmpeg: # tag 5.1.2
ffmpeg version N-109236-g2324b917fc Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12 (SUSE Linux)
configuration: --prefix=/usr/local/ --libdir=/usr/local/lib64/ --bindir=/usr/local/bin --disable-static --enable-shared --enable-vaapi --enable-libvorbis --enable-libvpx --enable-gpl --cpu=native --enable-opengl --enable-libpulse --enable-libfdk-aac --enable-libx264 --enable-libx265 --enable-nonfree --enable-libv4l2
libavutil 57. 43.100 / 57. 43.100
libavcodec 59. 54.100 / 59. 54.100
libavformat 59. 34.102 / 59. 34.102
libavdevice 59. 8.101 / 59. 8.101
libavfilter 8. 50.101 / 8. 50.101
libswscale 6. 8.112 / 6. 8.112
libswresample 4. 9.100 / 4. 9.100
libpostproc 56. 7.100 / 56. 7.100Seems to be an FFmpeg compatibility issue. Which version of FFmpeg is recommended for 4.x? |
|
I am rebuilding FFmpeg release/5.1 right now just to see if the problem is on my side. |
|
I tested this patch with multiple FFmpeg versions including
Perhaps you have a problem with FFmpeg detection. Try to uncomment this line and determine why this happens. |
|
I am not sure. that is why i am rebuilding. |
|
Problem is on my side. Sorry! About to test If i can make it read gray16 using VA_INTEL. |
|
Hmm. creating ffv1/gray16le is easy but i still fail to create a mjpeg/rgb16 video with ffmpeg. but i don't give up yet. anyway great PR! |
|
This PR does not add 16 bit support for MJPEG. You can try to do it manually here: https://github.com/mshabunin/opencv/blob/39ddf0e4e22536847580bc0d21e35c0c20ebe8b9/modules/videoio/src/cap_ffmpeg_impl.hpp#L2932 Also, I'm not sure what would happen with 16 bit values after conversion to RGB16 and lossy compression. |
Thx. I do understand! At the moment I am experimenting with accelerating raw RGB16 using VAAPI. |
|
Ok. Two things i can say:
I'll tinker a little more and will open an issue at FFmpeg trac. |
|
Related: #9123 |
| OPENCV_FFMPEG_API int cvGrabFrame_FFMPEG(struct CvCapture_FFMPEG* cap); | ||
| OPENCV_FFMPEG_API int cvRetrieveFrame_FFMPEG(struct CvCapture_FFMPEG* capture, unsigned char** data, | ||
| int* step, int* width, int* height, int* cn); | ||
| int* step, int* width, int* height, int* cn, int* depth); |
There was a problem hiding this comment.
AFAIK, it is a public API.
We should not modify existed functions.
There was a problem hiding this comment.
I thought we've switched to the new plugin API in the FFmpeg plugin? Is it possible, what do you think?
There was a problem hiding this comment.
These functions are still exported.
These functions are deprecated and they will to be removed in 5.x. So no need trying to modify it.
There was a problem hiding this comment.
I've added a new function.
| bool setProperty(int, double); | ||
| bool grabFrame(); | ||
| bool retrieveFrame(int flag, unsigned char** data, int* step, int* width, int* height, int* cn); | ||
| bool retrieveFrame(int flag, unsigned char** data, int* step, int* width, int* height, int* cn, int* deptth); |
39ddf0e to
cf511c7
Compare
alalek
left a comment
There was a problem hiding this comment.
Thank you!
Please squash commits into one before merge.
cf511c7 to
6ad2165
Compare
Partially resolves #10623
Replaces #12284 and #12290
FFV1codec.Note: some other codecs had hidden support for 16UC1, but I did not test them (PNG and RAWVIDEO).
Note: originally I wanted to modify #12290 - add a test, fix minor issues, but it turned out that I had to rewrite 90% of changes made in that PR, so I decided to publish it as a brand new one.