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
Copy file name to clipboardExpand all lines: README.md
+19-25Lines changed: 19 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -108,14 +108,13 @@ To list the supported, connected capture devices, see **[FFmpeg Capture Webcam](
108
108
109
109
110
110
### DASH
111
-
**[Dynamic Adaptive Streaming over HTTP (DASH)](http://dashif.org/)**, also known as MPEG-DASH, is an adaptive bitrate streaming technique that enables highquality streaming of media content over the Internet delivered from conventional HTTP web servers. [Learn more](https://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP)
112
-
111
+
**[Dynamic Adaptive Streaming over HTTP (DASH)](http://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. [Learn more](https://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP)
112
+
113
113
Create DASH files:
114
114
```php
115
115
$video->dash()
116
-
->hevc() // Format of the video. Alternatives: x264() and vp9()
116
+
->x264() // Format of the video. Alternatives: hevc() and vp9()
117
117
->autoGenerateRepresentations() // Auto generate representations
118
-
->setAdaption('id=0,streams=v id=1,streams=a') // Set the adaption.
119
118
->save(); // It can be passed a path to the method or it can be null
120
119
```
121
120
Generate representations manually:
@@ -132,16 +131,15 @@ $r_2k = (new Representation)->setKiloBitrate(6144)->setResize(2560, 1440);
132
131
$r_4k = (new Representation)->setKiloBitrate(17408)->setResize(3840, 2160);
See **[DASH section](https://video.aminyazdanpanah.com/start?r=dash#dash)** in the documentation, for more examples.
141
139
142
140
### HLS
143
-
**[HTTP Live Streaming (also known as HLS)](https://developer.apple.com/streaming/)** is an HTTP-based adaptive bitrate streaming communications protocol implemented by Apple Inc. as part of its QuickTime, Safari, OS X, and iOS software. Client implementations are also available in Microsoft Edge, Firefox and some versions of Google Chrome. Support is widespread in streaming media servers. [Learn more](https://en.wikipedia.org/wiki/HTTP_Live_Streaming)
144
-
141
+
**[HTTP Live Streaming (also known as HLS)](https://developer.apple.com/streaming/)** is an HTTP-based adaptive bitrate streaming communications protocol implemented by Apple Inc. as part of its QuickTime, Safari, OS X, and iOS software. Client implementations are also available in Microsoft Edge, Firefox, and some versions of Google Chrome. Support is widespread in streaming media servers. [Learn more](https://en.wikipedia.org/wiki/HTTP_Live_Streaming)
142
+
145
143
Create HLS files:
146
144
```php
147
145
$video->hls()
@@ -173,12 +171,12 @@ You must specify a path to save a random key to your local machine and also a UR
173
171
The following code generates a key for all segment files.
174
172
175
173
```php
176
-
//A path you want to save a random key to your server
177
-
$save_to = '/home/public_html/"PATH TO THE KEY DIRECTORY"/key';
174
+
//A path you want to save a random key to your local machine
175
+
$save_to = '/home/public_html/"PATH TO THE KEY DIRECTORY"/key'
178
176
179
177
//A URL (or a path) to access the key on your website
180
-
$url = 'https://www.aminyazdanpanah.com/?"PATH TO THE KEY DIRECTORY"/key';
181
-
// or $url = '/PATH TO THE KEY DIRECTORY/key';
178
+
$url = 'https://www.aminyazdanpanah.com/?"PATH TO THE KEY DIRECTORY"/key'
179
+
// or $url = '/"PATH TO THE KEY DIRECTORY"/key';
182
180
183
181
$video->hls()
184
182
->encryption($save_to, $url)
@@ -192,17 +190,17 @@ An integer as a "key rotation period" can also be passed to the `encryption` met
192
190
193
191
See **[the example](https://video.aminyazdanpanah.com/start?r=enc-hls#hls-encryption)** for more information.
194
192
195
-
**IMPORTANT:** It is very important to protect your key(s) on your website. For example, you can check a token(using a Get or Post HTTP method) to access the key(s) on your website. You can also check a session(or cookie) on your website to restrict access to the key(s)(**It is highly recommended**).
193
+
**IMPORTANT:** It is very important to protect your key(s) on your website. For example, you can use a token(using a Get or Post HTTP method) to check if the user is eligible to access the key or not. You can also use a session(or cookie) on your website to restrict access to the key(s)(**It is highly recommended**).
196
194
197
195
##### DRM
198
196
However FFmpeg supports AES encryption for HLS packaging, which you can encrypt your content, it is not a full **[DRM](https://en.wikipedia.org/wiki/Digital_rights_management)** solution. If you want to use a full DRM solution, I recommend trying **[FairPlay Streaming](https://developer.apple.com/streaming/fps/)** solution which then securely exchange keys, and protect playback on devices.
199
197
200
-
**Besides [Apple’s FairPlay](https://developer.apple.com/streaming/fps/)** DRM system, you can also use other DRM systems such as **[Microsoft's PlayReady](https://www.microsoft.com/playready/overview/)** and **[Google’s Widevine](https://www.widevine.com/)**.
198
+
**Besides [Apple's FairPlay](https://developer.apple.com/streaming/fps/)** DRM system, you can also use other DRM systems such as **[Microsoft's PlayReady](https://www.microsoft.com/playready/overview/)** and **[Google's Widevine](https://www.widevine.com/)**.
201
199
202
200
### Transcoding
203
201
A format can also extend `FFMpeg\Format\ProgressableInterface` to get realtime information about the transcoding.
204
202
```php
205
-
$format = new Streaming\Format\hevc();
203
+
$format = new Streaming\Format\X264();
206
204
$format->on('progress', function ($video, $format, $percentage){
207
205
// You can update a field in your database or can log it to a file
208
206
// You can also create a socket connection and show a progress bar to users
@@ -212,7 +210,6 @@ $format->on('progress', function ($video, $format, $percentage){
212
210
$video->dash()
213
211
->setFormat($format)
214
212
->autoGenerateRepresentations()
215
-
->setAdaption('id=0,streams=v id=1,streams=a')
216
213
->save();
217
214
```
218
215
@@ -226,9 +223,8 @@ There are several ways to save files.
226
223
You can pass a local path to the `save` method. If there was no directory in the path, then the package auto makes the directory.
227
224
```php
228
225
$dash = $video->dash()
229
-
->hevc()
226
+
->x264()
230
227
->autoGenerateRepresentations()
231
-
->setAdaption('id=0,streams=v id=1,streams=a');
232
228
233
229
$dash->save('/var/media/dash-stream.mpd');
234
230
```
@@ -262,9 +258,7 @@ Visit **[this page](https://video.aminyazdanpanah.com/start/clouds?r=save)** to
You can pass a url(or a supported resource like `ftp`) to live method to upload all the segments files to the HTTP server(or other protocols) using the HTTP PUT method, and update the manifest files every refresh times.
266
-
267
-
If you want to save stream files to your local machine, use the `save` method.
261
+
You can pass a URL(or a supported resource like `FTP`) to live method to upload all the segments files to the HTTP server(or other protocols) using the HTTP PUT method and update the manifest files every refresh times.
268
262
269
263
```php
270
264
// DASH
@@ -357,12 +351,12 @@ This method has a third optional boolean parameter, which is the duration of the
357
351
To see more examples, visit the **[PHP-FFMpeg Documentation](https://github.com/PHP-FFMpeg/PHP-FFMpeg)** page.
358
352
359
353
## Asynchronous Task Execution
360
-
Packaging process might take a while and it is recommended to run it in the background(or in a cloud e.g. AWS). There are some libraries that you can use for this use case.
354
+
The packaging process might take a while and it is recommended to run it in the background(or in a cloud e.g. AWS). There are some libraries that you can use for this use case.
361
355
-**[Symphony(The Console Component)](https://github.com/symfony/console):** You can use this library to create command-line commands. Your console commands can be used for any recurring task, such as cronjobs, imports, or other batch jobs. [Learn more](https://symfony.com/doc/current/components/console.html#learn-more)
362
356
363
357
-**[Laravel(Queues)](https://github.com/illuminate/queue):** If you are using Laravel for development, Laravel Queues is a wonderful tool for this use case. It allows you to create a job and dispatch it. [Learn more](https://laravel.com/docs/7.x/queues)
364
358
365
-
**NOTE:** You can also create a script to create packaged video files and create your own crontab file to run the script.
359
+
**NOTE:** You can also create a script and run it in your cronjob.
366
360
367
361
## Several Open Source Players
368
362
You can use these libraries to play your streams.
@@ -394,9 +388,9 @@ You can use these libraries to play your streams.
394
388
395
389
**NOTE-1:** You must pass a **link of the master playlist(manifest)**(i.e. `https://www.aminyazdanpanah.com/?"PATH TO STREAM DIRECTORY"/dash-stream.mpd` or `/PATH_TO_STREAM_DIRECTORY/hls-stream.m3u8` ) to these players.
396
390
397
-
**NOTE-2:** If you save your stream to a cloud(i.e. **[Amazon S3](https://aws.amazon.com/s3)**), the link of your playlist and also other content **MUST BE PUBLIC**.
391
+
**NOTE-2:** If you save your stream content to a cloud(i.e. **[Amazon S3](https://aws.amazon.com/s3)**), the link of your playlist and other content **MUST BE PUBLIC**.
398
392
399
-
**NOTE-3:** As you may know, **[IOS](https://www.apple.com/ios)** does not have native support for DASH. Although there are some libraries such as **[Viblast](https://github.com/Viblast/ios-player-sdk)** and **[MPEGDASH-iOS-Player](https://github.com/MPEGDASHPlayer/MPEGDASH-iOS-Player)** to support this technique, I have never tested them. So maybe som of them will not work correctly.
393
+
**NOTE-3:** As you may know, **[IOS](https://www.apple.com/ios)** does not have native support for DASH. Although there are some libraries such as **[Viblast](https://github.com/Viblast/ios-player-sdk)** and **[MPEGDASH-iOS-Player](https://github.com/MPEGDASHPlayer/MPEGDASH-iOS-Player)** to support this technique, I have never tested them. So maybe some of them will not work properly.
0 commit comments