Can not open a sony mxf video file on Fedora

Hi,

I am trying to open a sony mxf video file with the following python code:

import cv2
file="./A006C004_201031PG.mxf"
type orcap = cv2.VideoCapture(file)
print(cap)

while not cap.isOpened():
    cap = cv2.VideoCapture(file)
    cv2.waitKey(1000)

The code never passes the open statement, it just hangs
I am able to read and process the file with ffmpeg. The video uses the h.264 codec.
I am able to open other containers on my linux (fedora 37) system.
I have converted the file to a mp4 container and can read it in.

I have set
OPENCV_VIDEOIO_DEBUG=1
and get this result
`` WARN:0@0.481] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/cap.cpp (130) open VIDEOIO(FFMPEG): trying capture filename=‘./A006C004_201031PG.mxf’ …
[ WARN:0@0.488] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/cap.cpp (190) open VIDEOIO(FFMPEG): backend is not available (plugin is missing, or can’t be loaded due dependencies or it is not compatible)
[ WARN:0@0.488] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/cap.cpp (130) open VIDEOIO(GSTREAMER): trying capture filename=‘./A006C004_201031PG.mxf’ …`


Are there plugins available or do I have to recompile?  I can not find any plugins.

Thanks.

render

HI,

I would like to also add that I get this feedback:

INTEL_MFX): trying capture filename='./A006C004_201031PG.MXF' ...
libva info: VA-API version 1.16.0
libva info: Trying to open /usr/lib64/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_16
libva info: va_openDriver() returns 0
MFX: Unsupported extension: ./A006C004_201031PG.MXF

[ WARN:0@7.914] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/cap.cpp (142) open VIDEOIO(INTEL_MFX): created, isOpened=0
[ WARN:0@7.916] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/cap.cpp (130) open VIDEOIO(V4L2): trying capture filename='./A006C004_201031PG.MXF' ...
[ WARN:0@7.916] global /builddir/build/BUILD/opencv-4.6.0/modules/videoio/src/cap.cpp (153) open VIDEOIO(V4L2): can't create capture

Thanks.

render

How did you get your OpenCV and why is it not the latest release?

Hi,

I acquired opencv from the package manager for fc37. The release is 4.6.0 7.fc37. This is on a dell xps with an intel processor. The h.264 codecs I have are

gst-inspect-1.0 | grep 264
libav:  avmux_ipod: libav iPod H.264 MP4 (MPEG-4 Part 14) muxer
openh264:  openh264dec: OpenH264 video decoder
openh264:  openh264enc: OpenH264 video encoder
rtp:  rtph264depay: RTP H264 depayloader
rtp:  rtph264pay: RTP H264 payloader
typefindfunctions: video/x-h264: h264, x264, 264
uvch264:  uvch264deviceprovider (GstDeviceProviderFactory)
uvch264:  uvch264mjpgdemux: UVC H264 MJPG Demuxer
uvch264:  uvch264src: UVC H264 Source
va:  vah264dec: VA-API H.264 Decoder
va:  varenderD129h264dec: VA-API H.264 Decoder in renderD129
vaapi:  vaapih264dec: VA-API H264 decoder
vaapi:  vaapih264enc: VA-API H264 encoder
videoparsersbad:  h264parse: H.264 parser
x264:  x264enc: x264 H.264 Encoder

My ffmpeg codecs are

ffmpeg -decoders 2>/dev/null | grep 264
 VFS..D h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
 V..... h264_v4l2m2m         V4L2 mem2mem H.264 decoder wrapper (codec h264)
 V....D h264_qsv             H264 video (Intel Quick Sync Video acceleration) (codec h264)
 V....D libopenh264          OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
 V..... h264_cuvid           Nvidia CUVID H264 decoder (codec h264)

I have successfully opened the video on another platform using an amd processor. The opencv release is the same. I see that my intel based platform has

libav:  WARNING No decoder available for type 'video/x-h264, libav H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 decoder

and does not have

va:  vah264dec: VA-API H.264 Decoder
va:  varenderD129h264dec: VA-API H.264 Decoder in renderD129
vaapi:  vaapih264dec: VA-API H264 decoder
vaapi:  vaapih264enc: VA-API H264 encoder

One both platforms I have installed

gstreamer1-plugin-libav
gstreamer1-plugin-openh264
gstreamer1-plugin-bad-free
gstremer1-plugin-bad-free-extras
gstreamer1-plugin-bad-freeworld
gstreamer1-plugins-base

My amd platform (works) does not have any packages that my intel platform (does not work) has.

I assume that the not having

libav:  avdec_264: libav H.264 / AVC / ^CEG-4 AVC / MPEG-4 part 10 decoder

is the reason that my intel platform does not handle this mxf video. But I have all the same packages loaded on the platform that does not work as on the platform that does work to my knowledge.

Running gst-play-1.0 on the video indicates that I am missing

WARNING No decoder available for type 'video/x-h264,

Your thoughts?

Thanks.

render

contact the package maintainer. it’s their job to make sure this stuff works.

official opencv packages don’t have this issue. they come with ffmpeg.

you are on linux. installing some library doesn’t mean other programs use that instance. there is no system-wide API to provide ffmpeg’s services to other programs. programs are either compiled to use some ffmpeg, that they depend on hard or bring it along themselves, or it just doesn’t happen.

your “intel” platform has nothing to do with this.

chuck all that, install the official OpenCV package for Python (opencv-python on PyPI), and you’re done. that is why official packages exist, because various distros and their “maintained” packages are a huge headache to all the projects that are expected to support all kinds of linux distros and their inadequate packaging.

Hi,

I appreciate your help. I did install opencv-python as suggested and I am able to process the video file as I do other video files. Thank you.

However, now I get this error for my matplotlib calls. Something got squished (maybe from the last install ?) References to plot, xlabel, ylabel and grid cores the script.

QObject::moveToThread: Current thread (0x5596694987e0) is not the object's thread (0x55966a503fa0).
Cannot move to target thread (0x5596694987e0)

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/adi/.local/lib/python3.11/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx.

I googled the thread issue and found

It stated:

As noted already, the basis for this problem is discussed in [opencv-python issue 46](https://github.com/skvark/opencv-python/issues/46), and results from the duplication of the following libraries both on the host and the opencv-python distro **libQtDBus** **libQtCore** and **libQtGui**.

It has been lately addressed in the newest release of opencv-python. It is not a fix to the source code, rather the fix is to force **pip** to compile the newly available source via

and suggested

pip install --no-binary opencv-python opencv-python

but this and it still did not work. I unistalled opencv-python and then reinstalled with the no-binary flag and then my script failed since it could not import cv2.

Traceback (most recent call last):
  File "/home/adi/Desktop/velocity_measurement.py", line 4, in <module>
    import cv2
  File "/home/adi/.local/lib/python3.11/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/home/adi/.local/lib/python3.11/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

However, I tested a simple plot script and it worked.

Thoughts?

render

might be time to file an issue (or check for existing one and add your situation) on Issues · opencv/opencv · GitHub

Hi,

Okay and again thank you for your time.

render