You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -32,24 +33,24 @@ Getting your versions here! You could also visit the [release page](https://gith
32
33
Just use it as a common module in python like this.
33
34
34
35
```python
35
-
import mpegCoder
36
+
import mpegCoder
36
37
```
37
38
38
39
Noted that this API need you to install numpy.
39
40
40
41
An example of decoding a video in an arbitrary format:
41
42
42
-
```python
43
+
```python
43
44
d = mpegCoder.MpegDecoder()
44
45
d.FFmpegSetup(b'inputVideo.mp4')
45
46
p = d.ExtractGOP(10) # Get a gop of current video by setting the start position of 10th frame.
46
47
p = d.ExtractGOP() # Get a gop of current video, using the current position after the last ExtractGOP.
47
48
d.ExtractFrame(100, 100) # Extract 100 frames from the begining of 100th frame.
48
-
```
49
+
```
49
50
50
51
An example of transfer the coding of a video with an assigned codec:
51
52
52
-
```python
53
+
```python
53
54
d = mpegCoder.MpegDecoder()
54
55
d.FFmpegSetup(b'i.avi')
55
56
e = mpegCoder.MpegEncoder()
@@ -63,11 +64,11 @@ An example of transfer the coding of a video with an assigned codec:
63
64
e.EncodeFrame(i) # Encode current frame.
64
65
e.FFmpegClose() # End encoding, and flush all frames in cache.
65
66
d.clear() # Close the input video.
66
-
```
67
+
```
67
68
68
69
An example of demuxing the video streamer from a server:
69
70
70
-
```python
71
+
```python
71
72
d = mpegCoder.MpegClient() # create the handle
72
73
d.setParameter(dstFrameRate=(5,1), readSize=5, cacheSize=12) # normalize the frame rate to 5 FPS, and use a cache which size is 12 frames. Read 5 frames each time.
@@ -80,97 +81,105 @@ An example of demuxing the video streamer from a server:
80
81
# do some processing
81
82
d.terminate() # shut down the current thread. You could call start() and let it restart.
82
83
d.clear() # Disconnect with the stream.
84
+
```
85
+
86
+
You could also find some more explanations in two examples about `MpegClient` in [here][exp1] and [here][exp2].
83
87
84
88
For more instructions, you could tap `help(mpegCoder)`.
85
89
86
90
## Update Report
87
91
88
92
### V2.0 update report:
89
93
90
-
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.
94
+
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.
91
95
92
-
2. Improve the structure of the code and remove some unnecessary codes.
96
+
2. Improve the structure of the code and remove some unnecessary codes.
93
97
94
-
3. Provide a complete version of client, which could demux the video stream from a server in any network protocol.
98
+
3. Provide a complete version of client, which could demux the video stream from a server in any network protocol.
95
99
96
100
### V1.8 update report:
97
101
98
-
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:
102
+
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:
103
+
104
+
```python
105
+
d = mpegCoder.MpegDecoder() # initialize
106
+
d.setParameter(widthDst=400, heightDst=300) # noted that these options must be set before 'FFmpegSetup'!
107
+
d.FFmpegSetup(b'i.avi') # the original video size would not influence the output
108
+
print(d) # examine the parameters. You could also get the original video size by 'getParameter'
109
+
d.ExtractFrame(0, 100) # get 100 frames with 400x300
110
+
```
99
111
100
-
```python
101
-
d = mpegCoder.MpegDecoder() # initialize
102
-
d.setParameter(widthDst=400, heightDst=300) # noted that these options must be set before 'FFmpegSetup'!
103
-
d.FFmpegSetup(b'i.avi') # the original video size would not influence the output
104
-
print(d) # examine the parameters. You could also get the original video size by 'getParameter'
105
-
d.ExtractFrame(0, 100) # get 100 frames with 400x300
106
-
```
112
+
In another example, the set optional parameters could be inherited by encoder, too:
107
113
108
-
In another example, the set optional parameters could be inherited by encoder, too:
114
+
```python
115
+
d.setParameter(widthDst=400, heightDst=300) # set optional parameters
116
+
...
117
+
e.setParameter(decoder=d) # the width/height would inherit from widthDst/heightDst rather than original width/height of the decoder.
118
+
```
109
119
110
-
```python
111
-
d.setParameter(widthDst=400, heightDst=300) # set optional parameters
112
-
...
113
-
e.setParameter(decoder=d) # the width/height would inherit from widthDst/heightDst rather than original width/height of the decoder.
114
-
```
120
+
Noted that we do not provide `widthDst`/`heightDst`in`getParameter`, because these 2 options are allset by users. There is no need to get them from the video metadata.
115
121
116
-
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.
117
-
118
-
2. Optimize some realization of Decoder so that its efficiency could be improved.
122
+
2. Optimize some realization of Decoder so that its efficiency could be improved.
119
123
120
124
### V1.7-linux update report:
121
125
122
-
Thanks to God, we succeed in this work!
126
+
Thanks to God, we succeed in this work!
123
127
124
-
A new version is avaliable for Linux. To implement this tool, you need to install some libraries firstly:
128
+
A new version is avaliable for Linux. To implement this tool, you need to install some libraries firstly:
125
129
126
-
* python3.5
130
+
* python3.5
127
131
128
-
* numpy 1.13
132
+
* numpy 1.13
129
133
130
-
If you want, you could install `ffmpeg` on Linux: Here are some instructions
134
+
If you want, you could install `ffmpeg` on Linux: Here are some instructions
131
135
132
-
1. Check every pack which ffmpeg needs here: [Dependency of FFmpeg](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu "Dependency of FFmpeg")
136
+
1. Check every pack which ffmpeg needs here: [Dependency of FFmpeg](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu "Dependency of FFmpeg")
133
137
134
-
2. Use these steps to install ffmpeg instead of provided commands on the above site.
138
+
2. Use these steps to install ffmpeg instead of provided commands on the above site.
0 commit comments