Skip to main content

Wrapper around OpenCV VideoWriter with some extra features

Project description

cv_videowriter

Wrapper around OpenCV VideoWriter with some extra features.

Features

  • Raise an exception if the video file is not created due to wrong configuration parameters.
  • Automatically select the video size based on the first written frame.
  • Raise an exception if the passed frame has a different size than the video size.
  • Add force resize option to resize the frame to a predefined size.
  • It will run cvtColor if the frame color is not the same as the video color. Or it will raise an exception if the frame color is not convertible to the video color.

Installation PyPI

pip install cv_videowriter

Usage

import cv2
import numpy as np
from cv_videowriter import VideoWriter

writer = VideoWriter('test.mp4', cv2.VideoWriter_fourcc(*'mp4v'), 30)

for i in range(10):
    frame = np.random.randint(0, 255, (460, 640, 3), dtype=np.uint8)
    writer.write(frame)

Parameters

  • filename: str - Path to the video file.
  • fourcc: int - FourCC code of the codec used to compress the frames.
  • fps: float (default: 30) - Frame rate of the created video.
  • force_resize: tuple[int, int] (default: None) - Resize the frame to the specified size (height, width) before writing it to the video file.
  • api_preference: int (default: cv2.CAP_ANY) - API backends for video capturing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cv_videowriter-0.1.0.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

cv_videowriter-0.1.0-py3-none-any.whl (3.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page