Skip to content

Commit 18a7d0e

Browse files
update readme
1 parent ba07a3f commit 18a7d0e

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

README.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ video = '/var/www/media/videos/test.mp4'
4848
#### 2. From Clouds
4949
You can open a file from a cloud by passing a tuple of cloud configuration to the method. There are some options to open a file from **[Amazon Web Services (AWS)](https://aws.amazon.com/)**, **[Google Cloud Storage](https://console.cloud.google.com/storage)**, **[Microsoft Azure Storage](https://azure.microsoft.com/en-us/features/storage-explorer/)**, and a custom cloud.
5050

51-
Please visit **[this page](https://video.aminyazdanpanah.com/python/start/open-clouds)** to see more examples and usage of these clouds.
5251
```python
5352
video = (google_cloud, download_options, None)
5453
```
5554

55+
Please visit **[this page](https://video.aminyazdanpanah.com/python/start/open-clouds)** to see more examples and usage of these clouds.
56+
5657
### DASH
5758
**[Dynamic Adaptive Streaming over HTTP (DASH)](https://dashif.org/)**, also known as MPEG-DASH, is an adaptive bitrate streaming technique that enables high quality streaming of media content over the Internet delivered from conventional HTTP web servers.
5859

@@ -67,23 +68,27 @@ import ffmpeg_streaming
6768
.dash(video, adaption='"id=0,streams=v id=1,streams=a"')
6869
.format('libx265')
6970
.auto_rep()
70-
.package('/var/www/media/videos/dash/test.mpd')
71+
.package('/var/www/media/videos/dash/dash-stream.mpd')
7172
)
7273
```
7374
You can also create representations manually:
7475
```python
7576
import ffmpeg_streaming
7677
from ffmpeg_streaming import Representation
7778

78-
rep_144 = Representation(width=256, height=144, kilo_bitrate=200)
79-
rep_240 = Representation(width=426, height=240, kilo_bitrate=500)
80-
rep_360 = Representation(width=640, height=360, kilo_bitrate=1000)
79+
rep_144 = Representation(width=256, height=144, kilo_bitrate=95)
80+
rep_240 = Representation(width=426, height=240, kilo_bitrate=150)
81+
rep_360 = Representation(width=640, height=360, kilo_bitrate=276)
82+
rep_480 = Representation(width=854, height=480, kilo_bitrate=750)
83+
rep_720 = Representation(width=1280, height=720, kilo_bitrate=2048)
84+
rep_1080 = Representation(width=1920, height=1080, kilo_bitrate=4096)
85+
rep_1440 = Representation(width=2560, height=1440, kilo_bitrate=6096)
8186

8287
(
8388
ffmpeg_streaming
8489
.dash(video, adaption='"id=0,streams=v id=1,streams=a"')
8590
.format('libx265')
86-
.add_rep(rep_144, rep_240, rep_360)
91+
.add_rep(rep_144, rep_240, rep_360, rep_480, rep_720, rep_1080, rep_1440)
8792
.package('/var/www/media/videos/dash/test.mpd')
8893
)
8994

@@ -115,15 +120,15 @@ You can also create representations manually:
115120
import ffmpeg_streaming
116121
from ffmpeg_streaming import Representation
117122

118-
rep_144 = Representation(width=256, height=144, kilo_bitrate=200)
119-
rep_240 = Representation(width=426, height=240, kilo_bitrate=500)
120-
rep_360 = Representation(width=640, height=360, kilo_bitrate=1000)
123+
rep_360 = Representation(width=640, height=360, kilo_bitrate=276)
124+
rep_480 = Representation(width=854, height=480, kilo_bitrate=750)
125+
rep_720 = Representation(width=1280, height=720, kilo_bitrate=2048)
121126

122127
(
123128
ffmpeg_streaming
124129
.hls(video, hls_time=10, hls_allow_cache=1)
125130
.format('libx264')
126-
.add_rep(rep_144, rep_240, rep_360)
131+
.add_rep(rep_360, rep_480, rep_720)
127132
.package('/var/www/media/videos/hls/test.m3u8')
128133
)
129134
```
@@ -141,7 +146,7 @@ import ffmpeg_streaming
141146
.hls(video, hls_time=10, hls_allow_cache=1)
142147
.encryption('https://www.aminyazdanpanah.com/keys/enc.key', '/var/www/my_website_project/keys/enc.key')
143148
.format('libx264')
144-
.auto_rep()
149+
.auto_rep(heights=[480, 360, 240])
145150
.package('/var/www/media/videos/hls/test.m3u8')
146151
)
147152
```
@@ -159,7 +164,7 @@ import ffmpeg_streaming
159164
def progress(percentage, ffmpeg):
160165
# You can update a field in your database
161166
# You can also create a socket connection and show a progress bar to users
162-
sys.stdout.write("\r Transcoding... (%s%%)[%s%s]" % (percentage, '#' * percentage, '-' * (100 - percentage)))
167+
sys.stdout.write("\rTranscoding...(%s%%)[%s%s]" % (percentage, '#' * percentage, '-' * (100 - percentage)))
163168
sys.stdout.flush()
164169

165170

@@ -168,7 +173,7 @@ def progress(percentage, ffmpeg):
168173
.hls(video)
169174
.format('libx264')
170175
.auto_rep()
171-
.package('/var/www/media/videos/hls/test.m3u8', progress)
176+
.package('/var/www/media/videos/hls/test.m3u8', progress=progress)
172177
)
173178
```
174179
Output of the progress:
@@ -185,7 +190,7 @@ You can pass a local path to the `package` method. If there was no directory in
185190
.hls(video)
186191
.format('libx264')
187192
.auto_rep()
188-
.package('/var/www/media/videos/hls/test.m3u8', progress)
193+
.package('/var/www/media/videos/hls/test.m3u8', progress=progress)
189194
)
190195
```
191196
It can also be null. The default path to save files is the input path.
@@ -203,7 +208,6 @@ It can also be null. The default path to save files is the input path.
203208
#### 2. To Clouds
204209
You can save your files to clouds by passing a array of cloud configuration to the `package` method. There are some options to save files to **[Amazon Web Services (AWS)](https://aws.amazon.com/)**, **[Google Cloud Storage](https://console.cloud.google.com/storage)**, **[Microsoft Azure Storage](https://azure.microsoft.com/en-us/features/storage-explorer/)**, and a custom cloud.
205210

206-
Please visit **[this page](https://video.aminyazdanpanah.com/python/start/save-clouds)** to see more examples and usage of these clouds.
207211
```python
208212
(
209213
ffmpeg_streaming
@@ -225,6 +229,9 @@ A path can also be passed to save a copy of files on your local machine.
225229
progress=progress)
226230
)
227231
```
232+
233+
Please visit **[this page](https://video.aminyazdanpanah.com/python/start/save-clouds)** to see more examples and usage of these clouds.
234+
228235
**NOTE:** You can open a file from your local machine(or a cloud) and save files to a local path or a cloud(or multiple clouds) or both.
229236

230237
<p align="center"><img src="https://github.com/aminyazdanpanah/aminyazdanpanah.github.io/blob/master/video-streaming/video-streaming.gif?raw=true" width="100%"></p>

0 commit comments

Comments
 (0)