Skip to content

VideoWriter fails silently for multiple codecs on macOS Intel #1192

@pauladkisson

Description

@pauladkisson

Summary

cv2.VideoWriter fails silently for multiple codecs (HFYU, XVID, mp4v) on macOS Intel (x86_64) in opencv-python-headless 4.13.0.90. No exception is raised, but isOpened() returns False and no video file is created.

This is a regression from 4.12.0.88, where all codecs work correctly.

Environment

  • OpenCV version: opencv-python-headless 4.13.0.90
  • Python version: 3.10.18
  • OS: macOS 15.7.2 (x86_64 / Intel)

Note: This bug only affects macOS Intel (x86_64), not macOS ARM (Apple Silicon).

Steps to reproduce

import os
import tempfile

import cv2
import numpy as np

print(f"OpenCV version: {cv2.__version__}")

test_dir = tempfile.mkdtemp()

codecs = ["MJPG", "HFYU", "XVID", "mp4v"]

print("\nTesting VideoWriter codecs:")
print("-" * 40)

for codec in codecs:
    video_path = os.path.join(test_dir, f"test_{codec}.avi")

    writer = cv2.VideoWriter(
        filename=video_path,
        fourcc=cv2.VideoWriter_fourcc(*codec),
        fps=25,
        frameSize=(200, 100),
    )

    opened = writer.isOpened()
    status = "OK" if opened else "FAILED"

    if opened:
        frame = np.random.randint(0, 255, size=(100, 200, 3), dtype="uint8")
        writer.write(frame)
        writer.release()
        os.remove(video_path)
    else:
        writer.release()

    print(f"{codec:6} : {status}")

os.rmdir(test_dir)

Expected behavior

All standard codecs should work:

OpenCV version: 4.12.0

Testing VideoWriter codecs:
----------------------------------------
MJPG   : OK
HFYU   : OK
XVID   : OK
mp4v   : OK

Actual behavior

Only MJPG works; other codecs fail silently:

OpenCV version: 4.13.0

Testing VideoWriter codecs:
----------------------------------------
[ WARN:0@0.056] global cap.cpp:781 open VIDEOIO(CV_IMAGES): raised OpenCV exception:

OpenCV(4.13.0) /Users/macmini_16g/GHA-Actions-Opencv-Python/_work/opencv-python/opencv-python/opencv/modules/videoio/src/cap_images.cpp:411: error: (-215:Assertion failed) !filename_pattern.empty() in function 'CvVideoWriter_Images'


MJPG   : OK
[ WARN:0@0.104] global cap.cpp:781 open VIDEOIO(CV_IMAGES): raised OpenCV exception:

OpenCV(4.13.0) /Users/macmini_16g/GHA-Actions-Opencv-Python/_work/opencv-python/opencv-python/opencv/modules/videoio/src/cap_images.cpp:411: error: (-215:Assertion failed) !filename_pattern.empty() in function 'CvVideoWriter_Images'


HFYU   : FAILED
[ WARN:0@0.104] global cap.cpp:781 open VIDEOIO(CV_IMAGES): raised OpenCV exception:

OpenCV(4.13.0) /Users/macmini_16g/GHA-Actions-Opencv-Python/_work/opencv-python/opencv-python/opencv/modules/videoio/src/cap_images.cpp:411: error: (-215:Assertion failed) !filename_pattern.empty() in function 'CvVideoWriter_Images'


XVID   : FAILED
mp4v   : FAILED

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions