Skip to main content

Common Wrapper/Interface around various video reading/writing tools

Project description

Vidsz: Video's Wizard

CI-Test-Status CodeFactor status made-with-python Documentation Status Downloads

Common Wrapper/Interface around various video reading/writing tools to make video reading stable, consistent and super easy around different systems and OS.

pip install vidsz

Backends

  • OpenCV (in-development)

Features

  • Easy and hassle free (read/write with for-loop, with-block, while-loop)
  • Batch Support. Read and write frames in batches.

Read Video

Read with for-loop

from vidsz.opencv import Reader

# open reader
reader = Reader("static/countdown.mp4")

# read frame with for loop
for frame in reader:
    # use ndarry-frame however you like
    pass

# release
reader.release()

Read with a with-block

with Reader("static/countdown.mp4") as reader:
    frame = reader.read()

Read with a while-loop

# this follows similar behavior as opencv counterpart
while reader.is_open():
    # returns ndarry-frame or None if nothing left to read
    frame = reader.read()
    if frame is None:
        break

Read frames in a batch

with Reader("dummy.mp4", batch_size=8, dynamic_batch=True) as reader:
    batch_frames = reader.read()

Get properties of the reader

# print info: width, height, fps etc.
print(reader)

# access specific things
print(reader.width, reader.height, reader.fps)

# access number-of-frames/seconds/minutes that have been read
print(reader.frame_count, reader.seconds, reader.minutes)

Write Video

Write a single frame

from vidsz.opencv import Reader, Writer

video_fname = "static/countdown.mp4"

# open reader
reader = Reader(video_fname)

# start writer with the Reader object
# by default it'll append _out in the name of the output video
writer = Writer(reader)

# start writer with your settings;
# you can also give any combinations of
# following settings with Reader object to
# overwrite default settings
writer = Writer(name="out.mp4", width=1920, height=1080, fps=15)

# print writer info
print(writer)

# write single frame
frame = reader.read()
writer.write(frame)

Write with for-loop

# read frame with for loop
for frame in reader:
    # write the ndarry-frame
    writer.write(frame)

Write a batch

# read batches and write
with Reader("dummy.mp4", batch_size=8, dynamic_batch=True) as reader:
    batch_frames = reader.read()
    # write list or ndarray of frames
    writer.write_all(batch_frames)

# close off
reader.release()
writer.release()

Write with a with-block

# using "with" block, write "static/countdown_out.mp4" (clone of input)
with Reader(video_fname) as reader:
    with Writer(reader, name="out_with.mp4") as writer:
        writer.write_all(reader)

Logo-Attribution Designed by brgfx / Freepik

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

vidsz-deployment-test-0.1.0.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vidsz_deployment_test-0.1.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file vidsz-deployment-test-0.1.0.tar.gz.

File metadata

  • Download URL: vidsz-deployment-test-0.1.0.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for vidsz-deployment-test-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2dd065f30f90a7046180468ff3bd28dfb1354a8ed1063e23f0cf7b9b8bd6afcc
MD5 6c71d1aa39976712419c63dee2bbb9fa
BLAKE2b-256 4c08d323f1b72452d15a7a029dddf16e70a1307eb2a5aabcdfe02a79b742b0b9

See more details on using hashes here.

File details

Details for the file vidsz_deployment_test-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vidsz_deployment_test-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb1608e406a632c4e314ea1f5ea1b1d75e1e14d631a825f0b6f7c7c26ccbd99c
MD5 dae480461b2e81cf74dc2de0338e95d6
BLAKE2b-256 191f7181e5c57db4e348398852e2eacb249f8701a1e0528652ae152d31a11bec

See more details on using hashes here.

Supported by

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