Can't read mp4 on alma linux ( = RHEL) system

greetings,

i’m running into an error when i try to open and read an mp4 video, something about ‘missing a plugin’.

here is the program :

#include <iostream>
#include <filesystem>
#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;


int main(int argc, char *argv[])
{
        if (!filesystem::exists(argv[1])) {
                cerr << "Video file not found: " << argv[1] << "\n";
                return 1;
        }

        VideoCapture cap(argv[1]);
        if (cap.isOpened()) {
                cap.release();
                cout << "OK!\n";
        } else {
                cerr << argv[1] << ": can't open video for reading\n";
        }
}

running the program :

$ opencvread /data/ocr/1777366691553627/danse.mp4
[ INFO:0@0.009] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/videoio_registry.cpp (223) VideoBackendRegistry VIDEOIO: Enabled backends(7, sorted by priority): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); V4L2(970); CV_IMAGES(960); CV_MJPEG(950); UEYE(940)
[ INFO:0@0.010] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/backend_plugin.cpp (369) getPluginCandidates VideoIO plugin (FFMPEG): glob is 'libopencv_videoio_ffmpeg*.so', 1 location(s)
[ INFO:0@0.013] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/backend_plugin.cpp (379) getPluginCandidates     - /usr/lib64: 0
[ INFO:0@0.013] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/backend_plugin.cpp (383) getPluginCandidates Found 0 plugin(s) for FFMPEG
[ INFO:0@0.018] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/cap_gstreamer.cpp (1104) open OpenCV | GStreamer: /data/ocr/1777366691553627/danse.mp4
[ INFO:0@0.018] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/cap_gstreamer.cpp (1137) open OpenCV | GStreamer: mode - FILE
[ WARN:0@0.036] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/cap_gstreamer.cpp (2386) handleMessage OpenCV | GStreamer warning: your GStreamer installation is missing a required plugin
[ WARN:0@0.036] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/cap_gstreamer.cpp (2401) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module qtdemux0 reported: Internal data stream error.
[ WARN:0@0.038] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/cap_gstreamer.cpp (1356) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0@0.038] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/cap_gstreamer.cpp (862) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
MFX: Can't initialize session
[ INFO:0@0.038] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/cap_images.cpp (282) icvExtractPattern Pattern: /data/ocr/1777366691553627/danse.mp%01d @ 4
[ INFO:0@0.040] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/cap_images.cpp (313) open CAP_IMAGES: Stop scanning. Can't read image file: /data/ocr/1777366691553627/danse.mp4
/data/ocr/1777366691553627/danse.mp4: can't open video for reading

(the error “warning: your GStreamer installation is missing a required plugin” sure is helpful… :confounded_face: )

i’ve verified that gstream’s libraries are installed :

$ sudo dnf list installed | grep -i gstream
gstreamer1.x86_64                              1.22.12-3.el9                    @appstream
gstreamer1-plugin-libav.x86_64                 1.22.1-1.el9                     @epel
gstreamer1-plugins-base.x86_64                 1.22.12-5.el9_7                  @appstream
gstreamer1-plugins-good.x86_64                 1.22.12-5.el9_7                  @appstream

i found the following when calling cv::getBuildInformation() :

  Video I/O:
    DC1394:                      NO
    GStreamer:                   YES (1.18.4)
    v4l/v4l2:                    YES (linux/videodev2.h)
    Intel Media SDK:             YES (/lib64/libmfx.so -lstdc++ /lib64/libdl.a /lib64/libva.so /lib64/libva-drm.so)

can anyone tell me what’s going wrong and how i can fix the problem?
what “required plugin”? where could this be?
reading MP4 video is pretty fundamental, i’m surprised it would be problematic right out of the box.

many thanks

OpenCV should be trying to use ffmpeg for this.

the other backends aren’t responsible. they figure that out by trying, and failing, to interpret the argument string.

opencv 4.6.0 is very much outdated. you are probably running into a bug that has long since been fixed.

try this again with the latest release.

if the issue still occurs in the latest release, then you can submit a bug report.

this could also be an issue with your system/distro. if you got your opencv precompiled as a package from some maintainer affiliated with the distro, get them involved.

1 Like

hi crackwitz,

thanks for the reply.

do you mean to say that opencv is fork/exec’ing ffmpeg to do its work for it?

no, this is just a straight dnf install of opencv for alma linux. apparently, we have the latest possible release. i guess i’ll be compiling this from scratch.

no.

ffmpeg is a library too. I’m saying OpenCV can call ffmpeg’s APIs, as part of VideoWriter and VideoCapture.

then i am reassured. :grinning_face:

ah. yes. you mean the libAV libraries (libavcodec.a, libavdevice.a, …) also used to build ffmpeg, and ffprobe. sorry, nomenclature skewered me. :laughing:

in any case, that’s all beside the point, which is that upgrading to 4.13 now allows opening of MP4 videos. thanks very much for your help. :slight_smile: