Unable to build opencv 4.5 with FFmpeg

I am unable to build Opencv 4.5.5 with FFMPEG , Please find below error file.

Error File

@cudawarped Can You Please help with this last issue remaining.

what version of opencv? what version of ffmpeg libraries?

is this the complete output? I’d expect some missing headers.

Did you install the ffmpeg libs?

Its been a while but from memory on linux you need to install pkg-config and then the ffmpeg libs for OpenCV to pick them up, e.g.

sudo apt-get install pkg-config

and then

sudo apt-get install libavformat-dev libavcodec-dev libswscale-dev libavresample-dev

Also as @crackwitz said, which version of FFMpeg are you using, pre OpenCV 4.6 I think there wasn’t support for 4 or 5 but I may be wrong.

@crackwitz @cudawarped Now I am trying to build with OpenCV Version 4.6 and FFmpeg version n5.0, I saw the "Initial FFmpeg 5.0 Support thread " in OpenCV Issues. Interestingly now FFmpeg is not recognized by OpenCV. Somehow i disabled build and can get ffmpeg=Yes.

Do I need to specify the FFmpeg location in CMake options?

This is the complete error gist I am getting, I think even with Open CV 4.6

Errors are like this during build :
error: ‘CODEC_ID_H264’ was not declared in this scope; did you mean ‘AV_CODEC_ID_H264’?

Can you post the CMake output, does it pick up FFMpeg, have you installed pkg-config? e.g.

– Video I/O:
– DC1394: YES (2.2.5)
– FFMPEG: YES
– avcodec: YES (58.54.100)
– avformat: YES (58.29.100)
– avutil: YES (56.31.100)
– swscale: YES (5.5.100)
– avresample: YES (4.0.0)
– GStreamer: YES (1.16.2)
– v4l/v4l2: YES (linux/videodev2.h)

@cudawarped No, It says FFMPEG : No. I use OPENCV_FFMPEG_SKIP_BUILD_CHECK=ON , as I check I am skipping the build options for FFmpeg.
My FFmpeg is built from source and installed in location /opt/FFmpeg !!

pkg-config is installed !!

But i cannot get ffmpeg -version from terminal !!

I am not sure I use windows more than linux it would be better to ask @crackwitz.

If pkg-config is aware of FFmpeg it should pick it up.

@crackwitz I used ./configure and used prefix_path=/usr/local , now pkg_config can recognise FFmpeg but still getting some build errors .

Video I/O:
– DC1394: YES (2.2.5)
– FFMPEG: YES
– avcodec: YES (59.33.100)
– avformat: YES (59.25.100)
– avutil: YES (57.27.100)
– swscale: YES (6.6.100)
– avresample: YES (4.0.0)
– GStreamer: YES (1.14.5)
– v4l/v4l2: YES (linux/videodev2.h)

thanks for the vote of confidence but it’s wholly misplaced. I’ve gotten OpenCV built on Windows but not even attempted to on linux.

if the issue could be modulated by choosing OpenCV v4.6.0 vs a previous version, it could be about any recent changes to OpenCV’s usage of ffmpeg… if not, then probably not.

that’s the extent of what I can contribute in this thread.

OK then @berak should definitely be able to help?

@berak Can you Pls help as we are stuck , Opencv is using ffmpeg internally for decoding RTSP stream.