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
+30-30Lines changed: 30 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -51,14 +51,14 @@ Alternatively, add the dependency directly to your `composer.json` file:
51
51
52
52
## Quickstart
53
53
First of all, you need to include the package in your code:
54
-
```php
54
+
```php
55
55
require 'vendor/autoload.php'; // path to the autoload file
56
56
```
57
57
58
58
### Configuration
59
59
This package will autodetect FFmpeg and FFprobe binaries. If you want to give binary paths explicitly, you can pass an array as configuration. A Psr\Logger\LoggerInterface can also be passed to log binary executions.
60
60
61
-
```php
61
+
```php
62
62
use Monolog\Handler\StreamHandler;
63
63
use Monolog\Logger;
64
64
@@ -80,29 +80,29 @@ There are several ways to open a resource.
80
80
81
81
#### 1. From an FFmpeg supported resource
82
82
You can pass a local path of video(or a supported resource) to the `open` method:
83
-
```php
83
+
```php
84
84
$video = $ffmpeg->open('/var/media/video.mp4');
85
85
```
86
86
87
87
See **[FFmpeg Protocols Documentation](https://ffmpeg.org/ffmpeg-protocols.html)** for more information about supported resources such as HTTP, FTP, and etc.
88
88
89
89
**For example:**
90
-
```php
91
-
$video = $ffmpeg->open(https://www.aminyazdanpanah.com/?"PATH TO A VIDEO FILE" or "PATH TO A LIVE HTTP STREAM");
90
+
```php
91
+
$video = $ffmpeg->open('https://www.aminyazdanpanah.com/?"PATH TO A VIDEO FILE" or "PATH TO A LIVE HTTP STREAM"');
92
92
```
93
93
94
94
#### 2. From Clouds
95
95
You can open a file from a cloud by passing an array of cloud configuration to the `openFromCloud` method.
Visit **[this page](https://video.aminyazdanpanah.com/start/clouds?r=open)** to see some examples of opening a file from **[Amazon S3](https://aws.amazon.com/s3)**, **[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.
101
101
102
102
#### 3. Capture Webcam or Screen (Live Streaming)
103
103
You can pass the name of a supported, connected capture device(i.e. the name of a webcam, camera, screen and etc) to the `capture` method to stream a live media over network.
104
104
105
-
```php
105
+
```php
106
106
$capture = $ffmpeg->capture("CAMERA NAME OR SCREEN NAME");
107
107
```
108
108
To list the supported, connected capture devices, see **[FFmpeg Capture Webcam](https://trac.ffmpeg.org/wiki/Capture/Webcam)** and **[FFmpeg Capture Desktop](https://trac.ffmpeg.org/wiki/Capture/Desktop)**.
@@ -112,14 +112,14 @@ To list the supported, connected capture devices, see **[FFmpeg Capture Webcam](
112
112
**[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)
113
113
114
114
Create DASH files:
115
-
```php
115
+
```php
116
116
$video->dash()
117
117
->x264() // Format of the video. Alternatives: hevc() and vp9()
118
118
->autoGenerateRepresentations() // Auto generate representations
119
119
->save(); // It can be passed a path to the method or it can be null
120
120
```
121
121
Generate representations manually:
122
-
```php
122
+
```php
123
123
use Streaming\Representation;
124
124
125
125
$r_144p = (new Representation)->setKiloBitrate(95)->setResize(256, 144);
@@ -142,14 +142,14 @@ See **[DASH section](https://video.aminyazdanpanah.com/start?r=dash#dash)** in t
142
142
**[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)
143
143
144
144
Create HLS files:
145
-
```php
145
+
```php
146
146
$video->hls()
147
147
->x264()
148
148
->autoGenerateRepresentations([720, 360]) // You can limit the number of representatons
149
149
->save();
150
150
```
151
151
Generate representations manually:
152
-
```php
152
+
```php
153
153
use Streaming\Representation;
154
154
155
155
$r_360p = (new Representation)->setKiloBitrate(276)->setResize(640, 360);
@@ -171,7 +171,7 @@ You must specify a path to save a random key to your local machine and also a UR
171
171
##### Single Key
172
172
The following code generates a key for all segment files.
173
173
174
-
```php
174
+
```php
175
175
//A path you want to save a random key to your local machine
176
176
$save_to = '/home/public_html/"PATH TO THE KEY DIRECTORY"/key'
177
177
@@ -200,7 +200,7 @@ However FFmpeg supports AES encryption for HLS packaging, which you can encrypt
200
200
201
201
### Transcoding
202
202
A format can also extend `FFMpeg\Format\ProgressableInterface` to get realtime information about the transcoding.
203
-
```php
203
+
```php
204
204
$format = new Streaming\Format\X264();
205
205
$format->on('progress', function ($video, $format, $percentage){
206
206
// You can update a field in your database or can log it to a file
@@ -222,15 +222,15 @@ There are several ways to save files.
222
222
223
223
#### 1. To a Local Path
224
224
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.
225
-
```php
225
+
```php
226
226
$dash = $video->dash()
227
227
->x264()
228
228
->autoGenerateRepresentations()
229
229
230
230
$dash->save('/var/media/dash-stream.mpd');
231
231
```
232
232
It can also be null. The default path to save files is the input path.
233
-
```php
233
+
```php
234
234
$hls = $video->hls()
235
235
->x264()
236
236
->autoGenerateRepresentations();
@@ -242,11 +242,11 @@ $hls->save();
242
242
#### 2. To Clouds
243
243
You can save your files to a cloud by passing an array of cloud configuration to the `save` method.
@@ -261,7 +261,7 @@ Visit **[this page](https://video.aminyazdanpanah.com/start/clouds?r=save)** to
261
261
#### 3. To a Server Instantly
262
262
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.
You can easily use other advanced features in the **[PHP-FFMpeg](https://github.com/PHP-FFMpeg/PHP-FFMpeg)** library. In fact, when you open a file with the `open` method(or `openFromCloud`), it holds the Media object that belongs to the PHP-FFMpeg.
@@ -340,7 +340,7 @@ A gif is an animated image extracted from a sequence of the video.
340
340
341
341
You can save gif files using the FFMpeg\Media\Gif::save method.
342
342
343
-
```php
343
+
```php
344
344
$video
345
345
->gif(FFMpeg\Coordinate\TimeCode::fromSeconds(2), new FFMpeg\Coordinate\Dimension(640, 480), 3)
346
346
->save('/var/media/animated_image.gif');
@@ -394,15 +394,15 @@ You can use these libraries to play your streams.
394
394
## FAQs
395
395
**I created stream files and now what should I pass to a player?**
396
396
You must pass a **master playlist(manifest) URL**(e.x. `https://www.aminyazdanpanah.com/?"PATH TO STREAM DIRECTORY"/dash-stream.mpd` or `/PATH_TO_STREAM_DIRECTORY/hls-stream.m3u8` ) to a player.
397
-
See the demo page of these players for more information(**[hls.js Demo](https://hls-js.netlify.app/demo/)**, **[dash.js Demo](https://reference.dashif.org/dash.js/v3.1.2/samples/dash-if-reference-player/index.html)**, **[videojs](https://videojs.com/advanced?video=elephantsdream)** and etc).
397
+
See the demo page of these players for more information(**[hls.js Demo](https://hls-js.netlify.app/demo/)**, **[dash.js Demo](https://reference.dashif.org/dash.js/v3.1.2/samples/dash-if-reference-player/index.html)**, **[videojs Demo](https://videojs.com/advanced?video=elephantsdream)** and etc).
398
398
399
-
**My player does not show quality selector to change the quality of video?**
400
-
Some Players does not have embedded quality selector to change this option and you should install(or add) the plugin for this use case. For example if your are using Videojs to play your stream, you can install **[videojs-hls-quality-selector](https://github.com/chrisboustead/videojs-hls-quality-selector)** to show the quality selector. For adding a plugin to other players, you can easily Google it!
399
+
**My player does not show the quality selector button to change the video quality?**
400
+
Some Players do not have an embedded quality selector button to change this option and you should install(or add) the plugin for this use case. For example, if you are using Videojs to play your stream, you can install **[videojs-hls-quality-selector](https://github.com/chrisboustead/videojs-hls-quality-selector)** to show the quality selector. For adding a plugin to other players, you can easily Google it!
401
401
402
402
**I uploaded my stream files to a cloud but it does not play on my website?**
403
403
If you save your stream content to a cloud(i.e. **[Amazon S3](https://aws.amazon.com/s3)**), make sure your contents are **PUBLIC**. If they are not, you must change the access control.
404
404
405
-
**Does [IOS](https://www.apple.com/ios) support DASH stream?**
405
+
**Does [IOS](https://www.apple.com/ios) support the DASH stream?**
406
406
No, 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.
407
407
408
408
See [this page](https://video.aminyazdanpanah.com/start?r=faq#faq) for more FAQs.
0 commit comments