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.
Metadata
Release files for ffms 0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ffms-0.4.tar.gz | 4.7 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ffms-0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.7 MB
Release files / ffms-0.4.tar.gz
| Download URL | ffms-0.4.tar.gz |
|---|---|
| Size | 4.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4f77347b20a4c5f841db0b5c25eb6b6f917f181132745a44cb79afc41dcea7c
|
|
BLAKE2b-256 checksum How to use checksums |
78a51ca4a6cda0af0bb8f10454967fe01355dba5c02920e44bd2ca4846680e61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / ffms-0.4-py3-none-any.whl
| Download URL | ffms-0.4-py3-none-any.whl |
|---|---|
| Size | 34.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
09a80149974f95f2a41f49d0c5b71d2d035b0930b51ab58ed2090b08470775b5
|
|
BLAKE2b-256 checksum How to use checksums |
1c4dc1d7c6d9399a1f58b0cf71ad229ac3a202bd1433c2a7cad565d52f840b06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|