|
1 | | - |
2 | 1 | # FFmpeg-Encoder-Decoder-for-Python
|
3 | 2 |
|
4 | 3 | *****
|
|
14 | 13 |
|
15 | 14 | 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.
|
16 | 15 |
|
17 | | -```python |
18 | | - import mpegCoder |
19 | | -``` |
| 16 | +```python |
| 17 | + import mpegCoder |
| 18 | +``` |
20 | 19 |
|
21 | 20 | Noted that this API need you to install numpy.
|
22 | 21 |
|
@@ -71,86 +70,86 @@ For more instructions, you could tap `help(mpegCoder)`.
|
71 | 70 |
|
72 | 71 | ### V2.0 update report:
|
73 | 72 |
|
74 | | -1. Revise the bug of the encoder which may cause the stream duration is shorter than the real duration of the video in some not advanced media players. |
| 73 | +1. Revise the bug of the encoder which may cause the stream duration is shorter than the real duration of the video in some not advanced media players. |
75 | 74 |
|
76 | | -2. Improve the structure of the code and remove some unnecessary codes. |
| 75 | +2. Improve the structure of the code and remove some unnecessary codes. |
77 | 76 |
|
78 | | -3. Provide a complete version of client, which could demux the video stream from a server in any network protocol. |
| 77 | +3. Provide a complete version of client, which could demux the video stream from a server in any network protocol. |
79 | 78 |
|
80 | 79 | ### V1.8 update report:
|
81 | 80 |
|
82 | | -1. Provide options (widthDst, heightDst) to let MpegDecoder could control the output size manually. To ensure the option is valid, we must use the method `setParameter` before `FFmpegSetup`. Now you could use this options to get a rescaled output directly: |
| 81 | +1. Provide options (widthDst, heightDst) to let MpegDecoder could control the output size manually. To ensure the option is valid, we must use the method `setParameter` before `FFmpegSetup`. Now you could use this options to get a rescaled output directly: |
83 | 82 |
|
84 | | - ```python |
85 | | - d = mpegCoder.MpegDecoder() # initialize |
86 | | - d.setParameter(widthDst=400, heightDst=300) # noted that these options must be set before 'FFmpegSetup'! |
87 | | - d.FFmpegSetup(b'i.avi') # the original video size would not influence the output |
88 | | - print(d) # examine the parameters. You could also get the original video size by 'getParameter' |
89 | | - d.ExtractFrame(0, 100) # get 100 frames with 400x300 |
90 | | - ``` |
| 83 | + ```python |
| 84 | + d = mpegCoder.MpegDecoder() # initialize |
| 85 | + d.setParameter(widthDst=400, heightDst=300) # noted that these options must be set before 'FFmpegSetup'! |
| 86 | + d.FFmpegSetup(b'i.avi') # the original video size would not influence the output |
| 87 | + print(d) # examine the parameters. You could also get the original video size by 'getParameter' |
| 88 | + d.ExtractFrame(0, 100) # get 100 frames with 400x300 |
| 89 | + ``` |
91 | 90 |
|
92 | | - In another example, the set optional parameters could be inherited by encoder, too: |
| 91 | + In another example, the set optional parameters could be inherited by encoder, too: |
93 | 92 |
|
94 | | - ```python |
95 | | - d.setParameter(widthDst=400, heightDst=300) # set optional parameters |
96 | | - ... |
97 | | - e.setParameter(decoder=d) # the width/height would inherit from widthDst/heightDst rather than original width/height of the decoder. |
98 | | - ``` |
| 93 | + ```python |
| 94 | + d.setParameter(widthDst=400, heightDst=300) # set optional parameters |
| 95 | + ... |
| 96 | + e.setParameter(decoder=d) # the width/height would inherit from widthDst/heightDst rather than original width/height of the decoder. |
| 97 | + ``` |
| 98 | + |
| 99 | + Noted that we do not provide `widthDst`/`heightDst` in `getParameter`, because these 2 options are all set by users. There is no need to get them from the video metadata. |
99 | 100 |
|
100 | | - Noted that we do not provide `widthDst`/`heightDst` in `getParameter`, because these 2 options are all set by users. There is no need to get them from the video metadata. |
101 | | - |
102 | | - 2. Optimize some realization of Decoder so that its efficiency could be improved. |
| 101 | +2. Optimize some realization of Decoder so that its efficiency could be improved. |
103 | 102 |
|
104 | 103 | ### V1.7-linux update report:
|
105 | 104 |
|
106 | | -Thanks to God, we succeed in this work! |
| 105 | +Thanks to God, we succeed in this work! |
107 | 106 |
|
108 | | -A new version is avaliable for Linux. To implement this tool, you need to install some libraries firstly: |
| 107 | +A new version is avaliable for Linux. To implement this tool, you need to install some libraries firstly: |
109 | 108 |
|
110 | | -* python3.5 |
| 109 | +* python3.5 |
111 | 110 |
|
112 | | -* numpy 1.13 |
| 111 | +* numpy 1.13 |
113 | 112 |
|
114 | | -If you want, you could install `ffmpeg` on Linux: Here are some instructions |
| 113 | +If you want, you could install `ffmpeg` on Linux: Here are some instructions |
115 | 114 |
|
116 | | -1. Check every pack which ffmpeg needs here: [Dependency of FFmpeg](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu "Dependency of FFmpeg") |
| 115 | +1. Check every pack which ffmpeg needs here: [Dependency of FFmpeg](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu "Dependency of FFmpeg") |
117 | 116 |
|
118 | | -2. Use these steps to install ffmpeg instead of provided commands on the above site. |
| 117 | +2. Use these steps to install ffmpeg instead of provided commands on the above site. |
119 | 118 |
|
120 | | -```Bash |
121 | | - $ git clone https://git.ffmpeg.org/ffmpeg.git |
122 | | - $ cd ffmpeg |
123 | | - $ ./configure --prefix=host --enable-gpl --enable-libx264 --enable-libx265 --enable-shared --disable-static --disable-doc |
124 | | - $ make |
125 | | - $ make install |
126 | | -``` |
| 119 | +```Bash |
| 120 | + $ git clone https://git.ffmpeg.org/ffmpeg.git |
| 121 | + $ cd ffmpeg |
| 122 | + $ ./configure --prefix=host --enable-gpl --enable-libx264 --enable-libx265 --enable-shared --disable-static --disable-doc |
| 123 | + $ make |
| 124 | + $ make install |
| 125 | +``` |
127 | 126 |
|
128 | 127 | ### V1.7 update report:
|
129 | 128 |
|
130 | | -1. Realize the encoder totally. |
| 129 | +1. Realize the encoder totally. |
131 | 130 |
|
132 | | -2. Provide a global option `dumpLevel` to control the log shown in the screen. |
| 131 | +2. Provide a global option `dumpLevel` to control the log shown in the screen. |
133 | 132 |
|
134 | | -3. Fix bugs in initialize functions. |
| 133 | +3. Fix bugs in initialize functions. |
135 | 134 |
|
136 | 135 | ### V1.5 update report:
|
137 | 136 |
|
138 | | -1. Provide an incomplete version of encoder, which could encode frames as a video stream that could not be played by player. |
| 137 | +1. Provide an incomplete version of encoder, which could encode frames as a video stream that could not be played by player. |
139 | 138 |
|
140 | 139 | ### V1.4 update report:
|
141 | 140 |
|
142 | | -1. Fix a severe bug of the decoder, which causes the memory collapsed if decoding a lot of frames. |
| 141 | +1. Fix a severe bug of the decoder, which causes the memory collapsed if decoding a lot of frames. |
143 | 142 |
|
144 | 143 | ### V1.2 update report:
|
145 | 144 |
|
146 | | -1. Use numpy array to replace the native pyList, which improves the speed significantly. |
| 145 | +1. Use numpy array to replace the native pyList, which improves the speed significantly. |
147 | 146 |
|
148 | 147 | ### V1.0 update report:
|
149 | | -1. Provide the decoder which could decode videos in arbitrary formats and arbitrary coding. |
| 148 | +1. Provide the decoder which could decode videos in arbitrary formats and arbitrary coding. |
150 | 149 |
|
151 | 150 | ## Version of currently used FFmpeg library
|
152 | | -* libavcodec.so.58.6.103 |
153 | | -* libavformat.so.58.3.100 |
154 | | -* libavutil.so.56.5.100 |
155 | | -* libswresample.so.3.0.101 |
156 | | -* libswscale.so.5.0.101 |
| 151 | +* libavcodec.so.58.6.103 |
| 152 | +* libavformat.so.58.3.100 |
| 153 | +* libavutil.so.56.5.100 |
| 154 | +* libswresample.so.3.0.101 |
| 155 | +* libswscale.so.5.0.101 |
0 commit comments