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

Uploaded CPython 3.10Windows x86-64

mpegCoder-3.2.0-cp310-cp310-manylinux1_x86_64.whl (21.2 kB view details)

Uploaded CPython 3.10

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

Uploaded CPython 3.9Windows x86-64

mpegCoder-3.2.0-cp39-cp39-manylinux1_x86_64.whl (21.2 kB view details)

Uploaded CPython 3.9

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

Uploaded CPython 3.8Windows x86-64

mpegCoder-3.2.0-cp38-cp38-manylinux1_x86_64.whl (21.1 kB view details)

Uploaded CPython 3.8

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

Uploaded CPython 3.7mWindows x86-64

mpegCoder-3.2.0-cp37-cp37m-manylinux1_x86_64.whl (21.0 kB view details)

Uploaded CPython 3.7m

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

Uploaded CPython 3.6mWindows x86-64

mpegCoder-3.2.0-cp36-cp36m-manylinux1_x86_64.whl (21.2 kB view details)

Uploaded CPython 3.6m

File details

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

File metadata

  • Download URL: mpegCoder-3.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for mpegCoder-3.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d9d0ede1978548dd42522ac5feee35631db907ea08f5b1e978925ed50c0060cb
MD5 030c860c5f83aa99313b202f37eeab19
BLAKE2b-256 089190227c25617774abc5e052b26c1928f9013260116598b21207c21d4708dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mpegCoder-3.2.0-cp310-cp310-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b7523fd878bc88680ff3fc1f0b66c602646fdd5314cb81fb846d7747259baed8
MD5 895c5a7a1a57a68c61b8cb40d77bbac8
BLAKE2b-256 5bf3118f2afd606f5e2924b63661b5adce02bae4de62b665de55e3ef2aef1dfe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mpegCoder-3.2.0-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.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 db2a78b460350d0d84ff6e73ab03f0b03e67789e7b5ab2a7526f0aa531483182
MD5 7af300f1ebe2e4069fcd23badbfda8e0
BLAKE2b-256 96f514bfd440ab8c6f2341512166d51f0281c0fcaa45e43483e536c5d180f80e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mpegCoder-3.2.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 33fc3c8f24103182993f2ef92e42af5a97246c3403a6822835df827f8fbb2a26
MD5 2c26bc618921df6ecd4c4dc0a7c134fa
BLAKE2b-256 b11d81cf95ca3d324ea993cc1d4df4fa52f665f5ce2cc161fcb862dd5bc0136c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mpegCoder-3.2.0-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.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 158484c852e8af21e656fa609cce3cc2936ad258a1d4d2e89e89d292f3a68c41
MD5 f277e07c3bb477f6b79bb011883ab3a5
BLAKE2b-256 01b1ff959e12e11d0811e48155ee6a593b1da0b4fdcbce6dfc470bd5230742a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mpegCoder-3.2.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4592868623aac193635bfa27ce517b333393cb3b84969f14af70d2437ab6adfb
MD5 a375875395923d3728dff7a33e4dcc24
BLAKE2b-256 f01124fd7de770aac2c56a7fa04d578046cf2a47cf4c8ecbb06abbbdf6d91860

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mpegCoder-3.2.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.9

File hashes

Hashes for mpegCoder-3.2.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 94c4d3b03febe1332be0b30ae3ff5b4a09297ca66abef497e55779b354a164f4
MD5 a83e0481aa2c811c3566326810ee358c
BLAKE2b-256 a48ed507160099347710aac9132ecc916a3caa232769b35ef57a0c68ddfb9f62

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mpegCoder-3.2.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4647638ab2f89a5124f94eb4c8c8cc8be19037bb835ad1d36b907c1084a53738
MD5 60884e7b69e9ce3412546ee9a9f6b1b7
BLAKE2b-256 99a3aaa7a3ae757880f26e0567d7618e47734a1d4acd7bd52ebdf5bdb94a612a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mpegCoder-3.2.0-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.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 3ce43233ccdca516993287d38692112d60556732637d7e40ca913a4a44b41904
MD5 84fc2af4dbe53d939531847c55746561
BLAKE2b-256 d54e2c8d29f166371bcf69e836369b68f02fadd3bbdd7f69ab355a9f38e1502e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mpegCoder-3.2.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 21.2 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.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 df097afae9909a64624bb4d8065ee32eeddace0079b2d1c429e5ac82592f815b
MD5 4cbb868838acc3c7669849033649f992
BLAKE2b-256 bd4771778b26d3f8e449033a77341f03bf473797260db05fe9961d5831a803ac

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