|
1 | 1 | # FFmpeg-Encoder-Decoder-for-Python |
2 | | -This is a C++ based FFmpeg Encoder/Decoder for Python 3.5 & numpy 1.13. Both Linux & Win versions are provided. |
| 2 | +================================================================================ |
| 3 | + __ _ _ _ _ ,___ |
| 4 | + ( / / / o ( / ) ) / / / |
| 5 | + (__/ , , _, /_ _ _ _' ( / / / ,_ _ _, / __ __/ _ _ |
| 6 | + _/_(_/_(__/ /_(/_/ / /_/_)_ / / (__/|_)_(/_(_)_(___/(_)(_/_(/_/ (_ |
| 7 | + // /| /| |
| 8 | + (/ (/ (/ |
| 9 | +================================================================================ |
| 10 | +Yuchen's Mpeg Coder - Readme |
| 11 | + This is a mpegcoder adapted from FFmpeg & Python-c-api.Using it you could |
| 12 | + get access to processing video easily. Just use it as a common module in |
| 13 | + python like this. |
| 14 | + >>> import mpegCoder |
| 15 | + Noted that this API need you to install numpy. |
| 16 | + An example of decoding a video in an arbitrary format: |
| 17 | + >>> d = mpegCoder.MpegDecoder() |
| 18 | + >>> d.FFmpegSetup(b'inputVideo.mp4') |
| 19 | + >>> p = d.ExtractGOP(10) # Get a gop of current video by setting the |
| 20 | + start position of 10th frame. |
| 21 | + >>> p = d.ExtractGOP() # Get a gop of current video, using the current |
| 22 | + position after the last ExtractGOP. |
| 23 | + >>> d.ExtractFrame(100, 100) # Extract 100 frames from the begining of |
| 24 | + 100th frame. |
| 25 | + An example of transfer the coding of a video with an assigned codec: |
| 26 | + >>> d = mpegCoder.MpegDecoder() |
| 27 | + >>> d.FFmpegSetup(b'i.avi') |
| 28 | + >>> e = mpegCoder.MpegEncoder() |
| 29 | + >>> e.setParameter(decoder=d, codecName=b'libx264', videoPath=b'o.mp4') |
| 30 | + # inherit most of parameters from the decoder. |
| 31 | + >>> opened = e.FFmpegSetup() # Load the encoder. |
| 32 | + >>> if opened: # If encoder is not loaded successfully, do not continue. |
| 33 | + ... p = True |
| 34 | + ... while p: |
| 35 | + ... p = d.ExtractGOP() # Extract current GOP. |
| 36 | + ... for i in p: # Select every frame. |
| 37 | + ... e.EncodeFrame(i) # Encode current frame. |
| 38 | + ... e.FFmpegClose() # End encoding, and flush all frames in cache. |
| 39 | + >>> d.clear() # Close the input video. |
| 40 | + For more instructions, you could tap help(mpegCoder). |
| 41 | +================================================================================ |
| 42 | +V1.7-linux update report: |
| 43 | + Thanks to God, we succeed in this work! |
| 44 | + A new version is avaliable for Linux. To implement this tool, you need to |
| 45 | + install some libraries firstly: |
| 46 | + - python3.5 (with numpy) |
| 47 | + - ffmpeg on Linux: Here are some instructions |
| 48 | + (1). Check every pack which ffmpeg needs on |
| 49 | + https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu |
| 50 | + (2). Use these steps to install ffmpeg instead of provided commands |
| 51 | + on the above site. |
| 52 | + $ git clone https://git.ffmpeg.org/ffmpeg.git |
| 53 | + $ cd ffmpeg |
| 54 | + $ ./configure --prefix=host --enable-gpl --enable-shared --disable-static --disable-doc |
| 55 | + $ make |
| 56 | + $ make install |
| 57 | +V1.7 update report: |
| 58 | + 1. Realize the encoder totally. |
| 59 | + 2. Provide a global option 'dumpLevel' to control the log shown in the screen. |
| 60 | + 3. Fix bugs in initalize functions. |
| 61 | +V1.5 update report: |
| 62 | + 1. Provide an incomplete version of encoder, which could encode frames as a |
| 63 | + video stream that could not be played by player. |
| 64 | +V1.4 update report: |
| 65 | + 1. Fix a severe bug of the decoder, which causes the memory collapsed if |
| 66 | + decoding a lot of frames. |
| 67 | +V1.2 update report: |
| 68 | + 1. Use numpy array to replace the native pyList, which improves the speed |
| 69 | + significantlly. |
| 70 | +V1.0 update report: |
| 71 | + 1. Provide the decoder which could decode videos in arbitrary formats and |
| 72 | + arbitrary coding. |
| 73 | +================================================================================ |
| 74 | +Version of used FFmpeg library |
| 75 | + libavcodec.so.58.6.103 |
| 76 | + libavformat.so.58.3.100 |
| 77 | + libavutil.so.56.5.100 |
| 78 | + libswresample.so.3.0.101 |
| 79 | + libswscale.so.5.0.101 |
0 commit comments