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 only works with FFMpeg 4.4. Users need to download the dependent dynamic libraries to make the package work. 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

If you're not sure about the file name format, learn more about wheel file names.

mpegCoder-3.1.0b0-cp39-cp39-win_amd64.whl (28.8 MB view details)

Uploaded CPython 3.9Windows x86-64

mpegCoder-3.1.0b0-cp39-cp39-manylinux1_x86_64.whl (95.1 MB view details)

Uploaded CPython 3.9

mpegCoder-3.1.0b0-cp38-cp38-win_amd64.whl (28.8 MB view details)

Uploaded CPython 3.8Windows x86-64

mpegCoder-3.1.0b0-cp38-cp38-manylinux1_x86_64.whl (95.1 MB view details)

Uploaded CPython 3.8

mpegCoder-3.1.0b0-cp37-cp37m-win_amd64.whl (28.8 MB view details)

Uploaded CPython 3.7mWindows x86-64

mpegCoder-3.1.0b0-cp37-cp37m-manylinux1_x86_64.whl (95.1 MB view details)

Uploaded CPython 3.7m

mpegCoder-3.1.0b0-cp36-cp36m-win_amd64.whl (28.8 MB view details)

Uploaded CPython 3.6mWindows x86-64

mpegCoder-3.1.0b0-cp36-cp36m-manylinux1_x86_64.whl (95.1 MB view details)

Uploaded CPython 3.6m

mpegCoder-3.1.0b0-cp35-cp35m-win_amd64.whl (28.8 MB view details)

Uploaded CPython 3.5mWindows x86-64

mpegCoder-3.1.0b0-cp35-cp35m-manylinux1_x86_64.whl (96.0 MB view details)

Uploaded CPython 3.5m

File details

Details for the file mpegCoder-3.1.0b0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: mpegCoder-3.1.0b0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 28.8 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for mpegCoder-3.1.0b0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5ea00b1e2a9ceb31ce20fb78051aadc37b7ca1587a5989ae9d2959014c375675
MD5 d711b347fb452ce8738af62b0eb7c0c5
BLAKE2b-256 a53339edd4166807b0136d4dfff1787857e8508074db052813065d0b0a566eb4

See more details on using hashes here.

File details

Details for the file mpegCoder-3.1.0b0-cp39-cp39-manylinux1_x86_64.whl.

File metadata

  • Download URL: mpegCoder-3.1.0b0-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 95.1 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for mpegCoder-3.1.0b0-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f46e2727ec9c1330e35fc8f87aa4200549a62cacb3d66b138f94929db5e55f71
MD5 cd7046c57029ef069f9bfcfc2fd0b3d9
BLAKE2b-256 fba66a6760aaf494fa360fba6d21e5dfd86a6c6fe45f35abc3cf66f6c9b47cb7

See more details on using hashes here.

File details

Details for the file mpegCoder-3.1.0b0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: mpegCoder-3.1.0b0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 28.8 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for mpegCoder-3.1.0b0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 006f28dad3f5d99dd4f72d45e52f25ad98cc05d65b463f43e5a61ea446d069c2
MD5 3aee8bca281a967f4cd0454c83c28b1f
BLAKE2b-256 389b51746d9ed21d9706cadf7d3fbca1cc01a2a048f5095a0ee7a04ac049b67d

See more details on using hashes here.

File details

Details for the file mpegCoder-3.1.0b0-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: mpegCoder-3.1.0b0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 95.1 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11

File hashes

Hashes for mpegCoder-3.1.0b0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5ebebbefc2ce4e57cf6345ec691aa67d7ce545ee4b533ebb5de0de5e6b4107f4
MD5 3419b786f86429c0683fcbca29f91f34
BLAKE2b-256 74b4ff7288eef8b3013d2867b96699ef4f7551f63b716843e5f946c2fbeacdd4

See more details on using hashes here.

File details

Details for the file mpegCoder-3.1.0b0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: mpegCoder-3.1.0b0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 28.8 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.9

File hashes

Hashes for mpegCoder-3.1.0b0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 2889b6a8e3fbd8ecbb606ec5c0d663700c838b36f46d39af4edd11ccbaa31a42
MD5 d8044ac057a09d1469af2093e8e02af1
BLAKE2b-256 18f8c15bd67a593b6243cbc034672c704e62430e5b52645236c13c84416e1b5c

See more details on using hashes here.

File details

Details for the file mpegCoder-3.1.0b0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: mpegCoder-3.1.0b0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 95.1 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.11

File hashes

Hashes for mpegCoder-3.1.0b0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f7d420e3d2a86031e548bdfa6e9851c4344d9bfaccc640958deb644b55a346ec
MD5 53e3062d1341e116d9572bce6126fdbc
BLAKE2b-256 cf5b90a1b18c73281ca7759f08270471260b19a5f9da8905fca5e1ae92e3f049

See more details on using hashes here.

File details

Details for the file mpegCoder-3.1.0b0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: mpegCoder-3.1.0b0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 28.8 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.8

File hashes

Hashes for mpegCoder-3.1.0b0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 7a74843b340d8d6d9ed0be746a5c6ba2b68245b2364682baa474556cad39a355
MD5 f3ef8a08bbcb600f7acc837d5de34aa0
BLAKE2b-256 337318acda53d3c901b881a70f537b84e88fc16ce1130e0ed35324047d868c2f

See more details on using hashes here.

File details

Details for the file mpegCoder-3.1.0b0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: mpegCoder-3.1.0b0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 95.1 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.14

File hashes

Hashes for mpegCoder-3.1.0b0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 85a62de79d28f435fc6803b40e92e94dd1855409163bb794cd334bf6dae2149e
MD5 56022361e7e683a67e0da1e29f431cb7
BLAKE2b-256 14f7abaa57dda662207f38acac57b7cb5cdc3ede0f90702156cfcf6b45853fdc

See more details on using hashes here.

File details

Details for the file mpegCoder-3.1.0b0-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: mpegCoder-3.1.0b0-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 28.8 MB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.7.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.5.4

File hashes

Hashes for mpegCoder-3.1.0b0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 cafedc364eccaa9a5efb041bc0ea9aca46dbeed72bc10e9a78428e34b3ca6945
MD5 7dff8014b7a902a245b33763c766bd01
BLAKE2b-256 303ea4bebd37acd2f85ca12ef3c0d3c2890489e291d9d8504693500e96ac3179

See more details on using hashes here.

File details

Details for the file mpegCoder-3.1.0b0-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: mpegCoder-3.1.0b0-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 96.0 MB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.7.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.5.10

File hashes

Hashes for mpegCoder-3.1.0b0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 be0071b5b98337572dfa97c6d185e21f893dba4ebc8121d44538254b4a4a4348
MD5 88bbaf917aa6ed93e7391a5d805ce302
BLAKE2b-256 eea14ecd95c74f53f7c2152c60689e0f9aacb4121ac0337d35bb98f49ec6dd5a

See more details on using hashes here.

Supported by

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