|
| 1 | + |
| 2 | +# FFmpeg-Encoder-Decoder-for-Python |
| 3 | + |
| 4 | +***** |
| 5 | + __ _ _ _ _ ,___ |
| 6 | + ( / / / o ( / ) ) / / / |
| 7 | + (__/ , , _, /_ _ _ _' ( / / / ,_ _ _, / __ __/ _ _ |
| 8 | + _/_(_/_(__/ /_(/_/ / /_/_)_ / / (__/|_)_(/_(_)_(___/(_)(_/_(/_/ (_ |
| 9 | + // /| /| |
| 10 | + (/ (/ (/ |
| 11 | +***** |
| 12 | + |
| 13 | +## Yuchen's Mpeg Coder - Readme |
| 14 | + |
| 15 | +This is a mpegcoder adapted from FFmpeg & Python-c-api. Using it you could get access to processing video easily. |
| 16 | + |
| 17 | +## Download |
| 18 | + |
| 19 | +Getting your versions here! You could also visit the [release page](https://github.com/cainmagi/FFmpeg-Encoder-Decoder-for-Python/releases, "Release Page") for current mpegCoder. |
| 20 | + |
| 21 | +| Version | Platform | Python Ver. | Numpy Ver. | FFmpeg Ver. | |
| 22 | +| ---------- | -----------| |
| 23 | +| [1.7](https://github.com/cainmagi/FFmpeg-Encoder-Decoder-for-Python/releases/download/1.7/mpegCoder_1_7_Linux.7z, "Linux, 1.7") | Linux | 3.5 | 1.13 | 3.3 | |
| 24 | +| [1.7](https://github.com/cainmagi/FFmpeg-Encoder-Decoder-for-Python/releases/download/1.7/mpegCoder_1_7_Win.7z, "Windows, 1.7") | Windows | 3.5 | 1.13 | 3.3 | |
| 25 | + |
| 26 | +## Usage |
| 27 | + |
| 28 | +Just use it as a common module in python like this. |
| 29 | + |
| 30 | +```python |
| 31 | + import mpegCoder |
| 32 | +``` |
| 33 | + |
| 34 | +Noted that this API need you to install numpy. |
| 35 | + |
| 36 | +An example of decoding a video in an arbitrary format: |
| 37 | + |
| 38 | +```python |
| 39 | + d = mpegCoder.MpegDecoder() |
| 40 | + d.FFmpegSetup(b'inputVideo.mp4') |
| 41 | + p = d.ExtractGOP(10) # Get a gop of current video by setting the start position of 10th frame. |
| 42 | + p = d.ExtractGOP() # Get a gop of current video, using the current position after the last ExtractGOP. |
| 43 | + d.ExtractFrame(100, 100) # Extract 100 frames from the begining of 100th frame. |
| 44 | +``` |
| 45 | + |
| 46 | +An example of transfer the coding of a video with an assigned codec: |
| 47 | + |
| 48 | +```python |
| 49 | + d = mpegCoder.MpegDecoder() |
| 50 | + d.FFmpegSetup(b'i.avi') |
| 51 | + e = mpegCoder.MpegEncoder() |
| 52 | + e.setParameter(decoder=d, codecName=b'libx264', videoPath=b'o.mp4') # inherit most of parameters from the decoder. |
| 53 | + opened = e.FFmpegSetup() # Load the encoder. |
| 54 | + if opened: # If encoder is not loaded successfully, do not continue. |
| 55 | + p = True |
| 56 | + while p is not None: |
| 57 | + p = d.ExtractGOP() # Extract current GOP. |
| 58 | + for i in p: # Select every frame. |
| 59 | + e.EncodeFrame(i) # Encode current frame. |
| 60 | + e.FFmpegClose() # End encoding, and flush all frames in cache. |
| 61 | + d.clear() # Close the input video. |
| 62 | +``` |
| 63 | + |
| 64 | +For more instructions, you could tap `help(mpegCoder)`. |
| 65 | + |
| 66 | +## Update Report |
| 67 | + |
| 68 | +### V1.7-linux update report: |
| 69 | + |
| 70 | +Thanks to God, we succeed in this work! |
| 71 | + |
| 72 | +A new version is avaliable for Linux. To implement this tool, you need to install some libraries firstly: |
| 73 | + |
| 74 | +* python3.5 |
| 75 | + |
| 76 | +* numpy 1.13 |
| 77 | + |
| 78 | +If you want, you could install `ffmpeg` on Linux: Here are some instructions |
| 79 | + |
| 80 | +1. Check every pack which ffmpeg needs here: [Dependency of FFmpeg](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu "Dependency of FFmpeg") |
| 81 | + |
| 82 | +2. Use these steps to install ffmpeg instead of provided commands on the above site. |
| 83 | + |
| 84 | +```Bash |
| 85 | + $ git clone https://git.ffmpeg.org/ffmpeg.git |
| 86 | + $ cd ffmpeg |
| 87 | + $ ./configure --prefix=host --enable-gpl --enable-shared --disable-static --disable-doc |
| 88 | + $ make |
| 89 | + $ make install |
| 90 | +``` |
| 91 | + |
| 92 | +### V1.7 update report: |
| 93 | + |
| 94 | +1. Realize the encoder totally. |
| 95 | + |
| 96 | +2. Provide a global option `dumpLevel` to control the log shown in the screen. |
| 97 | + |
| 98 | +3. Fix bugs in initalize functions. |
| 99 | + |
| 100 | +### V1.5 update report: |
| 101 | + |
| 102 | +1. Provide an incomplete version of encoder, which could encode frames as a |
| 103 | + video stream that could not be played by player. |
| 104 | + |
| 105 | +### V1.4 update report: |
| 106 | + |
| 107 | +1. Fix a severe bug of the decoder, which causes the memory collapsed if |
| 108 | + decoding a lot of frames. |
| 109 | + |
| 110 | +### V1.2 update report: |
| 111 | + |
| 112 | +1. Use numpy array to replace the native pyList, which improves the speed |
| 113 | + significantlly. |
| 114 | + |
| 115 | +### V1.0 update report: |
| 116 | +1. Provide the decoder which could decode videos in arbitrary formats and |
| 117 | + arbitrary coding. |
| 118 | + |
| 119 | +## Version of currently used FFmpeg library |
| 120 | +* libavcodec.so.58.6.103 |
| 121 | +* libavformat.so.58.3.100 |
| 122 | +* libavutil.so.56.5.100 |
| 123 | +* libswresample.so.3.0.101 |
| 124 | +* libswscale.so.5.0.101 |
0 commit comments