Skip to main content

A FFmpeg module which could provide a class for encoding, decoding, or streaming a video in any format.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

mpegCoder-3.2.4-cp310-cp310-win_amd64.whl (20.8 kB view details)

Uploaded CPython 3.10 Windows x86-64

mpegCoder-3.2.4-cp310-cp310-manylinux1_x86_64.whl (21.3 kB view details)

Uploaded CPython 3.10

mpegCoder-3.2.4-cp39-cp39-win_amd64.whl (20.8 kB view details)

Uploaded CPython 3.9 Windows x86-64

mpegCoder-3.2.4-cp39-cp39-manylinux1_x86_64.whl (21.3 kB view details)

Uploaded CPython 3.9

mpegCoder-3.2.4-cp38-cp38-win_amd64.whl (20.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

mpegCoder-3.2.4-cp38-cp38-manylinux1_x86_64.whl (21.3 kB view details)

Uploaded CPython 3.8

mpegCoder-3.2.4-cp37-cp37m-win_amd64.whl (20.7 kB view details)

Uploaded CPython 3.7m Windows x86-64

mpegCoder-3.2.4-cp37-cp37m-manylinux1_x86_64.whl (21.2 kB view details)

Uploaded CPython 3.7m

mpegCoder-3.2.4-cp36-cp36m-win_amd64.whl (20.8 kB view details)

Uploaded CPython 3.6m Windows x86-64

mpegCoder-3.2.4-cp36-cp36m-manylinux1_x86_64.whl (21.3 kB view details)

Uploaded CPython 3.6m

File details

Details for the file mpegCoder-3.2.4-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for mpegCoder-3.2.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cc75fb0009fd6a260a3d48200b743555d00dc71c6ef3165a488c5586c976e2d5
MD5 175c1ba33c24fb8fe6fb4c81eb211efd
BLAKE2b-256 4d2b0bf17420222e1caba99299c9ee1afb62b826a83d907ce707c5fc815cb1e7

See more details on using hashes here.

File details

Details for the file mpegCoder-3.2.4-cp310-cp310-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mpegCoder-3.2.4-cp310-cp310-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 75a1d13df25f4f8f4f85c82f36d34f3e503daa83f83b9f86e1f0bfed77d8ec46
MD5 e485c19ed1f7161d4b21ee800ab4c212
BLAKE2b-256 34b7c20d27cb11d22c70eb646ed7c9e60b5c75ee438bafa1ff62089d3b1ef5c3

See more details on using hashes here.

File details

Details for the file mpegCoder-3.2.4-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: mpegCoder-3.2.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for mpegCoder-3.2.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 2382245ea59b5eb183c3041182798ffa474b5be9389a85d05965cca503bee126
MD5 37c6fd4d75d679d38c1de284454b0878
BLAKE2b-256 2a56014eef91ef26c729b89e5e72391e2f716a215bb259ed5bf353b975c648cc

See more details on using hashes here.

File details

Details for the file mpegCoder-3.2.4-cp39-cp39-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mpegCoder-3.2.4-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 38892250c2c11c53eb7219b66ab6dcec1bdc32511f188dde509187866573758b
MD5 30fd455e0312e1f0107c6e6f1888db12
BLAKE2b-256 cc15fd8e2044af939503c8d305dcadd0040cc7b903fff0b7b3000c431b31e7c5

See more details on using hashes here.

File details

Details for the file mpegCoder-3.2.4-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: mpegCoder-3.2.4-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for mpegCoder-3.2.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 80f428d7c56e7bd34931488cd2d7236d8d49e600804e9842eef260db5ec9a926
MD5 9d98a942ba01ea002c943520bdfedafb
BLAKE2b-256 4ab4a2a02279d3771ca3a4d19c035dbfaa87c5fba08bae41eee28226cd5dd8f4

See more details on using hashes here.

File details

Details for the file mpegCoder-3.2.4-cp38-cp38-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mpegCoder-3.2.4-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4b047b7d8d3ed0057a0df39dd254a49b6d659ad7c2671b4226950688655578fb
MD5 cf5ee3cdbd52da2805cebdcfa98c21d3
BLAKE2b-256 14b398a2d8350938950f619b309a20142345d868b2c96b216d5a7f30e5b66847

See more details on using hashes here.

File details

Details for the file mpegCoder-3.2.4-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for mpegCoder-3.2.4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 b3dc1609f4dc2f9dc9b929c0cee7b9a94b0efdcde5a77e298e5428ae65dbdbe0
MD5 d2a8dbf748df605995185e38e0695ae8
BLAKE2b-256 7d0236bb7125dfea5a450240c98aefe3f71181a8bdeb71b9db449075e9c59a05

See more details on using hashes here.

File details

Details for the file mpegCoder-3.2.4-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mpegCoder-3.2.4-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 57a614ac303ed31b87b4f6d30cecf828813abc0e75d0d27c7142af3058e89123
MD5 d8d18263248dad722d747ecb4de9e61f
BLAKE2b-256 4875e6f974b348de539301c6a81805af198837cad38f5939b17d91f741a2e394

See more details on using hashes here.

File details

Details for the file mpegCoder-3.2.4-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: mpegCoder-3.2.4-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for mpegCoder-3.2.4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 d9088ff39a3c6abf7ef19b540a1edd977cab19fbf591ffb33f50748f7ad40084
MD5 e76a3eaa19890fe937c9156a783dd572
BLAKE2b-256 16bc43c3313a9fdbd680b241ca7e03354d2b995afeb3793f57bb2c0eac6a96c0

See more details on using hashes here.

File details

Details for the file mpegCoder-3.2.4-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: mpegCoder-3.2.4-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: CPython 3.6m
  • Uploaded using 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

File hashes

Hashes for mpegCoder-3.2.4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7d9be047cbdc7d13f3dce621ea4d25b1dc273ee7ada38c4a9583e26df54d865d
MD5 5dc10ca92438bc54cc4f68d1d427ed59
BLAKE2b-256 2a5d94513921615d27ffbf46136f781d21ccbbb56b16bef2f1b09cabde499d41

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page