Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

This is a C++ based FFmpeg Encoder/Decoder for Python 3.6+ & numpy 1.19+. Both Linux & Win versions are provided. Theoretically you do not need to install FFmpeg for using this library.

License

NotificationsYou must be signed in to change notification settings

cainmagi/FFmpeg-Encoder-Decoder-for-Python

 
 

Repository files navigation

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.

importmpegCoder
BranchDescription
master 🔗The source project ofmpegCoder, Windows version.
master-linux 🔗The source project ofmpegCoder, 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.

Source project ofmpegCoder (Linux)

The following instructions are used for building the project on Windows with Visual Studio 2019.

  1. Clone themaster branch which only contains the codes ofmpegCoder:

    git clone --single-branch -b master-linux https://github.com/cainmagi/FFmpeg-Encoder-Decoder-for-Python.git
  2. Install the pre-requisite packages. The following script could be used by ubuntu or debian. If users are using other Linux distribution, they should installgcc andg++ by themselves.

    chmod +rwx ./apt-requirements.sh./apt-requirements.sh

    We strongly suggest that users should also install the python dependencies (optional):

    python -m pip install -r requirements.txt
  3. Get the shared version of the Linux FFMpeg. We support three different approaches for this step:

    • Build the shared libs of FFMpeg from the source codes by yourself. We providea compiling script 📃 in the deps branch. You could download and build it by the following commands:

      mkdir -p /appschmod +rwx /appscurl -O https://raw.githubusercontent.com/cainmagi/FFmpeg-Encoder-Decoder-for-Python/deps/install-ffmpeg-5_0.shchmod +rwx install-ffmpeg-5_0.sh./install-ffmpeg-5_0.sh --all --nvcuda

      After running this script, the FFMpeg with most of the dependencies would be complied along with the shared libraries. Then you could replace the FFMpeg path in thesetup.py by

      FFMPEG_DIR='/apps/build/ffmpeg-5.0'
    • Download the pre-built dependencies. These dependencies are built by myself. You could download the archivehere 📦. The files need to be extracted to./dependencies:

      cd FFmpeg-Encoder-Decoder-for-Pythonmkdir -p dependencieswget -O- https://github.com/cainmagi/FFmpeg-Encoder-Decoder-for-Python/releases/download/deps-3.2.0/dep-linux-ffmpeg_5_0.tar.xz| tar xJ -C"./dependencies"
    • The dependencies could be also downloaded by the automatic script, you just need to run

      python webtools.py

      This script requires users to installurllib3. Thetqdm is also recommended to be installed.

  4. BuildmpegCoder by running the following script. The built file would be stored in./build. If you has not fetched the dependencies in the step 2, running thesetup.py may trigger an event for fetching the online dependencies.

    python setup.py build
  5. Rename the built module asmpegCoder.so, then you could import it in the same directory. If you have built FFMpeg by our script, you do not need any other dependencies when importing the libs. However, if not, you may need to downloadthe lib dependencies 📦 and add thelib folder to yourLD_LIBRARY_PATH:

    mkdir -p /apps/ffmpeg-5.0cd /apps/ffmpeg-5.0wget -O- https://github.com/cainmagi/FFmpeg-Encoder-Decoder-for-Python/releases/download/deps-3.2.0/so-linux-ffmpeg_5_0.tar.xz| tar xJ -C"."echo"export LD_LIBRARY_PATH=/apps/ffmpeg-5.0/lib:\$LD_LIBRARY_PATH">>~/.bashrcexport LD_LIBRARY_PATH=/apps/ffmpeg-5.0/lib:$LD_LIBRARY_PATH
  6. RunningmpegCoder requiresGLIBC>=2.29. This requirement is not satisfied in some cases. However, if you have built FFMpeg by our script, the requirement would be fulfilled (i.e. you could skip this step). If users are using our pre-built dependencies, users may need to solve this problem by

    ln -sf /apps/ffmpeg-5.0/lib-fix/libm-2.31.so /lib/x86_64-linux-gnu/libm.so.6

Update reports

Has been moved to📑 CHANGELOG.md

Version of currently used FFmpeg library

Current FFMpeg version is5.0.

DependencyVersion
libavcodec59.18.100.0
libavformat59.16.100.0
libavutil57.17.100.0
libswresample4.3.100.0
libswscale6.4.100.0

About

This is a C++ based FFmpeg Encoder/Decoder for Python 3.6+ & numpy 1.19+. Both Linux & Win versions are provided. Theoretically you do not need to install FFmpeg for using this library.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp