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.3-cp310-cp310-win_amd64.whl (20.7 kB view details)

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10

mpegCoder-3.2.3-cp39-cp39-win_amd64.whl (20.7 kB view details)

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9

mpegCoder-3.2.3-cp38-cp38-win_amd64.whl (20.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

mpegCoder-3.2.3-cp38-cp38-manylinux1_x86_64.whl (21.2 kB view details)

Uploaded CPython 3.8

mpegCoder-3.2.3-cp37-cp37m-win_amd64.whl (20.6 kB view details)

Uploaded CPython 3.7m Windows x86-64

mpegCoder-3.2.3-cp37-cp37m-manylinux1_x86_64.whl (21.1 kB view details)

Uploaded CPython 3.7m

mpegCoder-3.2.3-cp36-cp36m-win_amd64.whl (20.7 kB view details)

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m

File details

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

File metadata

File hashes

Hashes for mpegCoder-3.2.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 99eb2810a0bf3dd39764324319dc8b40f3180af0b7d79579326811784a1aa588
MD5 d841e2b45143b29bb9fe349b30ca3b57
BLAKE2b-256 e6110d8ffe055390c145dbe0afd4475af8baec1123470de2c039a4c71ea58c66

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for mpegCoder-3.2.3-cp310-cp310-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4aad802a68b9f4a8863f86d701f7db9db37a6870f2bb49f79bd55d61f5ecda9a
MD5 fd9b48bd78cf7f1bfef5895ff914d576
BLAKE2b-256 3367274152d43349f9137b7705680bf1ab3bf1b86a774f04ec4cfa321a5b1046

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: mpegCoder-3.2.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 20.7 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.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 daa28004308130e16733f2357f874ee3e9bd893bbe5074abfa807c5a03ccf3b3
MD5 49a69b9996292f7b1f3154d91d465e95
BLAKE2b-256 c632790fff2a72c20943674913df6a5b91b9444b2fe9e8950bab48c8e7711545

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for mpegCoder-3.2.3-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 98577c384062fe95a4efbcc55b1d09d37178d52f7fc768189579c7c992c60de2
MD5 a66c4a9e5ccd59be1bc35fbfb700c025
BLAKE2b-256 50d43a126f858a1e80e5bec189ddd08d41512dee699c9e9c83c3a4114bdedc33

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: mpegCoder-3.2.3-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 20.7 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.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 697c9635e0addb082ba2e816a09363e2790fa1469557a5671cde37e08d8fd28a
MD5 595190b498190e93ce7e7d3f634ac03c
BLAKE2b-256 343340272634e662908e76ead8f5c674088cf43cddb01740ee6385edfc738f0f

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for mpegCoder-3.2.3-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 404a2ebc94b46140424a9f9bf49679933e6152ecb8aa7e9d4aa1f86f9963bdbe
MD5 8d02022149579ba7aa0a05f9b29a903f
BLAKE2b-256 73f69f9ecfa4993ca9846757606efdc0ac09786d2fc530cb28da683fb8312739

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for mpegCoder-3.2.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 065c587aad834a4ab0775b903f6eac37371ce6cbe50883f44884e00f230d477c
MD5 b07f7b5c820dfc7c4a3981ce5ecbff9a
BLAKE2b-256 a00978fca043c650f4489d37d5be787fe6a61e9185ab6df926cd0bbdee3ca867

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for mpegCoder-3.2.3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d77da97fdc46a8eac3af580e717a3bfa2563f3dc53f3fcf8ef3a79c52959b5bd
MD5 1ea61cf2f64c043f5bc5ab7582c7898e
BLAKE2b-256 b95a25d65260b453e00fcbbd8886b550760cb70a144a89c6383fa085b9d6f596

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: mpegCoder-3.2.3-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 20.7 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.3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 cd60348c6ce137f2db1a588adde834edbcb91a090c9928fb14b65c6d8e847b83
MD5 493fbc20dff7a495378f6a6e8fa25b34
BLAKE2b-256 bd5046be856b5734a899ff93a49c0ce1c65112fb2a5a77531c8b255eea33f79b

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: mpegCoder-3.2.3-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.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 777f0abfbfe77ecc9c82798134afa3ae6aa530fb4351fde96d3a810d1217a883
MD5 7cf44304ef2839d2c800b4c9ce1f3cc2
BLAKE2b-256 307e42d44ee1a5ea48197c623e11f53d0061c7c268391e8e4c6ecf830e8473d6

See more details on using hashes here.

Provenance

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