Bindings for FFmpegSource
Project description
Example usage
If you don’t need to keep the index, create a video source right away:
>>> import ffms >>> source_file = "test/CINT_Nik_H264_720_512kb.mp4" >>> vsource = ffms.VideoSource(source_file)
Or you can create an indexer:
>>> indexer = ffms.Indexer(source_file) >>> indexer.format_name 'mov,mp4,m4a,3gp,3g2,mj2' >>> indexer.track_info_list [TrackInfo(type=0, codec_name='h264'), TrackInfo(type=1, codec_name='aac')]
Then create the index for the video source:
>>> index = indexer.do_indexing(-1) >>> track_number = index.get_first_indexed_track_of_type(ffms.FFMS_TYPE_VIDEO) >>> vsource = ffms.VideoSource(source_file, track_number, index)
Extract information from the video source:
>>> vsource.properties.NumFrames 1430 >>> vsource.track.keyframes[:5] [0, 12, 24, 36, 48] >>> vsource.track.timecodes[:5] [0.0, 41.666666666666664, 83.33333333333333, 125.0, 166.66666666666666]
Retrieve a video frame:
>>> frame = vsource.get_frame(0) >>> frame.EncodedWidth, frame.EncodedHeight (416, 240) >>> frame.planes[0] array([41, 41, 41, ..., 0, 0, 0], dtype=uint8)
Audio stuff:
>>> track_number = index.get_first_indexed_track_of_type(ffms.FFMS_TYPE_AUDIO)
>>> asource = ffms.AudioSource(source_file, track_number, index)
>>> aprops = asource.properties
>>> aprops.SampleRate, aprops.BitsPerSample, aprops.Channels
(48000, 32, 2)
>>> min_audio, max_audio = float("inf"), float("-inf")
>>> for audio in asource.linear_access(rate=100):
... if audio.min() < min_audio:
... min_audio = audio.min()
... if audio.max() > max_audio:
... max_audio = audio.max()
>>> min_audio, max_audio
(-0.4941235, 0.57445675)
ffmsinfo.py is a demo script showing how this package can be used.
Installation
Install from PyPI:
$ pip install ffms
Or install the latest version from source:
$ pip install git+https://github.com/hiddenspirit/ffms
You also need the FFmpegSource shared library (libffms2) installed and reachable by the dynamic loader. On Debian/Ubuntu:
$ sudo apt install libffms2-5
On Windows, place ffms2.dll (or ffms2-x64.dll) next to your script or in a directory on the library search path.
Prerequisites
FFmpegSource (the libffms2 shared library)
pywin32 (Windows only)
The API was designed to be an object-oriented and Pythonic version of the original FFmpegSource API.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ffms-0.4.tar.gz.
File metadata
- Download URL: ffms-0.4.tar.gz
- Upload date:
- Size: 4.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4f77347b20a4c5f841db0b5c25eb6b6f917f181132745a44cb79afc41dcea7c
|
|
| MD5 |
90432bf1f052d8c537c8e6720035fb55
|
|
| BLAKE2b-256 |
78a51ca4a6cda0af0bb8f10454967fe01355dba5c02920e44bd2ca4846680e61
|
File details
Details for the file ffms-0.4-py3-none-any.whl.
File metadata
- Download URL: ffms-0.4-py3-none-any.whl
- Upload date:
- Size: 34.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09a80149974f95f2a41f49d0c5b71d2d035b0930b51ab58ed2090b08470775b5
|
|
| MD5 |
589811737cfbdb80a5dfe1911143e3cc
|
|
| BLAKE2b-256 |
1c4dc1d7c6d9399a1f58b0cf71ad229ac3a202bd1433c2a7cad565d52f840b06
|