Skip to main content

Tools for video and audio editing

Project description

mixing

Tools for video and audio editing

To install: pip install mixing

Examples

mixing.video

VideoFrames: Dictionary-like access to video frames

VideoFrames provides a Mapping interface to access individual frames from a video file by index. Frames are returned as numpy arrays (BGR format).

from mv.util import VideoFrames

# Create frame accessor
frames = VideoFrames("my_video.mp4")

# Access frames by index
first_frame = frames[0]
last_frame = frames[-1]  # Negative indexing supported
middle_frame = frames[len(frames) // 2]

# Slice to get multiple frames (returns an iterator, not a list)
for frame in frames[10:50]:
    # Process frames 10 through 49
    pass

# Get every 5th frame
for frame in frames[::5]:
    # Process every 5th frame
    pass

save_frame: Extract and save video frames as images

Convenience function to extract a single frame from a video and save it as an image.

from mv.util import save_frame

# Save first frame with auto-generated filename (video_0.png)
save_frame("my_video.mp4")

# Save frame 100 as JPEG
save_frame("my_video.mp4", 100, saveas=".jpg")  # Saves as my_video_000100.jpg

# Save last frame to specific path
save_frame("my_video.mp4", -1, saveas="output/last_frame.png")

The saveas parameter accepts:

  • None (default): Auto-generate filename in video's directory
  • .ext: Use this extension with auto-generated filename
  • Full path: Save to this specific location

write_subtitles_in_video

Write subtitles in a video.

Example usage:

>>> from mixing import write_subtitles_in_video
>>> output_path = write_subtitles_in_video("~/Downloads/some_video.mp4") 

Which is syntactic sugar for the more explicit:

>>> output_path = write_subtitles_in_video(
...     "~/Downloads/some_video.mp4", 
...     subtitles="~/Downloads/some_video.srt",
...     output_video="~/Downloads/some_video.mp4"
... )  

Further requirements

FFmpeg

Many of the tools also require ffmeg.

To install FFmpeg on your system, follow the instructions for your operating system below.

macOS

  1. Using Homebrew:
    • Open Terminal.
    • Run the following command:
      brew install ffmpeg
      

For more details, visit the FFmpeg installation page for macOS.

Linux

  1. Using the package manager:
    • For Debian/Ubuntu-based distributions, run:
      sudo apt update
      sudo apt install ffmpeg
      
    • For Fedora, run:
      sudo dnf install ffmpeg
      
    • For Arch Linux, run:
      sudo pacman -S ffmpeg
      

For more details, visit the FFmpeg installation page for Linux.

Windows

  1. Using Windows builds:
    • Download the executable from FFmpeg for Windows.
    • Extract the downloaded files and add the bin directory to your system's PATH.

For more details, visit the FFmpeg installation page for Windows.

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

mixing-0.0.4.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

mixing-0.0.4-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file mixing-0.0.4.tar.gz.

File metadata

  • Download URL: mixing-0.0.4.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for mixing-0.0.4.tar.gz
Algorithm Hash digest
SHA256 5e50e32e3912b3c90f42ca5ce1c8ca7802a8343157286ee8f8e8fd462164ce42
MD5 c1c4ec4b11a2b43fcc7b6810f5b0fea5
BLAKE2b-256 6fc311b91e4af177cacbefd49835a6fa3b4d6f5efa9224271b81ced55f623b6a

See more details on using hashes here.

File details

Details for the file mixing-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: mixing-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for mixing-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 866a76e6c9ca0809d06962466fecb48b313db9ee287423b46c1ba10354cddf1d
MD5 b603ce0c6ab64e6d7cad925d227284fd
BLAKE2b-256 409b1a7a3accaf6f85e48561fe0cee9a603575d2daa3dfacad030f69d6a7bee0

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