Skip to main content

FFmpeg-Encoder-Decoder-for-Python

This is a mpegCoder adapted from FFmpeg & Python-c-api. Using it you could get access to processing video easily. Just use it as a common module in python like this.

import mpegCoder
Branch Description
master The source project of mpegCoder, Windows version.
master-linux The source project of mpegCoder, Linux version.
example-client-check A testing project of the online video stream demuxing.
example-client-player A testing project of the simple online video stream player.

Documentation

The documentation could be reviewed here:

https://cainmagi.github.io/FFmpeg-Encoder-Decoder-for-Python

Brief introduction of this project

This project is also named as "FFmpeg-Encoder-Decoder-for-Python". It is implemented based on FFMpeg, Python-C-API and C++11. It is under GPL v3 License, and recommended for researching purposes. The project could be used for processing or streaming videos.

With this package, users could:

  • Make use of all FFMpeg video encoders and decoders. When decoding a video (or an online stream), like the original FFMpeg (C version), the provided APIs could detect the video format and codec format automatically. When encoding a video, users could control the codec format, bit rate and some other options by setting parameters.
  • Work with FFMpeg directly. This project invokes the FFMpeg C APIs in the bottom level. Unlike ffmpeg-python and pyffmpeg, our project is not driven by the FFMpeg CLI interfaces. The data format used by this package is np.ndarray. In other words, our project enables users to combine numpy and FFMpeg directly.
  • Frame-level APIs. Unlike pyffmpeg, this package is not a simple wrapper of FFMpeg. Users could works on the frame-level APIs. For example, when decoding a video, users could get the data frame-by-frame. Each frame is a 3D np.ndarray.
  • Pre-compiled package. This package has been pre-compiled by the author. If users download the dependent dynamic libraries (.so or .dll), they do not need to compile the package by themself.

However, users could not work with this project in such cases:

  • Platform limited. Currently, we only support Linux and Windows. The Linux release is pre-compiled on Debian. It has been only tested in Ubuntu, Debian and Windows. In other cases, the pre-compiled library may not work. Users may need to compile the package by themselves.
  • Version limited. Currently, our project works with FFMpeg 4.4, and 5.0. Users need to download the dependent dynamic libraries to make the package work. The pip version is able to download the libraries automatically. The legacy versions of this project supports FFMpeg 3.3, 3.4.2 and 4.0. However, the legacy built packages are not technically supported now.
  • Audio not supported. Although the original FFMpeg supports both video and audio streams, our project only works on video streams. For example, if a video contains audio streams, our package would omit all audio frames in the bottom level. In other words, you could not perform audio analysis now. In the future (v4), we may support the audio frame analysis.
  • Filters not supported. Although the original FFMpeg supports some video processing tools (avfilter and postproc), our implementation drops these modules. Instead, we suggest that users should process the frames with pillow or openCV. On the other hand, our implementation still supports frame scaling and re-sampling (supported by swscale and swresample).

An example of the usage

Here we show an example of transcoding a video with our decoder and encoder. To learn more details, please review the documentation.

import mpegCoder

d = mpegCoder.MpegDecoder()
d.setParameter(nthread=4)
opened = d.FFmpegSetup('test-video.mp4')  # Setup the decoder
e = mpegCoder.MpegEncoder()
e.setParameter(decoder=d, codecName='libx265', videoPath='test-video-x265.mp4', nthread=8)  # inherit most of parameters from the decoder.
opened = opened and e.FFmpegSetup()  # Setup the encoder.
if opened:  # If either the decoder or the encoder is not loaded successfully, do not continue.
    p = True
    while p is not None:
        p = d.ExtractGOP()  # Extract current GOP.
        if p is not None:
            for i in p:  # Iterate every frame.
                e.EncodeFrame(i)  # Encode current frame.
    e.FFmpegClose() # End encoding, and flush all frames in cache.
e.clear()  # Clean configs of the encoder.
d.clear()  # Close configs of the decoder.

Metadata

Release files for mpegCoder 3.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for mpegCoder 3.2.4
File
mpegCoder-3.2.4-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
mpegCoder-3.2.4-cp310-cp310-manylinux1_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.5+ x86-64 Details
mpegCoder-3.2.4-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
mpegCoder-3.2.4-cp39-cp39-manylinux1_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.5+ x86-64 Details
mpegCoder-3.2.4-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
mpegCoder-3.2.4-cp38-cp38-manylinux1_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64 Details
mpegCoder-3.2.4-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
mpegCoder-3.2.4-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details
mpegCoder-3.2.4-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
mpegCoder-3.2.4-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details

Total release size: 210.2 kB

Release files / mpegCoder-3.2.4-cp310-cp310-win_amd64.whl

Download URL mpegCoder-3.2.4-cp310-cp310-win_amd64.whl
Size 20.8 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
cc75fb0009fd6a260a3d48200b743555d00dc71c6ef3165a488c5586c976e2d5
BLAKE2b-256 checksum
How to use checksums
4d2b0bf17420222e1caba99299c9ee1afb62b826a83d907ce707c5fc815cb1e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release files / mpegCoder-3.2.4-cp310-cp310-manylinux1_x86_64.whl

Download URL mpegCoder-3.2.4-cp310-cp310-manylinux1_x86_64.whl
Size 21.3 kB
Tags CPython 3.10 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
75a1d13df25f4f8f4f85c82f36d34f3e503daa83f83b9f86e1f0bfed77d8ec46
BLAKE2b-256 checksum
How to use checksums
34b7c20d27cb11d22c70eb646ed7c9e60b5c75ee438bafa1ff62089d3b1ef5c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release files / mpegCoder-3.2.4-cp39-cp39-win_amd64.whl

Download URL mpegCoder-3.2.4-cp39-cp39-win_amd64.whl
Size 20.8 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
2382245ea59b5eb183c3041182798ffa474b5be9389a85d05965cca503bee126
BLAKE2b-256 checksum
How to use checksums
2a56014eef91ef26c729b89e5e72391e2f716a215bb259ed5bf353b975c648cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release files / mpegCoder-3.2.4-cp39-cp39-manylinux1_x86_64.whl

Download URL mpegCoder-3.2.4-cp39-cp39-manylinux1_x86_64.whl
Size 21.3 kB
Tags CPython 3.9 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
38892250c2c11c53eb7219b66ab6dcec1bdc32511f188dde509187866573758b
BLAKE2b-256 checksum
How to use checksums
cc15fd8e2044af939503c8d305dcadd0040cc7b903fff0b7b3000c431b31e7c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release files / mpegCoder-3.2.4-cp38-cp38-win_amd64.whl

Download URL mpegCoder-3.2.4-cp38-cp38-win_amd64.whl
Size 20.8 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
80f428d7c56e7bd34931488cd2d7236d8d49e600804e9842eef260db5ec9a926
BLAKE2b-256 checksum
How to use checksums
4ab4a2a02279d3771ca3a4d19c035dbfaa87c5fba08bae41eee28226cd5dd8f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.10

Release files / mpegCoder-3.2.4-cp38-cp38-manylinux1_x86_64.whl

Download URL mpegCoder-3.2.4-cp38-cp38-manylinux1_x86_64.whl
Size 21.3 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
4b047b7d8d3ed0057a0df39dd254a49b6d659ad7c2671b4226950688655578fb
BLAKE2b-256 checksum
How to use checksums
14b398a2d8350938950f619b309a20142345d868b2c96b216d5a7f30e5b66847
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.12

Release files / mpegCoder-3.2.4-cp37-cp37m-win_amd64.whl

Download URL mpegCoder-3.2.4-cp37-cp37m-win_amd64.whl
Size 20.7 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
b3dc1609f4dc2f9dc9b929c0cee7b9a94b0efdcde5a77e298e5428ae65dbdbe0
BLAKE2b-256 checksum
How to use checksums
7d0236bb7125dfea5a450240c98aefe3f71181a8bdeb71b9db449075e9c59a05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.9

Release files / mpegCoder-3.2.4-cp37-cp37m-manylinux1_x86_64.whl

Download URL mpegCoder-3.2.4-cp37-cp37m-manylinux1_x86_64.whl
Size 21.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
57a614ac303ed31b87b4f6d30cecf828813abc0e75d0d27c7142af3058e89123
BLAKE2b-256 checksum
How to use checksums
4875e6f974b348de539301c6a81805af198837cad38f5939b17d91f741a2e394
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.12

Release files / mpegCoder-3.2.4-cp36-cp36m-win_amd64.whl

Download URL mpegCoder-3.2.4-cp36-cp36m-win_amd64.whl
Size 20.8 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
d9088ff39a3c6abf7ef19b540a1edd977cab19fbf591ffb33f50748f7ad40084
BLAKE2b-256 checksum
How to use checksums
16bc43c3313a9fdbd680b241ca7e03354d2b995afeb3793f57bb2c0eac6a96c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.8

Release files / mpegCoder-3.2.4-cp36-cp36m-manylinux1_x86_64.whl

Download URL mpegCoder-3.2.4-cp36-cp36m-manylinux1_x86_64.whl
Size 21.3 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
7d9be047cbdc7d13f3dce621ea4d25b1dc273ee7ada38c4a9583e26df54d865d
BLAKE2b-256 checksum
How to use checksums
2a5d94513921615d27ffbf46136f781d21ccbbb56b16bef2f1b09cabde499d41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.15

Release history Release notifications | RSS feed

This release

3.2.4 This release

10 release files

3.2.3

10 release files

3.2.2

10 release files

3.2.1

10 release files

3.2.0

10 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page