Skip to content

Commit 3a5067f

Browse files
- Test updated
- Some minor improvements and bug fixes
1 parent 88ad783 commit 3a5067f

File tree

16 files changed

+242
-127
lines changed

16 files changed

+242
-127
lines changed

.appveyor.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ environment:
2323
- PHP_VERSION: Latest_Version
2424

2525
init:
26-
- ps: $env:PATH = 'c:\tools\php;c:\ProgramData\ComposerSetup\bin;' + $env:PATH
26+
- ps: $env:PATH = 'c:\tools\php;c:\OpenSSL-v111-Win64\bin;c:\ProgramData\ComposerSetup\bin;' + $env:PATH
2727

2828
install:
2929
- ps: Set-Service wuauserv -StartupType Manual # Chocolatey will try to install Windows updates when installing PHP.
@@ -53,4 +53,5 @@ test_script:
5353
- cd c:\projects\project-code
5454
- ffmpeg -version
5555
- mediainfo --version
56+
- openssl version
5657
- vendor\bin\phpunit tests

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ A clear and concise description of what the bug is.
1212

1313
**To Reproduce**
1414
Steps to reproduce the behavior:
15-
1. Go to '...'
16-
2. Click on '....'
17-
3. Scroll down to '....'
15+
1. Go to '/../...'
16+
2. On Line '...'
17+
3. The code '....'
1818
4. See error
1919

2020
**Expected behavior**
@@ -23,16 +23,12 @@ A clear and concise description of what you expected to happen.
2323
**Screenshots**
2424
If applicable, add screenshots to help explain your problem.
2525

26-
**Desktop (please complete the following information):**
27-
- OS: [e.g. iOS]
28-
- Browser [e.g. chrome, safari]
29-
- Version [e.g. 22]
30-
31-
**Smartphone (please complete the following information):**
32-
- Device: [e.g. iPhone6]
33-
- OS: [e.g. iOS8.1]
34-
- Browser [e.g. stock browser, safari]
35-
- Version [e.g. 22]
26+
**Desktop/Server (please complete the following information):**
27+
- OS: [e.g. Linux]
28+
- Version [e.g. Ubuntu 18]
29+
- FFmpeg vesion
30+
- MediaInfo vesion
31+
- openSSL version
3632

3733
**Additional context**
3834
Add any other context about the problem here.

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: php
22

33
php:
4-
- 7.1
54
- 7.2
5+
- 7.3
66

77
env:
88
matrix:
@@ -28,5 +28,5 @@ install:
2828
script:
2929
- ffmpeg -version
3030
- mediainfo --version
31-
- mediainfo --Output=JSON tests/files/test.mp4
31+
- openssl version
3232
- vendor/bin/phpunit tests

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 Amin Yazdanpanah <www.aminyazdanpanah.com>
3+
Copyright (c) 2019 Amin Yazdanpanah <www.aminyazdanpanah.com>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# 📼 PHP FFMPEG Video Streaming
22

33
[![Build Status](https://travis-ci.org/aminyazdanpanah/PHP-FFmpeg-video-streaming.svg?branch=master)](https://travis-ci.org/aminyazdanpanah/PHP-FFmpeg-video-streaming)
4-
[![Build status](https://img.shields.io/appveyor/ci/aminyazdanpanah/PHP-FFmpeg-video-streaming/master.svg?style=flat-square&logo=appveyor)](https://ci.appveyor.com/project/aminyazdanpanah/php-ffmpeg-video-streaming)
5-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/aminyazdanpanah/PHP-FFmpeg-video-streaming/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/aminyazdanpanah/PHP-FFmpeg-video-streaming/?branch=master)
6-
[![Code Intelligence Status](https://scrutinizer-ci.com/g/aminyazdanpanah/PHP-FFmpeg-video-streaming/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)
7-
[![Total Downloads](https://img.shields.io/packagist/dt/aminyazdanpanah/php-ffmpeg-video-streaming.svg?style=flat-square)](https://packagist.org/packages/aminyazdanpanah/php-ffmpeg-video-streaming)
8-
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/aminyazdanpanah/PHP-FFmpeg-video-streaming/blob/master/LICENSE)
9-
[![Latest Version on Packagist](https://img.shields.io/packagist/v/aminyazdanpanah/php-ffmpeg-video-streaming.svg?style=flat-square)](https://packagist.org/packages/aminyazdanpanah/php-ffmpeg-video-streaming)
4+
[![Build status](https://img.shields.io/appveyor/ci/aminyazdanpanah/PHP-FFmpeg-video-streaming/master.svg?style=flat&logo=appveyor)](https://ci.appveyor.com/project/aminyazdanpanah/php-ffmpeg-video-streaming)
5+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/aminyazdanpanah/PHP-FFmpeg-video-streaming/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/aminyazdanpanah/PHP-FFmpeg-video-streaming/?branch=master)[![Total Downloads](https://img.shields.io/packagist/dt/aminyazdanpanah/php-ffmpeg-video-streaming.svg?style=flat)](https://packagist.org/packages/aminyazdanpanah/php-ffmpeg-video-streaming)
6+
[![Latest Version on Packagist](https://img.shields.io/packagist/vpre/aminyazdanpanah/PHP-FFmpeg-video-streaming?color=success)](https://packagist.org/packages/aminyazdanpanah/php-ffmpeg-video-streaming)
7+
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](https://github.com/aminyazdanpanah/PHP-FFmpeg-video-streaming/blob/master/LICENSE)
108

119
## Overview
12-
This package provides an integration with [PHP-FFmpeg](https://github.com/PHP-FFMpeg/PHP-FFMpeg) and packages well-known live streaming techniques such as DASH and HLS. Also you can use DRM for HLS packaging.
10+
This package provides integration with [PHP-FFmpeg](https://github.com/PHP-FFMpeg/PHP-FFMpeg) and packages well-known live streaming techniques such as DASH and HLS. Also, you can use DRM for HLS packaging.
1311

1412
- Before you get started, please read the FFMpeg Document found **[here](https://ffmpeg.org/ffmpeg-formats.html)**.
1513
- **[Full Documentation](https://video.aminyazdanpanah.com/)** is available describing all features and components.
@@ -45,33 +43,40 @@ This library requires a working FFMpeg. You will need both FFMpeg and FFProbe bi
4543
- Getting FFmpeg: https://ffmpeg.org/download.html
4644

4745
#### 2. MediaInfo
48-
For auto generating representations and also for digital media analysis, this package needs a working MediaInfo.
46+
For auto-generating representations and also for digital media analysis, this package needs a working MediaInfo.
4947
- Getting MediaInfo: https://mediaarea.net/en/MediaInfo
5048

51-
**NOTE:** You must download MediaInfo CLI. If you want this package autodetect the MediaInfo binary, you need to add the path of CLI to your system path. Otherwise, You have to pass the full path of binary to `setMediaInfoBinary` method.
49+
**NOTE:** You must download MediaInfo CLI. If you want this package autodetect the MediaInfo binary, you need to add the path of CLI to your system path. Otherwise, you have to pass the full path of binary to `setMediaInfoBinary` method.
5250

5351
#### 3. OpenSSL
5452
For HLS encryption you will need a working OpenSSL:
5553
- Getting OpenSSL: https://www.openssl.org/source/
5654
- Getting OpenSSL(Windows): https://slproweb.com/products/Win32OpenSSL.html
5755

58-
**NOTE:** Add the path of OpenSSL bin directory to system path to get the benefit of binary detection.
56+
**NOTE:** Add the path of OpenSSL bin directory to your system path to get the benefit of binary detection.
5957

6058
### Installing Package
61-
This version of the package is only compatible with PHP 7.1.0 and later.
59+
This version of the package is only compatible with PHP 7.2 or higher.
6260

63-
Install the package via composer:
61+
Install the package via **[composer](https://getcomposer.org/)**:
6462

6563
``` bash
6664
composer require aminyazdanpanah/php-ffmpeg-video-streaming
6765
```
6866

6967
## Usage
70-
You can find Full Documentation **[here](https://video.aminyazdanpanah.com/).**
68+
First of all, you need to include the package in Your Code:
69+
70+
``` php
71+
require 'vendor/autoload.php'; // path to the autoload file
72+
```
73+
74+
- If you are using such a framework(e.g. [Laravel](https://github.com/laravel/laravel)) that include the autoload automatically, then you can skip this step.
75+
- You can find Full Documentation **[here](https://video.aminyazdanpanah.com/).**
7176

7277
### Configuration
7378

74-
FFMpeg 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.
79+
FFMpeg 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.
7580

7681
``` php
7782
$config = [
@@ -96,13 +101,13 @@ $video = $ffmpeg->open('/var/www/media/videos/test.mp4');
96101
```
97102

98103
#### 2. From Cloud
99-
You can open a file by passing a URL to `fromURL` method:
104+
You can open a file by passing a URL to the `fromURL` method:
100105

101106
``` php
102107
$video = $ffmpeg->fromURL("https://www.aminyazdanpanah.com/my_sweetie.mp4");
103108
```
104109

105-
Also, the path to save the file, the method of request, and [request options](http://docs.guzzlephp.org/en/stable/request-options.html) can be passed to the method.
110+
Also, the path to save the file, the method of the request, and [request options](http://docs.guzzlephp.org/en/stable/request-options.html) can be passed to the method.
106111

107112
``` php
108113
$api = 'https://www.aminyazdanpanah.com/api/v1.0';
@@ -140,7 +145,7 @@ Amazon S3 or Amazon Simple Storage Service is a service offered by [Amazon Web S
140145
- For getting credentials, you need to have an AWS account or you can [create one](https://portal.aws.amazon.com/billing/signup#/start).
141146
- Before you get started, please read the "AWS SDK for PHP" Document found **[here](https://aws.amazon.com/sdk-for-php/)**.
142147

143-
For downloading a file from Amazon S3, you need to pass an array as configuration, name of the bucket, and the key of your bucket to `fromS3` method:
148+
For downloading a file from Amazon S3, you need to pass an associative array of options, the name of your bucket, and the key of your bucket to the `fromS3` method:
144149

145150
``` php
146151
$config = [
@@ -174,7 +179,7 @@ $video->DASH()
174179
->save(); // It can be passed a path to the method or it can be null
175180
```
176181

177-
Also, You can create multi-representations video files using `Representation` object:
182+
Also, You can create multi-representations video files using the `Representation` object:
178183

179184
``` php
180185
use Streaming\Representation;
@@ -207,7 +212,7 @@ $video->HLS()
207212
->save();
208213
```
209214

210-
Create multi-qualities video files using `Representation` object(set bit-rate and size manually):
215+
Create multi-qualities video files using the `Representation` object(set bit-rate and size manually):
211216

212217
``` php
213218
use Streaming\Representation;
@@ -235,7 +240,7 @@ See [HLS options](https://ffmpeg.org/ffmpeg-formats.html#hls-2) for more informa
235240

236241
The encryption process requires some kind of secret (key) together with an encryption algorithm.
237242

238-
HLS uses AES in cipher block chaining (CBC) mode. This means each block is encrypted using the cipher text of the preceding block. [Learn more](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation)
243+
HLS uses AES in cipher block chaining (CBC) mode. This means each block is encrypted using the ciphertext of the preceding block. [Learn more](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation)
239244

240245
Before we can encrypt videos, we need an encryption key. However you can use any software that can generate a key, this package requires a working OpenSSL to create a key:
241246

@@ -264,9 +269,9 @@ $video->HLS()
264269

265270
### Transcoding
266271

267-
You can transcode videos using the `on` method in the format class.
268-
269-
Transcoding progress can be monitored in realtime, see Format documentation in [FFMpeg documentation](https://github.com/PHP-FFMpeg/PHP-FFMpeg#documentation) for more information.
272+
A format can also extend FFMpeg\Format\ProgressableInterface to get realtime information about the transcoding.
273+
274+
Transcoding progress can be monitored in realtime, see Format documentation in [FFMpeg documentation](https://github.com/PHP-FFMpeg/PHP-FFMpeg#documentation) for more information.
270275

271276
``` php
272277
$format = new Streaming\Format\HEVC();
@@ -303,7 +308,7 @@ $video->HLS()
303308
There are three options to save your packaged video files:
304309

305310
#### 1. To a Local Path
306-
You can pass a local path to the `save` method. If there was no directory in the path, then the package auto make the directory.
311+
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.
307312

308313
``` php
309314
$dash = $video->DASH()
@@ -392,16 +397,16 @@ $hls->saveToS3($config, $dest, '/var/www/media/videos/hls/test.m3u8');
392397

393398
For more information, please read [AWS SDK for PHP](https://aws.amazon.com/sdk-for-php/) document.
394399

395-
- **NOTE:** You can mix opening and saving options together. For Instance, you can open a file on your local computer/server and save packaged files to a Cloud (or vice versa).
400+
- **NOTE:** You can mix opening and saving options together. For instance, you can open a file on your local computer/server and save packaged files to a Cloud (or vice versa).
396401

397402
![schema](/docs/schema.gif?raw=true "schema" )
398403

399404
### Video Analysis
400-
This library uses [MediaInfo](https://mediaarea.net/en/MediaInfo) to analyze videos and extracting metadata. Why MediaInfo?! Although FFprobe can go way more in depth and is much more powerful, in some cases MediaInfo is much more reliable and more powerful. For instance, as it can be seen in this issue(#12), MKV format does not store some parameters such as duration, frame rate, and bit rate in its container. So FFprobe cannot obtain the value of these parameter and as a result, this package cannot calculate the value of `kilo bite rate` to auto generate representations. However, MediaInfo cannot obtain these value as well, it has a general info that contains the value of `OveralBitRate`. In spite of `OveralBitRate` is not equal to the video bite rate, it can estimate the value of video's bite rate.
405+
This library uses [MediaInfo](https://mediaarea.net/en/MediaInfo) to analyze videos and extracting metadata. Why MediaInfo?! Although FFprobe can go way more in-depth and is much more powerful, in some cases MediaInfo is much more reliable and more powerful. For instance, as it can be seen in this issue([#12](https://github.com/aminyazdanpanah/PHP-FFmpeg-video-streaming/issues/12)), MKV format does not store some parameters such as duration, frame rate, and bit rate in its container. So FFprobe cannot obtain the value of these parameters and as a result, this package cannot calculate the value of `kilo bite rate` to auto-generate representations. However, MediaInfo cannot obtain these value as well, it has general info that contains the value of `OveralBitRate`. In spite of `OveralBitRate` is not equal to the video bite rate, it can estimate the value of the video's bite rate.
401406

402407
- Please download and install the latest version of [MediaInfo](https://mediaarea.net/en/MediaInfo).
403408

404-
You can extract the media info and analyze streams when packaging is done. It also puts a `analysis.json` file in the packaged video directory:
409+
You can extract the media info and analyze streams when packaging was done. It also puts a `analysis.json` file in the packaged video directory:
405410

406411
``` php
407412
$metadata = $hls->save();
@@ -428,7 +433,7 @@ var_dump($general->all(), $video->all(), $audio->all());
428433
```
429434

430435
### Other Advanced Features
431-
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 `open` method(or `fromURL`), it holds the Media object that belongs to the PHP-FFMpeg.
436+
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 `fromURL`), it holds the Media object that belongs to the PHP-FFMpeg.
432437

433438
For exploring other advanced features, please read the [Full PHP-FFMpeg Documentation](https://github.com/PHP-FFMpeg/PHP-FFMpeg#documentation).
434439

@@ -451,7 +456,8 @@ $video
451456
```
452457

453458
## Several Open Source Players
454-
You can use these players to play your packaged videos
459+
You can use these players to play your packaged videos.
460+
455461
- **WEB**
456462
- DASH and HLS: [Plyr](https://github.com/sampotts/plyr)
457463
- DASH and HLS: [MediaElement.js](https://github.com/mediaelement/mediaelement)
@@ -465,15 +471,15 @@ You can use these players to play your packaged videos
465471
- **Android**
466472
- DASH and HLS: [ExoPlayer](https://github.com/google/ExoPlayer)
467473

468-
## Contributing and Reporting bug
474+
## Contributing and Reporting Bugs
469475

470476
I'd love your help in improving, correcting, adding to the specification.
471477
Please [file an issue](https://github.com/aminyazdanpanah/PHP-FFmpeg-video-streaming/issues)
472478
or [submit a pull request](https://github.com/aminyazdanpanah/PHP-FFmpeg-video-streaming/pulls).
473479

474480
- Please see [Contributing File](https://github.com/aminyazdanpanah/PHP-FFmpeg-video-streaming/blob/master/CONTRIBUTING.md) for more information.
475481

476-
- Please just [file an issue](https://github.com/aminyazdanpanah/PHP-FFmpeg-video-streaming/issues) for reporting bugs.
482+
- Please, just [file an issue](https://github.com/aminyazdanpanah/PHP-FFmpeg-video-streaming/issues) for reporting bugs.
477483
- If you discover a security vulnerability within this package, please send an e-mail to Amin Yazdanpanah via:
478484
contact [AT] aminyazdanpanah • com.
479485

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"DynamicAdaptiveStreamingOverHTTP"
1818
],
1919
"homepage": "https://github.com/aminyazdanpanah/PHP-FFmpeg-video-streaming",
20-
2120
"license": "MIT",
2221
"authors": [
2322
{
@@ -39,15 +38,15 @@
3938
}
4039
},
4140
"require-dev": {
42-
"phpunit/phpunit": "7.5.0"
41+
"phpunit/phpunit": "~8.0"
4342
},
4443
"autoload-dev": {
4544
"psr-4": {
4645
"Tests\\FFMpegStreaming\\": "tests"
4746
}
4847
},
4948
"require": {
50-
"php": "^7.1",
49+
"php": "^7.2",
5150
"php-ffmpeg/php-ffmpeg": "^0.14",
5251
"guzzlehttp/guzzle": "~6.0",
5352
"aws/aws-sdk-php": "~3.0"

tests/DASHFiltersTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public function testGetApply()
3333
"-bf", "1", "-keyint_min", "120", "-g", "120"
3434
, "-sc_threshold", "0", "-b_strategy", "0", "-strict", "-2", "-use_timeline"
3535
, "1", "-use_template", "1", "-f", "dash", "-map", "0", "-b:v:0"
36-
, "237k", "-s:v:0", "256x144", "-map", "0", "-b:v:1", "292k"
37-
, "-s:v:1", "426x240", "-map", "0", "-b:v:2", "380k", "-s:v:2", "640x360"
36+
, "129k", "-s:v:0", "256x144", "-map", "0", "-b:v:1", "159k"
37+
, "-s:v:1", "426x240", "-map", "0", "-b:v:2", "207k", "-s:v:2", "640x360"
3838
, "-adaptation_sets", "id=0,streams=v id=1,streams=a"
3939
],
4040
$apply);

0 commit comments

Comments
 (0)