Skip to content

Commit 26148ff

Browse files
fix php code style
1 parent 92fd2c1 commit 26148ff

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

README.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ Alternatively, add the dependency directly to your `composer.json` file:
5151

5252
## Quickstart
5353
First of all, you need to include the package in your code:
54-
``` php
54+
```php
5555
require 'vendor/autoload.php'; // path to the autoload file
5656
```
5757

5858
### Configuration
5959
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.
6060

61-
``` php
61+
```php
6262
use Monolog\Handler\StreamHandler;
6363
use Monolog\Logger;
6464

@@ -80,29 +80,29 @@ There are several ways to open a resource.
8080

8181
#### 1. From an FFmpeg supported resource
8282
You can pass a local path of video(or a supported resource) to the `open` method:
83-
``` php
83+
```php
8484
$video = $ffmpeg->open('/var/media/video.mp4');
8585
```
8686

8787
See **[FFmpeg Protocols Documentation](https://ffmpeg.org/ffmpeg-protocols.html)** for more information about supported resources such as HTTP, FTP, and etc.
8888

8989
**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"');
9292
```
9393

9494
#### 2. From Clouds
9595
You can open a file from a cloud by passing an array of cloud configuration to the `openFromCloud` method.
9696

97-
``` php
97+
```php
9898
$video = $ffmpeg->openFromCloud($from_google_cloud);
9999
```
100100
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.
101101

102102
#### 3. Capture Webcam or Screen (Live Streaming)
103103
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.
104104

105-
``` php
105+
```php
106106
$capture = $ffmpeg->capture("CAMERA NAME OR SCREEN NAME");
107107
```
108108
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](
112112
**[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)
113113

114114
Create DASH files:
115-
``` php
115+
```php
116116
$video->dash()
117117
->x264() // Format of the video. Alternatives: hevc() and vp9()
118118
->autoGenerateRepresentations() // Auto generate representations
119119
->save(); // It can be passed a path to the method or it can be null
120120
```
121121
Generate representations manually:
122-
``` php
122+
```php
123123
use Streaming\Representation;
124124

125125
$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
142142
**[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)
143143

144144
Create HLS files:
145-
``` php
145+
```php
146146
$video->hls()
147147
->x264()
148148
->autoGenerateRepresentations([720, 360]) // You can limit the number of representatons
149149
->save();
150150
```
151151
Generate representations manually:
152-
``` php
152+
```php
153153
use Streaming\Representation;
154154

155155
$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
171171
##### Single Key
172172
The following code generates a key for all segment files.
173173

174-
``` php
174+
```php
175175
//A path you want to save a random key to your local machine
176176
$save_to = '/home/public_html/"PATH TO THE KEY DIRECTORY"/key'
177177

@@ -200,7 +200,7 @@ However FFmpeg supports AES encryption for HLS packaging, which you can encrypt
200200

201201
### Transcoding
202202
A format can also extend `FFMpeg\Format\ProgressableInterface` to get realtime information about the transcoding.
203-
``` php
203+
```php
204204
$format = new Streaming\Format\X264();
205205
$format->on('progress', function ($video, $format, $percentage){
206206
// 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.
222222

223223
#### 1. To a Local Path
224224
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
226226
$dash = $video->dash()
227227
->x264()
228228
->autoGenerateRepresentations()
229229

230230
$dash->save('/var/media/dash-stream.mpd');
231231
```
232232
It can also be null. The default path to save files is the input path.
233-
``` php
233+
```php
234234
$hls = $video->hls()
235235
->x264()
236236
->autoGenerateRepresentations();
@@ -242,11 +242,11 @@ $hls->save();
242242
#### 2. To Clouds
243243
You can save your files to a cloud by passing an array of cloud configuration to the `save` method.
244244

245-
``` php
245+
```php
246246
$dash->save(null, [$to_aws_cloud, $to_google_cloud, $to_microsoft_azure, $to_custom_cloud]);
247247
```
248248
A path can also be passed to save a copy of files to your local machine.
249-
``` php
249+
```php
250250
$hls->save('/var/media/hls-stream.m3u8', [$to_google_cloud, $to_custom_cloud]);
251251
```
252252

@@ -261,7 +261,7 @@ Visit **[this page](https://video.aminyazdanpanah.com/start/clouds?r=save)** to
261261
#### 3. To a Server Instantly
262262
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.
263263

264-
``` php
264+
```php
265265
// DASH
266266
$dash->live('http://YOUR-WEBSITE.COM/live-stream/out.mpd');
267267

@@ -276,7 +276,7 @@ See **[FFmpeg Protocols Documentation](https://ffmpeg.org/ffmpeg-protocols.html)
276276

277277
### Metadata
278278
You can get information from multimedia streams and the video file using the following code.
279-
``` php
279+
```php
280280
$hls = $hls->save();
281281
$metadata = $hls->metadata()->export();
282282

@@ -289,7 +289,7 @@ See **[the example](https://video.aminyazdanpanah.com/start?r=metadata#metadata)
289289
You can convert your stream to a file or to another stream protocols. You should pass a manifest of the stream to the `open` method:
290290

291291
#### 1. HLS To DASH
292-
``` php
292+
```php
293293
$stream = $ffmpeg->open('https://www.aminyazdanpanah.com/?PATH/TO/HLS-MANIFEST.M3U8');
294294

295295
$stream->dash()
@@ -299,7 +299,7 @@ $stream->dash()
299299
```
300300

301301
#### 2. DASH To HLS
302-
``` php
302+
```php
303303
$stream = $ffmpeg->open('https://www.aminyazdanpanah.com/?PATH/TO/DASH-MANIFEST.MPD');
304304

305305
$stream->hls()
@@ -309,7 +309,7 @@ $stream->hls()
309309
```
310310

311311
#### 3. Stream(DASH or HLS) To File
312-
``` php
312+
```php
313313
$format = new Streaming\Format\x264();
314314
$format->on('progress', function ($video, $format, $percentage){
315315
echo sprintf("\rTranscoding...(%s%%) [%s%s]", $percentage, str_repeat('#', $percentage), str_repeat('-', (100 - $percentage)));
@@ -322,14 +322,14 @@ $stream->stream2file()
322322

323323
### Other Advanced Features
324324
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.
325-
``` php
326-
$ffmpeg = Streaming\FFMpeg::create()
325+
```php
326+
$ffmpeg = Streaming\FFMpeg::create();
327327
$video = $ffmpeg->openFromCloud($from_cloud, '/var/media/new/video.mp4');
328328
```
329329

330330
#### Extracting image
331331
You can extract a frame at any timecode using the `FFMpeg\Media\Video::frame` method.
332-
``` php
332+
```php
333333
$frame = $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(42));
334334
$frame->save('/var/media/poster.jpg');
335335
```
@@ -340,7 +340,7 @@ A gif is an animated image extracted from a sequence of the video.
340340

341341
You can save gif files using the FFMpeg\Media\Gif::save method.
342342

343-
``` php
343+
```php
344344
$video
345345
->gif(FFMpeg\Coordinate\TimeCode::fromSeconds(2), new FFMpeg\Coordinate\Dimension(640, 480), 3)
346346
->save('/var/media/animated_image.gif');
@@ -394,15 +394,15 @@ You can use these libraries to play your streams.
394394
## FAQs
395395
**I created stream files and now what should I pass to a player?**
396396
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).
398398

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!
401401

402402
**I uploaded my stream files to a cloud but it does not play on my website?**
403403
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.
404404

405-
**Does [IOS](https://www.apple.com/ios) support DASH stream?**
405+
**Does [IOS](https://www.apple.com/ios) support the DASH stream?**
406406
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.
407407

408408
See [this page](https://video.aminyazdanpanah.com/start?r=faq#faq) for more FAQs.

0 commit comments

Comments
 (0)