Skip to main content

Shared utilities for processing videos for sign language.

Project description

Simple Video Utils

Lightweight utilities for extracting frames and metadata from videos. Built for sign language processing workflows.

Python License

Goal

Provide simple, efficient tools for video processing in sign language research and applications. Uses PyAV for fast frame extraction with support for multiple formats (MP4, WebM) and remote URLs.

Installation

pip install simple-video-utils

Usage

Extract Video Metadata

from simple_video_utils.metadata import video_metadata

meta = video_metadata("video.mp4")
print(f"{meta.width}x{meta.height} @ {meta.fps} fps, {meta.duration}s")
# Output: VideoMetadata(width=1920, height=1080, fps=30.0, nb_frames=450, time_base='1/15360', duration=15.0)

Read Frames from File

from simple_video_utils.frames import read_frames_exact

# Read specific frame range (inclusive)
frames = list(read_frames_exact("video.mp4", start_frame=0, end_frame=10))
# Returns 11 frames as numpy arrays (H, W, 3) in RGB format

# Read from frame to end of video
frames = list(read_frames_exact("video.mp4", start_frame=5, end_frame=None))

# Downsample to a target frame rate (drops frames uniformly, never duplicates)
frames = list(read_frames_exact("video.mp4", fps=15))

Read Frames from Stream

from simple_video_utils.frames import read_frames_from_stream

# Useful for uploaded files or in-memory video data
with open("video.mp4", "rb") as f:
    meta, frames_gen = read_frames_from_stream(f)
    for frame in frames_gen:
        # Process each frame (numpy array)
        pass

Slice into Clips

from simple_video_utils.slicing import slice_video

# One MP4 (bytes) per (start, end) second range
clips = slice_video("video.mp4", [(0.0, 1.5), (2.0, 3.2)])

# Center-crop to a square and resize to 256x256 (e.g. for model input)
clips = slice_video("video.mp4", [(0.0, 1.5)], size=256)

Remote Videos

from simple_video_utils.metadata import video_metadata
from simple_video_utils.frames import read_frames_exact

# Works with remote URLs
url = "https://example.com/video.mp4"
meta = video_metadata(url)
frames = list(read_frames_exact(url, 0, 5))

Development

pip install -e ".[dev]"
pytest tests/
ruff check .

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

simple_video_utils-0.5.2.tar.gz (27.3 kB view details)

Uploaded Source

Built Distribution

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

simple_video_utils-0.5.2-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file simple_video_utils-0.5.2.tar.gz.

File metadata

  • Download URL: simple_video_utils-0.5.2.tar.gz
  • Upload date:
  • Size: 27.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for simple_video_utils-0.5.2.tar.gz
Algorithm Hash digest
SHA256 babd36dff32bef27009170c335143043c46086ce1652c3880163ea64faedfd03
MD5 ab395b9b6d081dda56e3e986fa488de5
BLAKE2b-256 ab964fc9a021a4784edf0aac7d6adf68eeec03a3c89a71f93c9f1348cdc307d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_video_utils-0.5.2.tar.gz:

Publisher: release.yaml on sign/simple-video-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simple_video_utils-0.5.2-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_video_utils-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 84554ff02b02c7fe3bb8d0f5cfccd647adba07f6119c5a417a35bba74b463d5a
MD5 b4dd9235795a864699d0c7406814f88b
BLAKE2b-256 e463f9e627618e0dc99bde32651f437b0aa9bd7d5190af9989dfcbd6f461ba1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_video_utils-0.5.2-py3-none-any.whl:

Publisher: release.yaml on sign/simple-video-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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