Skip to main content

Media I/O with FFmpeg

Project description

PyPI PyPI - Status PyPI - Python Version GitHub GitHub Workflow Status

Python ffmpegio package aims to bring the full capability of FFmpeg to read, write, and manipulate multimedia data to Python. FFmpeg is an open-source cross-platform multimedia framework, which can handle most of the multimedia formats available today.

Main Features

  • Pure-Python light-weight package interacting with FFmpeg executable found in the system

  • Transcode a media file to another in Python

  • Read, write, filter, and create functions for audio, image, and video data

  • Context-managing ffmpegio.open to perform stream read/write operations of video and audio

  • Automatically detect and convert audio & video formats to and from numpy.ndarray properties

  • Probe media file information

  • Accepts all FFmpeg options including filter graphs

  • Supports a user callback whenever FFmpeg updates its progress information file (see -progress FFmpeg option)

  • Advanced users can gain finer controls of FFmpeg I/O with ffmpegio.ffmpegprocess submodule

  • More features to follow

Documentation

Visit our GitHub page here

Examples

>>> import ffmpegio

>>> # read audio samples from 24.15 seconds to 63.2 seconds, pre-convert to mono in float data type
>>> fs, x = ffmpegio.audio.read('myaudio.wav', ss=24.15, to=63.2, sample_fmt='dbl', ac=1)

>>> # read 50 video frames at t=00:32:40, pre-convert to grayscale
>>> fs, x = ffmpegio.video.read('myvideo.mp4', ss='00:32:40', vframes=50, pix_fmt='gray')

>>> # capture video frame at t=0.24 and resize it to 540px wide and height proportionally
>>> # scaled with assuring even # of pixels
>>> x = ffmpegio.image.read('myvideo.mp4', ss=0.24, s=(540,-2))

>>> # save numpy array x as an audio file at 24000 samples/second
>>> ffmpegio.audio.write('outputvideo.mp4', 24000, x)

>>> # process video 100 frames at a time and save output as a new video
>>> # with the same frame rate
>>> fs = ffmpegio.probe.video_streams_basic('myvideo.mp4')[0]['frame_rate']
>>> with ffmpegio.open('myvideo.mp4', 'rv', blocksize=100) as f,
>>>      ffmpegio.open('myoutput.mp4', 'wv', rate=fs) as g:
>>>     for frames in f:
>>>         g.write(myprocess(frames))

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

ffmpegio-0.1.2.tar.gz (74.8 kB view details)

Uploaded Source

Built Distribution

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

ffmpegio-0.1.2-py3-none-any.whl (80.8 kB view details)

Uploaded Python 3

File details

Details for the file ffmpegio-0.1.2.tar.gz.

File metadata

  • Download URL: ffmpegio-0.1.2.tar.gz
  • Upload date:
  • Size: 74.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for ffmpegio-0.1.2.tar.gz
Algorithm Hash digest
SHA256 091a51f277c71e278b6872d7a3215699f370f4144aa8f8cdb7a8c3483580498d
MD5 71412926977b585c9a52be8abf77213a
BLAKE2b-256 e9af09e6e1d70b9e28803bed92b95b2652f09baa6835df6a863974794a045c0b

See more details on using hashes here.

File details

Details for the file ffmpegio-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: ffmpegio-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 80.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for ffmpegio-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8a673192a7cae6ec7c1d1b433c09911e010d8eacc585e7a549a70052a39c1c53
MD5 a552277a090155895eebc9052d7cd354
BLAKE2b-256 512af7c12a9f772f472130e02e95613198519268e107889c0cc34ec242cc9850

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