diff --git a/.ac-php-conf.json b/.ac-php-conf.json new file mode 100644 index 0000000..db1009c --- /dev/null +++ b/.ac-php-conf.json @@ -0,0 +1,13 @@ +{ + "use-cscope": null, + "tag-dir": null, + "filter": { + "php-file-ext-list": [ + "php" + ], + "php-path-list": [ + "." + ], + "php-path-list-without-subdir": [] + } +} \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a7c44dd --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes index 88dfe64..a8c82f1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,15 @@ -.gitattributes export-ignore -.gitignore export-ignore -.github export-ignore -docs export-ignore -tests export-ignore -phpunit.xml.dist export-ignore -.travis.yml export-ignore +# Path-based git attributes +# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html + +# Ignore all test and documentation with "export-ignore". +/.github export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/phpunit.xml.dist export-ignore +/psalm.xml.dist export-ignore +/tests export-ignore +/.editorconfig export-ignore +/.php-cs-fixer.dist.php export-ignore +/art export-ignore +/docs export-ignore +/UPGRADING.md export-ignore diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..c8843f9 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: goodevilgenius diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index ef7b4f8..0000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,25 +0,0 @@ -| Q | A -| -------------- | --- -| Bug? | no -| New Feature? | no -| Version Used | Specific tag or commit sha -| FFmpeg Version | FFmpeg or AVConv and version -| OS | Your OS and version - -#### Actual Behavior - -How does PHP-FFMpeg behave at the moment? - -#### Expected Behavior - -What is the behavior you expect? - -#### Steps to Reproduce - -What are the steps to reproduce this bug? Please add code examples, -screenshots or links to GitHub repositories that reproduce the problem. - -#### Possible Solutions - -If you have already ideas how to solve the issue, add them here. -Otherwise remove this section. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..78cdb51 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,14 @@ +blank_issues_enabled: false +contact_links: + - name: Ask a question + url: https://github.com/goodevilgenius/ffmpeg-mappable-media/discussions/new?category=q-a + about: Ask the community for help + - name: Request a feature + url: https://github.com/goodevilgenius/ffmpeg-mappable-media/discussions/new?category=ideas + about: Share ideas for new features + - name: Report a security issue + url: https://github.com/goodevilgenius/ffmpeg-mappable-media/security/policy + about: Learn how to notify us for sensitive bugs + - name: Report a bug + url: https://github.com/goodevilgenius/ffmpeg-mappable-media/issues/new + about: Report a reproducable bug diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 49205d2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,36 +0,0 @@ -| Q | A -| ------------------ | --- -| Bug fix? | no -| New feature? | no -| BC breaks? | no -| Deprecations? | no -| Fixed tickets | fixes #issuenum -| Related issues/PRs | #issuenum -| License | MIT - -#### What's in this PR? - -Explain the contents of the PR. - -#### Why? - -Which problem does the PR fix? - -#### Example Usage - -```php -$foo = new Foo(); - -// Now we can do -$foo->doSomething(); - -// Remove this section if not needed -~~~ - -#### BC Breaks/Deprecations - -Describe BC breaks/deprecations here (Remove this section if not needed). - -#### To Do - -- [ ] Create tests diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..30c8a49 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + labels: + - "dependencies" \ No newline at end of file diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 0000000..14da349 --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,32 @@ +name: dependabot-auto-merge +on: pull_request_target + +permissions: + pull-requests: write + contents: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v1.3.3 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Auto-merge Dependabot PRs for semver-minor updates + if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + - name: Auto-merge Dependabot PRs for semver-patch updates + if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..4917b37 --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,23 @@ +name: Check & fix styling + +on: [push] + +jobs: + php-cs-fixer: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + + - name: Run PHP CS Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --config=.php-cs-fixer.dist.php --allow-risky=yes + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Fix styling diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..514a49d --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,37 @@ +name: Tests + +on: [push, pull_request] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, windows-latest] + php: [8.0] + stability: [prefer-lowest, prefer-stable] + + name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + coverage: none + + - name: Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Install dependencies + run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction + + - name: Execute tests + run: vendor/bin/pest diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index 76475ce..0000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,48 +0,0 @@ -name: run-tests - -on: [push, pull_request] - -jobs: - test: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: true - matrix: - os: [ubuntu-20.04] - php: [8.1, 8.0] - ffmpeg: [5.0, 4.4] - dependency-version: [prefer-lowest, prefer-stable] - - name: ${{ matrix.os }} - P${{ matrix.php }} - FF${{ matrix.ffmpeg }} - ${{ matrix.dependency-version }} - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, mysql, mysqli, pdo_mysql, fileinfo - coverage: none - - - name: Install FFmpeg - uses: Iamshankhadeep/setup-ffmpeg@ffmpeg-5.0-20220119 - with: - version: ${{ matrix.ffmpeg }} - id: setup-ffmpeg - - - name: Install dependencies - run: | - composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest - - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ~/.composer/cache/files - key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}-dep-${{ matrix.dependency-version }} - - - name: Execute tests - run: vendor/bin/phpunit - env: - FFMPEG_TEMPORARY_FILES_ROOT: ${{ github.workspace }} diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml new file mode 100644 index 0000000..b20f3b6 --- /dev/null +++ b/.github/workflows/update-changelog.yml @@ -0,0 +1,28 @@ +name: "Update Changelog" + +on: + release: + types: [released] + +jobs: + update: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: main + + - name: Update Changelog + uses: stefanzweifel/changelog-updater-action@v1 + with: + latest-version: ${{ github.event.release.name }} + release-notes: ${{ github.event.release.body }} + + - name: Commit updated CHANGELOG + uses: stefanzweifel/git-auto-commit-action@v4 + with: + branch: main + commit_message: Update CHANGELOG + file_pattern: CHANGELOG.md diff --git a/.gitignore b/.gitignore index e69b0e3..841e6e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,13 @@ -#/nbproject/ -/vendor/ -/docs/build -composer.phar -composer.lock -phpunit.xml +.idea +.php_cs +.php_cs.cache .phpunit.result.cache +build +composer.lock +coverage +docs +phpunit.xml +psalm.xml +vendor .php-cs-fixer.cache -/tests/Functional/output/output-* -/docs/doctum.phar -/docs/source/API/API/cache/twig/* -.idea/ -/phpunit + diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..7ee4ffa --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,39 @@ +in([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->name('*.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +return (new PhpCsFixer\Config()) + ->setRules([ + '@PSR12' => true, + 'array_syntax' => ['syntax' => 'short'], + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'no_unused_imports' => true, + 'not_operator_with_successor_space' => true, + 'trailing_comma_in_multiline' => true, + 'phpdoc_scalar' => true, + 'unary_operator_spaces' => true, + 'binary_operator_spaces' => true, + 'blank_line_before_statement' => [ + 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], + ], + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_var_without_name' => true, + 'class_attributes_separation' => [ + 'elements' => [ + 'method' => 'one', + ], + ], + 'method_argument_space' => [ + 'on_multiline' => 'ensure_fully_multiline', + 'keep_multiple_spaces_after_comma' => true, + ], + 'single_trait_insert_per_statement' => true, + ]) + ->setFinder($finder); diff --git a/CHANGELOG-0.x.md b/CHANGELOG-0.x.md deleted file mode 100644 index 78aeb46..0000000 --- a/CHANGELOG-0.x.md +++ /dev/null @@ -1,173 +0,0 @@ -CHANGELOG -========= - -All notable changes to this project will be documented in this file. -This project adheres to [Semantic Versioning](http://semver.org/). - -[Unreleased] ------------- - -### Added - -- Add pull request and issue templates. -- Usage of new codec "aac" of ffmpeg 3 - -### Changed - -- Updated changelog to follow [keepachangelog.com](http://keepachangelog.com/) - style you see now here. - -[0.7.0] - 2016-12-15 --------------------- - -- Add support for FFMpeg 3 aac codec (@Nek-) -- Add a waveform filter to extract audio waveform images (@Romain) - -[0.6.1] - 2016-03-08 --------------------- - -- Support PHP 7 and test against -- Unused code cleanup (@haphan) -- Composer and tests cleanup (PSR-4 autoloading) -- Allow usage of evenement v2.0 - -[0.6.0] - 2016-01-30 --------------------- - -- AbstractData::get no longer throws exceptions (@sujayjaju). -- Add crop filter (@cangelis). -- Fix watermark (@sujayjaju). - -[0.5.1] - 2016-08-26 --------------------- - -- Fix video aspect ratio calculation (@nlegoff). - -[0.5.0] - 2014-08-12 --------------------- - -- Add support for Wav and AAC audio formats (@MrHash). -- Add watermark filter (@sylvainv). -- Add configuration for audio channels (@SimonSimCity). - -[0.4.4] - 2016-12-17 --------------------- - -- Fix width / height dimensions extraction. - -[0.4.3] - 2013-02-12 --------------------- - -- Fix using rotate and resize filters at the same time (#78) - -[0.4.2] - 2013-11-29 --------------------- - -- Add Rotate filter. -- Remove time_start metadata when using synchronize filter -- Remove restriction on filesystem resources. - -[0.4.1] - 2013-11-26 --------------------- - -- Add Clip filter (@guimeira) - -[0.4.0] - 2013-10-21 --------------------- - -- Add support for video to audio transcoding -- BC Break : Add FormatInterface::getPasses and FormatInterface::getExtraParams - -[0.3.5] - 2013-10-21 --------------------- - -- Add vorbis audio format (@jacobbudin). -- Fix #66 : Allow single pass encodings. - -[0.3.4] - 2013-09-05 --------------------- - -- Fix Invalid ratio computing. - -[0.3.3] - 2013-09-05 --------------------- - -- Add convenient Stream::getDimensions method to extract video dimension. -- Add DisplayRatioFixer Frame filter. - -[0.3.2] - 2013-08-08 --------------------- - -- Fix A/V synchronization over flash and HTML5 players. - -[0.3.1] - 2013-08-06 --------------------- - -- Allow use of FFProbe on remote URIs. -- Fix #47 : MediaTypeInterface::save adds filters depending on the codec. -- Save frame to target file without prompt. - -[0.3.0] - 2013-07-04 --------------------- - -- Complete rewrite of the library, lots of BC breaks, check the doc. - -[0.2.4] - 2013-05-10 --------------------- - -- Add Video\ResizableInterface::getModulus method for better output scaling (@retrojunk) -- Fix timeout setting on audio/video encoding (@xammep-ua) - -[0.2.3] - 2013-04-21 --------------------- - -- Add timeout getter and setter on FFMpeg and FFProbe -- Add timeout setting via second argument on FFMpeg::load and FFProbe::load - -[0.2.2] - 2013-02-11 --------------------- - -- Add compatibility with FFMpeg 1.1 -- Upgrade deprecated options (`-ab`, `-qscale` and `-b`) -- Use of a custom stat file for each multi-pass encoding (fix #20) -- Use larger version range for dependencies - -[0.2.1] - 2013-02-04 --------------------- - -- Parse the output of FFProbe using correct EOL sequences (@ak76) -- Add process timeout customization (@pulse00) -- Fix `accurate` option (`FFMpeg::extractImage`) - -[0.2.0] - 2012-12-13 --------------------- - -- Add HelperInterface and support for realtime progress ( @pulse00 ). -- Add `accurate` option to `FFMpeg::extractImage` method. - -0.1.0 - 2012-10-30 --------------------- - -- First stable version. - -[Unreleased]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.6.1...HEAD -[0.6.1]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.6.0...0.6.1 -[0.6.0]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.5.1...0.6.0 -[0.5.1]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.5.0...0.5.1 -[0.5.0]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.4.4...0.5.0 -[0.4.4]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.4.3...0.4.4 -[0.4.3]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.4.2...0.4.3 -[0.4.2]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.4.1...0.4.2 -[0.4.1]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.4.0...0.4.1 -[0.4.0]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.3.5...0.4.0 -[0.3.5]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.3.4...0.3.5 -[0.3.4]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.3.3...0.3.4 -[0.3.3]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.3.2...0.3.3 -[0.3.2]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.3.1...0.3.2 -[0.3.1]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.3.0...0.3.1 -[0.3.0]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.2.4...0.3.0 -[0.2.4]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.2.3...0.2.4 -[0.2.3]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.2.2...0.2.3 -[0.2.2]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.2.1...0.2.2 -[0.2.1]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.2.0...0.2.1 -[0.2.0]: https://github.com/PHP-FFMpeg/PHP-FFMpeg/compare/0.1.0...0.2.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index cbe4346..622f8e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,22 +1,4 @@ # Changelog -All Notable changes to the library will be documented in this file +All notable changes to `ffmpeg-mappable-media` will be documented in this file. -## 1.0.1 - 2022-02-22 - -- Added configuration key to customize the temporary directory used for passes. -- Fix for the path of the default `ffmpeg-passes*` temporary directory. - -## 1.0.0 - 2022-02-09 - -Upgraded dependencies, integrated the Alchemy Binary library, and dropped support for anything below PHP 8.0 - -- Support for Symfony 5.4 and 6.0 -- Support for `psr/log` v3 -- GitHub actions against FFmpeg 4.4 and 5.0 -- Integrated the Alchemy Binary library -- Replaced `neutron/temporary-filesystem` with `spatie/temporary-directory` -- PHPUnit 9.5 -- Removed Silex Service Provider -- Removed the auto-generated docs -- Removed support for anything below PHP 8.0 diff --git a/LICENSE b/LICENSE.md similarity index 85% rename from LICENSE rename to LICENSE.md index 07d4d9f..a54d47b 100644 --- a/LICENSE +++ b/LICENSE.md @@ -1,6 +1,6 @@ -MIT License +The MIT License (MIT) -Copyright (c) 2012-2021 Alchemy +Copyright (c) danjones000 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ORIGINAL_ALCHEMY_CHANGELOG.md b/ORIGINAL_ALCHEMY_CHANGELOG.md deleted file mode 100644 index f892249..0000000 --- a/ORIGINAL_ALCHEMY_CHANGELOG.md +++ /dev/null @@ -1,64 +0,0 @@ -CHANGELOG ---------- -* 1.6.0 (2015-03-02) - * BC Break: bump minimum PHP versions - * Allow use of evenement v2.0 (thanks @patkar for the P/R) - -* 1.5.0 (2013-06-21) - - * BC Break : ConfigurationInterface::get does not throw exceptions anymore - in case the key does not exist. Second argument is a default value to return - in case the key does not exist. - -* 1.4.1 (2013-05-23) - - * Add third parameter to BinaryInterface::command method to pass a listener or - an array of listener that will be registered just the time of the command. - -* 1.4.0 (2013-05-11) - - * Extract process run management to ProcessRunner. - * Add support for process listeners. - * Provides bundled DebugListener. - * Add BinaryInterface::command method. - * BC break : ProcessRunnerInterface::run now takes an SplObjectStorage containing - listeners as second argument. - * BC break : BinaryInterface no longer implements LoggerAwareInterface - as it is now supported by ProcessRunner. - -* 1.3.4 (2013-04-26) - - * Add BinaryDriver::run method. - -* 1.3.3 (2013-04-26) - - * Add BinaryDriver::createProcessMock method. - -* 1.3.2 (2013-04-26) - - * Add BinaryDriverTestCase for testing BinaryDriver implementations. - -* 1.3.1 (2013-04-24) - - * Add timeouts handling - -* 1.3.0 (2013-04-24) - - * Add BinaryInterface and AbstractBinary - -* 1.2.1 (2013-04-24) - - * Add ConfigurationAwareInterface - * Add ProcessBuilderAwareInterface - -* 1.2.0 (2013-04-24) - - * Add BinaryDriver\Configuration - -* 1.1.0 (2013-04-24) - - * Add support for timeouts via `setTimeout` method - -* 1.0.0 (2013-04-23) - - * First stable version. diff --git a/ORIGINAL_ALCHEMY_LICENSE b/ORIGINAL_ALCHEMY_LICENSE deleted file mode 100644 index e7bb314..0000000 --- a/ORIGINAL_ALCHEMY_LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -BinaryDriver is released with MIT License : - -Copyright (c) 2013 Alchemy - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. diff --git a/ORIGINAL_ALCHEMY_README.md b/ORIGINAL_ALCHEMY_README.md deleted file mode 100644 index 05b3a13..0000000 --- a/ORIGINAL_ALCHEMY_README.md +++ /dev/null @@ -1,190 +0,0 @@ -# Binary Driver - -Binary-Driver is a set of PHP tools to build binary drivers. - -[![Build Status](https://travis-ci.org/alchemy-fr/BinaryDriver.png?branch=master)](https://travis-ci.org/alchemy-fr/BinaryDriver) - -## Why ? - -You may wonder *Why building a library while I can use `exec` or -[symfony/process](https://github.com/symfony/Process) ?*. - -Here is a simple answer : - - - If you use `exec`, `passthru`, `system`, `proc_open` or any low level process - handling in PHP, you should have a look to [symfony/process](https://github.com/symfony/Process) - component that will provide an OO portable, testable and secure interface to - deal with this. It seems easy at first approach, but if you look at this - component [unit tests](https://github.com/symfony/Process/tree/master/Tests), - you will see that handling process in a simple interface can easily become a - nightmare. - - - If you already use symfony/process, and want to build binary drivers, you - will always have the same common set of methods and objects to configure, log, - debug, and generate processes. - This library is a base to implement any binary driver with this common set of - needs. - -## AbstractBinary - -`AbstractBinary` provides an abstract class to build a binary driver. It implements -`BinaryInterface`. - -Implementation example : - -```php -use Alchemy\BinaryDriver\AbstractBinary; - -class LsDriver extends AbstractBinary -{ - public function getName() - { - return 'ls driver'; - } -} - -$parser = new LsParser(); - -$driver = Driver::load('ls'); -// will return the output of `ls -a -l` -$parser->parse($driver->command(array('-a', '-l'))); -``` - -### Binary detection troubleshooting - -If you are using Nginx with PHP-fpm, executable detection may not work because of an empty `$_ENV['path']`. -To avoid having an empty `PATH` environment variable, add the following line to your `fastcgi_params` -config file (replace `/your/current/path/` with the output of `printenv PATH`) : - -``` -fastcgi_param PATH /your/current/path -``` - -## Logging - -You can log events with a `Psr\Log\LoggerInterface` by passing it in the load -method as second argument : - -```php -$logger = new Monolog\Logger('driver'); -$driver = Driver::load('ls', $logger); -``` - -## Listeners - -You can add custom listeners on processes. -Listeners are built on top of [Evenement](https://github.com/igorw/evenement) -and must implement `Alchemy\BinaryDriver\ListenerInterface`. - -```php -use Symfony\Component\Process\Process; - -class DebugListener extends EventEmitter implements ListenerInterface -{ - public function handle($type, $data) - { - foreach (explode(PHP_EOL, $data) as $line) { - $this->emit($type === Process::ERR ? 'error' : 'out', array($line)); - } - } - - public function forwardedEvents() - { - // forward 'error' events to the BinaryInterface - return array('error'); - } -} - -$listener = new DebugListener(); - -$driver = CustomImplementation::load('php'); - -// adds listener -$driver->listen($listener); - -$driver->on('error', function ($line) { - echo '[ERROR] ' . $line . PHP_EOL; -}); - -// removes listener -$driver->unlisten($listener); -``` - -### Bundled listeners - -The debug listener is a simple listener to catch `stderr` and `stdout` outputs ; -read the implementation for customization. - -```php -use Alchemy\BinaryDriver\Listeners\DebugListener; - -$driver = CustomImplementation::load('php'); -$driver->listen(new DebugListener()); - -$driver->on('debug', function ($line) { - echo $line; -}); -``` - -## ProcessBuilderFactory - -ProcessBuilderFactory ease spawning processes by generating Symfony [Process] -(http://symfony.com/doc/master/components/process.html) objects. - -```php -use Alchemy\BinaryDriver\ProcessBuilderFactory; - -$factory = new ProcessBuilderFactory('/usr/bin/php'); - -// return a Symfony\Component\Process\Process -$process = $factory->create('-v'); - -// echoes '/usr/bin/php' '-v' -echo $process->getCommandLine(); - -$process = $factory->create(array('-r', 'echo "Hello !";')); - -// echoes '/usr/bin/php' '-r' 'echo "Hello !";' -echo $process->getCommandLine(); -``` - -## Configuration - -A simple configuration object, providing an `ArrayAccess` and `IteratorAggregate` -interface. - -```php -use Alchemy\BinaryDriver\Configuration; - -$conf = new Configuration(array('timeout' => 0)); - -echo $conf->get('timeout'); - -if ($conf->has('param')) { - $conf->remove('param'); -} - -$conf->set('timeout', 20); - -$conf->all(); -``` - -Same example using the `ArrayAccess` interface : - -```php -use Alchemy\BinaryDriver\Configuration; - -$conf = new Configuration(array('timeout' => 0)); - -echo $conf['timeout']; - -if (isset($conf['param'])) { - unset($conf['param']); -} - -$conf['timeout'] = 20; -``` - -## License - -This project is released under the MIT license. diff --git a/README.md b/README.md index 7fbfb34..1308c8c 100644 --- a/README.md +++ b/README.md @@ -1,736 +1,60 @@ -# PHP-FFMPEG -[![Latest Version on Packagist](https://img.shields.io/packagist/v/PHP-FFMpeg/PHP-FFMpeg.svg?style=flat-square)](https://packagist.org/packages/PHP-FFMpeg/PHP-FFMpeg) -[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) -![run-tests](https://github.com/PHP-FFMpeg/PHP-FFMpeg/workflows/run-tests/badge.svg) -[![Total Downloads](https://img.shields.io/packagist/dt/PHP-FFMpeg/PHP-FFMpeg.svg?style=flat-square)](https://packagist.org/packages/PHP-FFMpeg/PHP-FFMpeg) +[](https://supportukrainenow.org) -An Object-Oriented library to convert video/audio files with FFmpeg / AVConv. +# This is my package ffmpeg-mappable-media -## Your attention please +[![Latest Version on Packagist](https://img.shields.io/packagist/v/danjones000/ffmpeg-mappable-media.svg?style=flat-square)](https://packagist.org/packages/danjones000/ffmpeg-mappable-media) +[![Tests](https://codeberg.org/danjones000/ffmpeg-mappable-media/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://codeberg.org/danjones000/ffmpeg-mappable-media/actions/workflows/run-tests.yml) +[![Total Downloads](https://img.shields.io/packagist/dt/danjones000/ffmpeg-mappable-media.svg?style=flat-square)](https://packagist.org/packages/danjones000/ffmpeg-mappable-media) -### How this library works: +This is where your description should go. Try and limit it to a paragraph or two. Consider adding a small example. -This library requires a working [FFMpeg install](https://ffmpeg.org/download.html). You will need both FFMpeg and FFProbe binaries to use it. -Be sure that these binaries can be located with system PATH to get the benefit of the binary detection, -otherwise you should have to explicitly give the binaries path on load. +## Support us -### Known issues: +[](https://spatie.be/github-ad-click/ffmpeg-mappable-media) -- Using rotate and resize will produce a corrupted output when using -[libav](http://libav.org/) 0.8. The bug is fixed in version 9. This bug does not -appear in latest ffmpeg version. +We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us). + +We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards). ## Installation -This library requires PHP 8.0 or higher. For older versions of PHP, check out the [0.x-branch](https://github.com/PHP-FFMpeg/PHP-FFMpeg/tree/0.x). - -The recommended way to install PHP-FFMpeg is through [Composer](https://getcomposer.org). +You can install the package via composer: ```bash -$ composer require php-ffmpeg/php-ffmpeg +composer require danjones000/ffmpeg-mappable-media ``` -## Basic Usage +## Usage ```php - -require 'vendor/autoload.php'; - -$ffmpeg = FFMpeg\FFMpeg::create(); -$video = $ffmpeg->open('video.mpg'); -$video - ->filters() - ->resize(new FFMpeg\Coordinate\Dimension(320, 240)) - ->synchronize(); -$video - ->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(10)) - ->save('frame.jpg'); -$video - ->save(new FFMpeg\Format\Video\X264(), 'export-x264.mp4') - ->save(new FFMpeg\Format\Video\WMV(), 'export-wmv.wmv') - ->save(new FFMpeg\Format\Video\WebM(), 'export-webm.webm'); +$skeleton = new Danjones\FFMpeg(); +echo $skeleton->echoPhrase('Hello, Danjones!'); ``` -## Documentation +## Testing -This documentation is an introduction to discover the API. It's recommended -to browse the source code as it is self-documented. - -### FFMpeg - -`FFMpeg\FFMpeg` is the main object to use to manipulate medias. To build it, -use the static `FFMpeg\FFMpeg::create`: - -```php -$ffmpeg = FFMpeg\FFMpeg::create(); +```bash +composer test ``` -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. +## Changelog -```php -$ffmpeg = FFMpeg\FFMpeg::create(array( - 'ffmpeg.binaries' => '/opt/local/ffmpeg/bin/ffmpeg', - 'ffprobe.binaries' => '/opt/local/ffmpeg/bin/ffprobe', - 'timeout' => 3600, // The timeout for the underlying process - 'ffmpeg.threads' => 12, // The number of threads that FFMpeg should use -), $logger); -``` +Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. -You may pass a `temporary_directory` key to specify a path for temporary files. +## Contributing -```php -$ffmpeg = FFMpeg\FFMpeg::create(array( - 'temporary_directory' => '/var/ffmpeg-tmp' -), $logger); -``` +Please see [CONTRIBUTING](https://codeberg.org/spatie/.github/blob/main/CONTRIBUTING.md) for details. -### Manipulate media +## Security Vulnerabilities -`FFMpeg\FFMpeg` creates media based on URIs. URIs could be either a pointer to a -local filesystem resource, an HTTP resource or any resource supported by FFmpeg. +Please review [our security policy](../../security/policy) on how to report security vulnerabilities. -**Note**: To list all supported resource type of your FFmpeg build, use the -`-protocols` command: +## Credits -``` -ffmpeg -protocols -``` - -To open a resource, use the `FFMpeg\FFMpeg::open` method. - -```php -$ffmpeg->open('video.mpeg'); -``` - -Two types of media can be resolved: `FFMpeg\Media\Audio` and `FFMpeg\Media\Video`. -A third type, `FFMpeg\Media\Frame`, is available through videos. - -### Video - -`FFMpeg\Media\Video` can be transcoded, ie: change codec, isolate audio or -video. Frames can be extracted. - -##### Transcoding - -You can transcode videos using the `FFMpeg\Media\Video:save` method. You will -pass a `FFMpeg\Format\FormatInterface` for that. - -Please note that audio and video bitrate are set on the format. You can disable the `-b:v` option by setting the kilo bitrate to 0. - -```php -$format = new FFMpeg\Format\Video\X264(); -$format->on('progress', function ($video, $format, $percentage) { - echo "$percentage % transcoded"; -}); - -$format - ->setKiloBitrate(1000) - ->setAudioChannels(2) - ->setAudioKiloBitrate(256); - -$video->save($format, 'video.avi'); -``` - -Transcoding progress can be monitored in realtime, see Format documentation -below for more information. - -##### Extracting image - -You can extract a frame at any timecode using the `FFMpeg\Media\Video::frame` -method. - -This code returns a `FFMpeg\Media\Frame` instance corresponding to the second 42. -You can pass any `FFMpeg\Coordinate\TimeCode` as argument, see dedicated -documentation below for more information. - -```php -$frame = $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(42)); -$frame->save('image.jpg'); -``` - -If you want to extract multiple images from the video, you can use the following filter: - -```php -$video - ->filters() - ->extractMultipleFrames(FFMpeg\Filters\Video\ExtractMultipleFramesFilter::FRAMERATE_EVERY_10SEC, '/path/to/destination/folder/') - ->synchronize(); - -$video - ->save(new FFMpeg\Format\Video\X264(), '/path/to/new/file'); -``` -By default, this will save the frames as `jpg` images. - -You are able to override this using `setFrameFileType` to save the frames in another format: -```php -$frameFileType = 'jpg'; // either 'jpg', 'jpeg' or 'png' -$filter = new ExtractMultipleFramesFilter($frameRate, $destinationFolder); -$filter->setFrameFileType($frameFileType); - -$video->addFilter($filter); -``` - -##### Clip - -Cuts the video at a desired point. Use input seeking method. It is faster option than use filter clip. - -```php -$clip = $video->clip(FFMpeg\Coordinate\TimeCode::fromSeconds(30), FFMpeg\Coordinate\TimeCode::fromSeconds(15)); -$clip->save(new FFMpeg\Format\Video\X264(), 'video.avi'); -``` - -The clip filter takes two parameters: - -- `$start`, an instance of `FFMpeg\Coordinate\TimeCode`, specifies the start point of the clip -- `$duration`, optional, an instance of `FFMpeg\Coordinate\TimeCode`, specifies the duration of the clip - -On clip you can apply same filters as on video. For example resizing filter. - -```php -$clip = $video->clip(FFMpeg\Coordinate\TimeCode::fromSeconds(30), FFMpeg\Coordinate\TimeCode::fromSeconds(15)); -$clip->filters()->resize(new FFMpeg\Coordinate\Dimension(320, 240), FFMpeg\Filters\Video\ResizeFilter::RESIZEMODE_INSET, true); -$clip->save(new FFMpeg\Format\Video\X264(), 'video.avi'); -``` - -##### Generate a waveform - -You can generate a waveform of an audio file using the `FFMpeg\Media\Audio::waveform` -method. - -This code returns a `FFMpeg\Media\Waveform` instance. -You can optionally pass dimensions as the first two arguments and an array of hex string colors for ffmpeg to use for the waveform, see dedicated -documentation below for more information. - -The output file MUST use the PNG extension. - -```php -$waveform = $audio->waveform(640, 120, array('#00FF00')); -$waveform->save('waveform.png'); -``` - -If you want to get a waveform from a video, convert it in an audio file first. - -```php -// Open your video file -$video = $ffmpeg->open( 'video.mp4' ); - -// Set an audio format -$audio_format = new FFMpeg\Format\Audio\Mp3(); - -// Extract the audio into a new file as mp3 -$video->save($audio_format, 'audio.mp3'); - -// Set the audio file -$audio = $ffmpeg->open( 'audio.mp3' ); - -// Create the waveform -$waveform = $audio->waveform(); -$waveform->save( 'waveform.png' ); -``` - -##### Filters - -You can apply filters on `FFMpeg\Media\Video` with the `FFMpeg\Media\Video::addFilter` -method. Video accepts Audio and Video filters. - -You can build your own filters and some are bundled in PHP-FFMpeg - they are -accessible through the `FFMpeg\Media\Video::filters` method. - -Filters are chainable - -```php -$video - ->filters() - ->resize($dimension, $mode, $useStandards) - ->framerate($framerate, $gop) - ->synchronize(); -``` - -###### Rotate - -Rotates a video to a given angle. - -```php -$video->filters()->rotate($angle); -``` - -The `$angle` parameter must be one of the following constants : - -- `FFMpeg\Filters\Video\RotateFilter::ROTATE_90`: 90° clockwise -- `FFMpeg\Filters\Video\RotateFilter::ROTATE_180`: 180° -- `FFMpeg\Filters\Video\RotateFilter::ROTATE_270`: 90° counterclockwise - -###### Resize - -Resizes a video to a given size. - -```php -$video->filters()->resize($dimension, $mode, $useStandards); -``` - -The resize filter takes three parameters: - -- `$dimension`, an instance of `FFMpeg\Coordinate\Dimension` -- `$mode`, one of the constants `FFMpeg\Filters\Video\ResizeFilter::RESIZEMODE_*` constants -- `$useStandards`, a boolean to force the use of the nearest aspect ratio standard. - -If you want a video in a non-standard ratio, you can use the padding filter to resize your video in the desired size, and wrap it into black bars. - -```php -$video->filters()->pad($dimension); -``` - -The pad filter takes one parameter: - -- `$dimension`, an instance of `FFMpeg\Coordinate\Dimension` - -Don't forget to save it afterwards. - -```php -$video->save(new FFMpeg\Format\Video\X264(), $new_file); -``` - -###### Watermark - -Watermark a video with a given image. - -```php -$video - ->filters() - ->watermark($watermarkPath, array( - 'position' => 'relative', - 'bottom' => 50, - 'right' => 50, - )); -``` - -The watermark filter takes two parameters: - -`$watermarkPath`, the path to your watermark file. -`$coordinates`, an array defining how you want your watermark positioned. You can use relative positioning as demonstrated above or absolute as such: - -```php -$video - ->filters() - ->watermark($watermarkPath, array( - 'position' => 'absolute', - 'x' => 1180, - 'y' => 620, - )); -``` - -###### Framerate - -Changes the frame rate of the video. - -```php -$video->filters()->framerate($framerate, $gop); -``` - -The framerate filter takes two parameters: - -- `$framerate`, an instance of `FFMpeg\Coordinate\FrameRate` -- `$gop`, a [GOP](https://wikipedia.org/wiki/Group_of_pictures) value (integer) - -###### Synchronize - -Synchronizes audio and video. - -Some containers may use a delay that results in desynchronized outputs. This -filter solves this issue. - -```php -$video->filters()->synchronize(); -``` - -###### Clip - -Cuts the video at a desired point. - -```php -$video->filters()->clip(FFMpeg\Coordinate\TimeCode::fromSeconds(30), FFMpeg\Coordinate\TimeCode::fromSeconds(15)); -``` - -The clip filter takes two parameters: - -- `$start`, an instance of `FFMpeg\Coordinate\TimeCode`, specifies the start point of the clip -- `$duration`, optional, an instance of `FFMpeg\Coordinate\TimeCode`, specifies the duration of the clip - -###### Crop - -Crops the video based on a width and height(a `Point`) - -```php -$video->filters()->crop(new FFMpeg\Coordinate\Point("t*100", 0, true), new FFMpeg\Coordinate\Dimension(200, 600)); -``` - -It takes two parameters: -- `$point`, an instance of `FFMpeg\Coordinate\Point`, specifies the point to crop -- `$dimension`, an instance of `FFMpeg\Coordinate\Dimension`, specifies the dimension of the output video - -### Audio - -`FFMpeg\Media\Audio` can be transcoded too, ie: change codec, isolate audio or -video. Frames can be extracted. - -##### Transcoding - -You can transcode audios using the `FFMpeg\Media\Audio:save` method. You will -pass a `FFMpeg\Format\FormatInterface` for that. - -Please note that audio kilobitrate is set on the audio format. - -```php -$ffmpeg = FFMpeg\FFMpeg::create(); -$audio = $ffmpeg->open('track.mp3'); - -$format = new FFMpeg\Format\Audio\Flac(); -$format->on('progress', function ($audio, $format, $percentage) { - echo "$percentage % transcoded"; -}); - -$format - ->setAudioChannels(2) - ->setAudioKiloBitrate(256); - -$audio->save($format, 'track.flac'); -``` - -Transcoding progress can be monitored in realtime, see Format documentation -below for more information. - -##### Filters - -You can apply filters on `FFMpeg\Media\Audio` with the `FFMpeg\Media\Audio::addFilter` -method. It only accepts audio filters. - -You can build your own filters and some are bundled in PHP-FFMpeg - they are -accessible through the `FFMpeg\Media\Audio::filters` method. - -##### Clipping -Cuts the audio at a desired point. - -```php -$audio->filters()->clip(FFMpeg\Coordinate\TimeCode::fromSeconds(30), FFMpeg\Coordinate\TimeCode::fromSeconds(15)); -``` - - -###### Metadata - -Add metadata to audio files. Just pass an array of key=value pairs of all -metadata you would like to add. If no arguments are passed into the filter -all metadata will be removed from input file. Currently supported data is -title, artist, album, artist, composer, track, year, description, artwork - -```php -$audio->filters()->addMetadata(["title" => "Some Title", "track" => 1]); - -//remove all metadata and video streams from audio file -$audio->filters()->addMetadata(); -``` - -Add artwork to the audio file -```php -$audio->filters()->addMetadata(["artwork" => "/path/to/image/file.jpg"]); -``` -NOTE: at present ffmpeg (version 3.2.2) only supports artwork output for .mp3 -files - -###### Resample - -Resamples an audio file. - -```php -$audio->filters()->resample($rate); -``` - -The resample filter takes two parameters : - -- `$rate`, a valid audio sample rate value (integer) - -#### Frame - -A frame is an image at a timecode of a video; see documentation above about -frame extraction. - -You can save frames using the `FFMpeg\Media\Frame::save` method. - -```php -$frame->save('target.jpg'); -``` - -This method has a second optional boolean parameter. Set it to true to get -accurate images; it takes more time to execute. - -#### Gif - -A gif is an animated image extracted from a sequence of the video. - -You can save gif files using the `FFMpeg\Media\Gif::save` method. - -```php -$video = $ffmpeg->open( '/path/to/video' ); -$video - ->gif(FFMpeg\Coordinate\TimeCode::fromSeconds(2), new FFMpeg\Coordinate\Dimension(640, 480), 3) - ->save($new_file); -``` - -This method has a third optional boolean parameter, which is the duration of the animation. -If you don't set it, you will get a fixed gif image. - -#### Concatenation - -This feature allows you to generate one audio or video file, based on multiple sources. - -There are two ways to concatenate videos, depending on the codecs of the sources. -If your sources have all been encoded with the same codec, you will want to use the `FFMpeg\Media\Concatenate::saveFromSameCodecs` which has way better performances. -If your sources have been encoded with different codecs, you will want to use the `FFMpeg\Media\Concatenate::saveFromDifferentCodecs`. - -The first function will use the initial codec as the one for the generated file. -With the second function, you will be able to choose which codec you want for the generated file. - -You also need to pay attention to the fact that, when using the saveFromDifferentCodecs method, -your files MUST have video and audio streams. - -In both cases, you will have to provide an array of files. - -To concatenate videos encoded with the same codec, do as follow: - -```php -// In order to instantiate the video object, you HAVE TO pass a path to a valid video file. -// We recommend that you put there the path of any of the video you want to use in this concatenation. -$video = $ffmpeg->open( '/path/to/video' ); -$video - ->concat(array('/path/to/video1', '/path/to/video2')) - ->saveFromSameCodecs('/path/to/new_file', TRUE); -``` - -The boolean parameter of the save function allows you to use the copy parameter which accelerates drastically the generation of the encoded file. - -To concatenate videos encoded with the different codec, do as follow: - -```php -// In order to instantiate the video object, you HAVE TO pass a path to a valid video file. -// We recommend that you put there the path of any of the video you want to use in this concatenation. -$video = $ffmpeg->open( '/path/to/video' ); - -$format = new FFMpeg\Format\Video\X264(); -$format->setAudioCodec("libmp3lame"); - -$video - ->concat(array('/path/to/video1', '/path/to/video2')) - ->saveFromDifferentCodecs($format, '/path/to/new_file'); -``` - -More details about concatenation in FFMPEG can be found [here](https://trac.ffmpeg.org/wiki/Concatenate), [here](https://ffmpeg.org/ffmpeg-formats.html#concat-1) and [here](https://ffmpeg.org/ffmpeg.html#Stream-copy). - -### AdvancedMedia -AdvancedMedia may have multiple inputs and multiple outputs. - -This class has been developed primarily to use with `-filter_complex`. - -So, its `filters()` method accepts only filters that can be used inside `-filter_complex` command. -AdvancedMedia already contains some built-in filters. - -#### Base usage -For example: - -```php -$advancedMedia = $ffmpeg->openAdvanced(array('video_1.mp4', 'video_2.mp4')); -$advancedMedia->filters() - ->custom('[0:v][1:v]', 'hstack', '[v]'); -$advancedMedia - ->map(array('0:a', '[v]'), new X264('aac', 'libx264'), 'output.mp4') - ->save(); -``` - -This code takes 2 input videos, stacks they horizontally in 1 output video and adds to this new video the audio from the first video. -(It is impossible with simple filtergraph that has only 1 input and only 1 output). - - -#### Complicated example -A more difficult example of possibilities of the AdvancedMedia. Consider all input videos already have the same resolution and duration. ("xstack" filter has been added in the 4.1 version of the ffmpeg). - -```php -$inputs = array( - 'video_1.mp4', - 'video_2.mp4', - 'video_3.mp4', - 'video_4.mp4', -); - -$advancedMedia = $ffmpeg->openAdvanced($inputs); -$advancedMedia->filters() - ->custom('[0:v]', 'negate', '[v0negate]') - ->custom('[1:v]', 'edgedetect', '[v1edgedetect]') - ->custom('[2:v]', 'hflip', '[v2hflip]') - ->custom('[3:v]', 'vflip', '[v3vflip]') - ->xStack('[v0negate][v1edgedetect][v2hflip][v3vflip]', XStackFilter::LAYOUT_2X2, 4, '[resultv]'); -$advancedMedia - ->map(array('0:a'), new Mp3(), 'video_1.mp3') - ->map(array('1:a'), new Flac(), 'video_2.flac') - ->map(array('2:a'), new Wav(), 'video_3.wav') - ->map(array('3:a'), new Aac(), 'video_4.aac') - ->map(array('[resultv]'), new X264('aac', 'libx264'), 'output.mp4') - ->save(); -``` - -This code takes 4 input videos, then the negates the first video, stores result in `[v0negate]` stream, detects edges in the second video, stores result in `[v1edgedetect]` stream, horizontally flips the third video, stores result in `[v2hflip]` stream, vertically flips the fourth video, stores result in `[v3vflip]` stream, then takes this 4 generated streams ans combine them in one 2x2 collage video. -Then saves audios from the original videos into the 4 different formats and saves the generated collage video into the separate file. - -As you can see, you can take multiple input sources, perform the complicated processing for them and produce multiple output files in the same time, in the one ffmpeg command. - -#### Just give me a map! -You do not have to use `-filter_complex`. You can use only `-map` options. For example, just extract the audio from the video: - -```php -$advancedMedia = $ffmpeg->openAdvanced(array('video.mp4')); -$advancedMedia - ->map(array('0:a'), new Mp3(), 'output.mp3') - ->save(); -``` - -#### Customisation -If you need you can extra customize the result ffmpeg command of the AdvancedMedia: - -```php -$advancedMedia = $ffmpeg->openAdvanced($inputs); -$advancedMedia - ->setInitialParameters(array('the', 'params', 'that', 'will', 'be', 'added', 'before', '-i', 'part', 'of', 'the', 'command')) - ->setAdditionalParameters(array('the', 'params', 'that', 'will', 'be', 'added', 'at', 'the', 'end', 'of', 'the', 'command')); -``` - -#### Formats - -A format implements `FFMpeg\Format\FormatInterface`. To save to a video file, -use `FFMpeg\Format\VideoInterface`, and `FFMpeg\Format\AudioInterface` for -audio files. - -A format can also extend `FFMpeg\Format\ProgressableInterface` to get realtime -information about the transcoding. - -Predefined formats already provide progress information as events. - -```php -$format = new FFMpeg\Format\Video\X264(); -$format->on('progress', function ($video, $format, $percentage) { - echo "$percentage % transcoded"; -}); - -$video->save($format, 'video.avi'); -``` - -The callback provided for the event can be any callable. - -##### Add additional parameters - -You can add additional parameters to your encoding requests based on your video format. - -The argument of the setAdditionalParameters method is an array. - -```php -$format = new FFMpeg\Format\Video\X264(); -$format->setAdditionalParameters(array('foo', 'bar')); -$video->save($format, 'video.avi'); -``` - -##### Add initial parameters - -You can also add initial parameters to your encoding requests based on your video format. This can be expecially handy in overriding a default input codec in FFMpeg. - -The argument of the setInitialParameters method is an array. - -```php -$format = new FFMpeg\Format\Video\X264(); -$format->setInitialParameters(array('-acodec', 'libopus')); -$video->save($format, 'video.avi'); -``` - -##### Create your own format - -The easiest way to create a format is to extend the abstract -`FFMpeg\Format\Video\DefaultVideo` and `FFMpeg\Format\Audio\DefaultAudio`. -and implement the following methods. - -```php -class CustomWMVFormat extends FFMpeg\Format\Video\DefaultVideo -{ - public function __construct($audioCodec = 'wmav2', $videoCodec = 'wmv2') - { - $this - ->setAudioCodec($audioCodec) - ->setVideoCodec($videoCodec); - } - - public function supportBFrames() - { - return false; - } - - public function getAvailableAudioCodecs() - { - return array('wmav2'); - } - - public function getAvailableVideoCodecs() - { - return array('wmv2'); - } -} -``` - -#### Coordinates - -FFMpeg uses many units for time and space coordinates. - -- `FFMpeg\Coordinate\AspectRatio` represents an aspect ratio. -- `FFMpeg\Coordinate\Dimension` represent a dimension. -- `FFMpeg\Coordinate\FrameRate` represent a framerate. -- `FFMpeg\Coordinate\Point` represent a point. (Supports dynamic points since v0.10.0) -- `FFMpeg\Coordinate\TimeCode` represent a timecode. - -### FFProbe - -`FFMpeg\FFProbe` is used internally by `FFMpeg\FFMpeg` to probe medias. You can -also use it to extract media metadata. - -```php -$ffprobe = FFMpeg\FFProbe::create(); -$ffprobe - ->streams('/path/to/video/mp4') // extracts streams informations - ->videos() // filters video streams - ->first() // returns the first video stream - ->get('codec_name'); // returns the codec_name property -``` - -```php -$ffprobe = FFMpeg\FFProbe::create(); -$ffprobe - ->format('/path/to/video/mp4') // extracts file informations - ->get('duration'); // returns the duration property -``` - -### Validating media files - -(since 0.10.0) -You can validate media files using PHP-FFMpeg's FFProbe wrapper. - -```php -$ffprobe = FFMpeg\FFProbe::create(); -$ffprobe->isValid('/path/to/file/to/check'); // returns bool -``` +- [Dan Jones](https://codeberg.org/danjones000) +- [All Contributors](../../contributors) ## License -This project is licensed under the [MIT license](http://opensource.org/licenses/MIT). - -Music: "Favorite Secrets" by Waylon Thornton -From the Free Music Archive -[CC BY NC SA](http://creativecommons.org/licenses/by-nc-sa/3.0/us/) - -Music: "Siesta" by Jahzzar -From the Free Music Archive -[CC BY SA](https://creativecommons.org/licenses/by-sa/3.0/) +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. diff --git a/composer.json b/composer.json index 0677d6e..c58e0ca 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { - "name": "php-ffmpeg/php-ffmpeg", - "type": "library", - "description": "FFMpeg PHP, an Object Oriented library to communicate with AVconv / ffmpeg", + "name": "danjones000/ffmpeg-mappable-media", + "description": "This is my package ffmpeg-mappable-media", "keywords": [ + "danjones000", "video processing", "video", "audio processing", @@ -12,64 +12,46 @@ "avprobe", "ffprobe" ], + "homepage": "https://codeberg.org/danjones000/ffmpeg-mappable-media", "license": "MIT", "authors": [ { - "name": "Romain Neutron", - "email": "imprec@gmail.com", - "homepage": "http://www.lickmychip.com/" - }, - { - "name": "Phraseanet Team", - "email": "info@alchemy.fr", - "homepage": "http://www.phraseanet.com/" - }, - { - "name": "Patrik Karisch", - "email": "patrik@karisch.guru", - "homepage": "http://www.karisch.guru" - }, - { - "name": "Romain Biard", - "email": "romain.biard@gmail.com", - "homepage": "https://www.strime.io/" - }, - { - "name": "Jens Hausdorf", - "email": "hello@jens-hausdorf.de", - "homepage": "https://jens-hausdorf.de" - }, - { - "name": "Pascal Baljet", - "email": "pascal@protone.media", - "homepage": "https://protone.media" + "name": "Dan Jones", + "email": "danjones@goodevilgenius.org", + "role": "Developer", + "homepage": "https://goodevilgenius.org" } ], "require": { - "php": "^8.0 || ^8.1", - "evenement/evenement": "^3.0", - "psr/log": "^1.0 || ^2.0 || ^3.0", - "spatie/temporary-directory": "^2.0", - "symfony/process": "^5.4 || ^6.0", - "symfony/cache": "^5.4 || ^6.0" - }, - "suggest": { - "php-ffmpeg/extras": "A compilation of common audio & video drivers for PHP-FFMpeg" + "php": "^8.0", + "php-ffmpeg/php-ffmpeg": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^9.5.10", - "mockery/mockery": "^1.5" + "friendsofphp/php-cs-fixer": "^3.0", + "pestphp/pest": "^1.20", + "spatie/ray": "^1.28" }, "autoload": { "psr-4": { - "FFMpeg\\": "src/FFMpeg", - "Alchemy\\BinaryDriver\\": "src/Alchemy/BinaryDriver" + "Danjones\\FFMpeg\\": "src" } }, "autoload-dev": { "psr-4": { - "Alchemy\\Tests\\BinaryDriver\\": "tests/Alchemy/BinaryDriver", - "Tests\\FFMpeg\\": "tests/FFMpeg" + "Danjones\\FFMpeg\\Tests\\": "tests" } - } + }, + "scripts": { + "test": "vendor/bin/pest", + "test-coverage": "vendor/bin/pest --coverage", + "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes" + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "pestphp/pest-plugin": true + } + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 597f999..aeb6002 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,24 +1,39 @@ - - - - - + - - tests/Alchemy/BinaryDriver - - - tests/FFMpeg/Unit - - - tests/FFMpeg/Functional + + tests - - - src/ - - + + + ./src + + + + + + + + + + - diff --git a/tests/Alchemy/BinaryDriver/AbstractBinaryTest.php b/tests/Alchemy/BinaryDriver/AbstractBinaryTest.php deleted file mode 100644 index 6be0cf1..0000000 --- a/tests/Alchemy/BinaryDriver/AbstractBinaryTest.php +++ /dev/null @@ -1,300 +0,0 @@ -find('php'); - - if (null === $php) { - $this->markTestSkipped('Unable to find a php binary'); - } - - return $php; - } - - public function testSimpleLoadWithBinaryPath() - { - $php = $this->getPhpBinary(); - $imp = Implementation::load($php); - $this->assertInstanceOf('Alchemy\Tests\BinaryDriver\Implementation', $imp); - - $this->assertEquals($php, $imp->getProcessBuilderFactory()->getBinary()); - } - - public function testMultipleLoadWithBinaryPath() - { - $php = $this->getPhpBinary(); - $imp = Implementation::load(['/zz/path/to/unexisting/command', $php]); - $this->assertInstanceOf('Alchemy\Tests\BinaryDriver\Implementation', $imp); - - $this->assertEquals($php, $imp->getProcessBuilderFactory()->getBinary()); - } - - public function testSimpleLoadWithBinaryName() - { - $php = $this->getPhpBinary(); - $imp = Implementation::load('php'); - $this->assertInstanceOf('Alchemy\Tests\BinaryDriver\Implementation', $imp); - - $this->assertEquals($php, $imp->getProcessBuilderFactory()->getBinary()); - } - - public function testMultipleLoadWithBinaryName() - { - $php = $this->getPhpBinary(); - $imp = Implementation::load(['bachibouzouk', 'php']); - $this->assertInstanceOf('Alchemy\Tests\BinaryDriver\Implementation', $imp); - - $this->assertEquals($php, $imp->getProcessBuilderFactory()->getBinary()); - } - - public function testLoadWithMultiplePathExpectingAFailure() - { - $this->expectException(ExecutableNotFoundException::class); - - Implementation::load(['bachibouzouk', 'moribon']); - } - - public function testLoadWithUniquePathExpectingAFailure() - { - $this->expectException(ExecutableNotFoundException::class); - - Implementation::load('bachibouzouk'); - } - - public function testLoadWithCustomLogger() - { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $imp = Implementation::load('php', $logger); - - $this->assertEquals($logger, $imp->getProcessRunner()->getLogger()); - } - - public function testLoadWithCustomConfigurationAsArray() - { - $conf = ['timeout' => 200]; - $imp = Implementation::load('php', null, $conf); - - $this->assertEquals($conf, $imp->getConfiguration()->all()); - } - - public function testLoadWithCustomConfigurationAsObject() - { - $conf = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock(); - $imp = Implementation::load('php', null, $conf); - - $this->assertEquals($conf, $imp->getConfiguration()); - } - - public function testProcessBuilderFactoryGetterAndSetters() - { - $imp = Implementation::load('php'); - $factory = $this->getMockBuilder('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface')->getMock(); - - $imp->setProcessBuilderFactory($factory); - $this->assertEquals($factory, $imp->getProcessBuilderFactory()); - } - - public function testConfigurationGetterAndSetters() - { - $imp = Implementation::load('php'); - $conf = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock(); - - $imp->setConfiguration($conf); - $this->assertEquals($conf, $imp->getConfiguration()); - } - - public function testTimeoutIsSetOnConstruction() - { - $imp = Implementation::load('php', null, ['timeout' => 42]); - $this->assertEquals(42, $imp->getProcessBuilderFactory()->getTimeout()); - } - - public function testTimeoutIsSetOnConfigurationSetting() - { - $imp = Implementation::load('php', null); - $imp->setConfiguration(new Configuration(['timeout' => 42])); - $this->assertEquals(42, $imp->getProcessBuilderFactory()->getTimeout()); - } - - public function testTimeoutIsSetOnProcessBuilderSetting() - { - $imp = Implementation::load('php', null, ['timeout' => 42]); - - $factory = $this->getMockBuilder('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface')->getMock(); - $factory->expects($this->once()) - ->method('setTimeout') - ->with(42); - - $imp->setProcessBuilderFactory($factory); - } - - public function testListenRegistersAListener() - { - $imp = Implementation::load('php'); - - $listeners = $this->getMockBuilder('Alchemy\BinaryDriver\Listeners\Listeners') - ->disableOriginalConstructor() - ->getMock(); - - $listener = $this->getMockBuilder('Alchemy\BinaryDriver\Listeners\ListenerInterface')->getMock(); - - $listeners->expects($this->once()) - ->method('register') - ->with($this->equalTo($listener), $this->equalTo($imp)); - - $reflexion = new \ReflectionClass('Alchemy\BinaryDriver\AbstractBinary'); - $prop = $reflexion->getProperty('listenersManager'); - $prop->setAccessible(true); - $prop->setValue($imp, $listeners); - - $imp->listen($listener); - } - - /** - * @dataProvider provideCommandParameters - */ - public function testCommandRunsAProcess($parameters, $bypassErrors, $expectedParameters, $output) - { - $imp = Implementation::load('php'); - $factory = $this->getMockBuilder('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface')->getMock(); - $processRunner = $this->getMockBuilder('Alchemy\BinaryDriver\ProcessRunnerInterface')->getMock(); - - $process = $this->getMockBuilder('Symfony\Component\Process\Process') - ->disableOriginalConstructor() - ->getMock(); - - $processRunner->expects($this->once()) - ->method('run') - ->with($this->equalTo($process), $this->isInstanceOf('SplObjectStorage'), $this->equalTo($bypassErrors)) - ->will($this->returnValue($output)); - - $factory->expects($this->once()) - ->method('create') - ->with($expectedParameters) - ->will($this->returnValue($process)); - - $imp->setProcessBuilderFactory($factory); - $imp->setProcessRunner($processRunner); - - $this->assertEquals($output, $imp->command($parameters, $bypassErrors)); - } - - /** - * @dataProvider provideCommandWithListenersParameters - */ - public function testCommandWithTemporaryListeners($parameters, $bypassErrors, $expectedParameters, $output, $count, $listeners) - { - $imp = Implementation::load('php'); - $factory = $this->getMockBuilder('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface')->getMock(); - $processRunner = $this->getMockBuilder('Alchemy\BinaryDriver\ProcessRunnerInterface')->getMock(); - - $process = $this->getMockBuilder('Symfony\Component\Process\Process') - ->disableOriginalConstructor() - ->getMock(); - - $firstStorage = $secondStorage = null; - - $processRunner->expects($this->exactly(2)) - ->method('run') - ->with($this->equalTo($process), $this->isInstanceOf('SplObjectStorage'), $this->equalTo($bypassErrors)) - ->will($this->returnCallback(function ($process, $storage, $errors) use ($output, &$firstStorage, &$secondStorage) { - if (null === $firstStorage) { - $firstStorage = $storage; - } else { - $secondStorage = $storage; - } - - return $output; - })); - - $factory->expects($this->exactly(2)) - ->method('create') - ->with($expectedParameters) - ->will($this->returnValue($process)); - - $imp->setProcessBuilderFactory($factory); - $imp->setProcessRunner($processRunner); - - $this->assertEquals($output, $imp->command($parameters, $bypassErrors, $listeners)); - $this->assertCount($count, $firstStorage); - $this->assertEquals($output, $imp->command($parameters, $bypassErrors)); - $this->assertCount(0, $secondStorage); - } - - public function provideCommandWithListenersParameters() - { - return [ - ['-a', false, ['-a'], 'loubda', 2, [$this->getMockListener(), $this->getMockListener()]], - ['-a', false, ['-a'], 'loubda', 1, [$this->getMockListener()]], - ['-a', false, ['-a'], 'loubda', 1, $this->getMockListener()], - ['-a', false, ['-a'], 'loubda', 0, []], - ]; - } - - public function provideCommandParameters() - { - return [ - ['-a', false, ['-a'], 'loubda'], - ['-a', true, ['-a'], 'loubda'], - ['-a -b', false, ['-a -b'], 'loubda'], - [['-a'], false, ['-a'], 'loubda'], - [['-a'], true, ['-a'], 'loubda'], - [['-a', '-b'], false, ['-a', '-b'], 'loubda'], - ]; - } - - public function testUnlistenUnregistersAListener() - { - $imp = Implementation::load('php'); - - $listeners = $this->getMockBuilder('Alchemy\BinaryDriver\Listeners\Listeners') - ->disableOriginalConstructor() - ->getMock(); - - $listener = $this->getMockBuilder('Alchemy\BinaryDriver\Listeners\ListenerInterface')->getMock(); - - $listeners->expects($this->once()) - ->method('unregister') - ->with($this->equalTo($listener), $this->equalTo($imp)); - - $reflexion = new \ReflectionClass('Alchemy\BinaryDriver\AbstractBinary'); - $prop = $reflexion->getProperty('listenersManager'); - $prop->setAccessible(true); - $prop->setValue($imp, $listeners); - - $imp->unlisten($listener); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject - */ - private function getMockListener() - { - $listener = $this->getMockBuilder(ListenerInterface::class)->getMock(); - $listener->expects($this->any()) - ->method('forwardedEvents') - ->willReturn([]); - - return $listener; - } -} - -class Implementation extends AbstractBinary -{ - public function getName() - { - return 'Implementation'; - } -} diff --git a/tests/Alchemy/BinaryDriver/AbstractProcessBuilderFactoryTest.php b/tests/Alchemy/BinaryDriver/AbstractProcessBuilderFactoryTest.php deleted file mode 100644 index 9f38ca4..0000000 --- a/tests/Alchemy/BinaryDriver/AbstractProcessBuilderFactoryTest.php +++ /dev/null @@ -1,98 +0,0 @@ -markTestSkipped('Unable to detect php binary, skipping'); - } - } - - public static function setUpBeforeClass(): void - { - $finder = new ExecutableFinder(); - static::$phpBinary = $finder->find('php'); - } - - public function testThatBinaryIsSetOnConstruction() - { - $factory = $this->getProcessBuilderFactory(static::$phpBinary); - $this->assertEquals(static::$phpBinary, $factory->getBinary()); - } - - public function testGetSetBinary() - { - $finder = new ExecutableFinder(); - $phpUnit = $finder->find('phpunit'); - - if (null === $phpUnit) { - $this->markTestSkipped('Unable to detect phpunit binary, skipping'); - } - - $factory = $this->getProcessBuilderFactory(static::$phpBinary); - $factory->useBinary($phpUnit); - $this->assertEquals($phpUnit, $factory->getBinary()); - } - - public function testUseNonExistantBinary() - { - $this->expectException(InvalidArgumentException::class); - - $factory = $this->getProcessBuilderFactory(static::$phpBinary); - $factory->useBinary('itissureitdoesnotexist'); - } - - public function testCreateShouldReturnAProcess() - { - $factory = $this->getProcessBuilderFactory(static::$phpBinary); - $process = $factory->create(); - - $this->assertInstanceOf('Symfony\Component\Process\Process', $process); - $this->assertEquals("'" . static::$phpBinary . "'", $process->getCommandLine()); - } - - public function testCreateWithStringArgument() - { - $factory = $this->getProcessBuilderFactory(static::$phpBinary); - $process = $factory->create('-v'); - - $this->assertInstanceOf('Symfony\Component\Process\Process', $process); - $this->assertEquals("'" . static::$phpBinary . "' '-v'", $process->getCommandLine()); - } - - public function testCreateWithArrayArgument() - { - $factory = $this->getProcessBuilderFactory(static::$phpBinary); - $process = $factory->create(['-r', 'echo "Hello !";']); - - $this->assertInstanceOf('Symfony\Component\Process\Process', $process); - $this->assertEquals("'" . static::$phpBinary . "' '-r' 'echo \"Hello !\";'", $process->getCommandLine()); - } - - public function testCreateWithTimeout() - { - $factory = $this->getProcessBuilderFactory(static::$phpBinary); - $factory->setTimeout(200); - $process = $factory->create(['-i']); - - $this->assertInstanceOf('Symfony\Component\Process\Process', $process); - $this->assertEquals(200, $process->getTimeout()); - } -} diff --git a/tests/Alchemy/BinaryDriver/ConfigurationTest.php b/tests/Alchemy/BinaryDriver/ConfigurationTest.php deleted file mode 100644 index 71e1891..0000000 --- a/tests/Alchemy/BinaryDriver/ConfigurationTest.php +++ /dev/null @@ -1,78 +0,0 @@ - 'value']); - - $this->assertTrue(isset($configuration['key'])); - $this->assertEquals('value', $configuration['key']); - - $this->assertFalse(isset($configuration['key2'])); - unset($configuration['key']); - $this->assertFalse(isset($configuration['key'])); - - $configuration['key2'] = 'value2'; - $this->assertTrue(isset($configuration['key2'])); - $this->assertEquals('value2', $configuration['key2']); - } - - public function testGetOnNonExistentKeyShouldReturnDefaultValue() - { - $conf = new Configuration(); - $this->assertEquals('booba', $conf->get('hooba', 'booba')); - $this->assertEquals(null, $conf->get('hooba')); - } - - public function testSetHasGetRemove() - { - $configuration = new Configuration(['key' => 'value']); - - $this->assertTrue($configuration->has('key')); - $this->assertEquals('value', $configuration->get('key')); - - $this->assertFalse($configuration->has('key2')); - $configuration->remove('key'); - $this->assertFalse($configuration->has('key')); - - $configuration->set('key2', 'value2'); - $this->assertTrue($configuration->has('key2')); - $this->assertEquals('value2', $configuration->get('key2')); - } - - public function testIterator() - { - $data = [ - 'key1' => 'value1', - 'key2' => 'value2', - 'key3' => 'value3', - ]; - - $captured = []; - $conf = new Configuration($data); - - foreach ($conf as $key => $value) { - $captured[$key] = $value; - } - - $this->assertEquals($data, $captured); - } - - public function testAll() - { - $data = [ - 'key1' => 'value1', - 'key2' => 'value2', - 'key3' => 'value3', - ]; - - $conf = new Configuration($data); - $this->assertEquals($data, $conf->all()); - } -} diff --git a/tests/Alchemy/BinaryDriver/Exceptions/ExecutionFailureExceptionTest.php b/tests/Alchemy/BinaryDriver/Exceptions/ExecutionFailureExceptionTest.php deleted file mode 100644 index a21bcf1..0000000 --- a/tests/Alchemy/BinaryDriver/Exceptions/ExecutionFailureExceptionTest.php +++ /dev/null @@ -1,33 +0,0 @@ -createLoggerMock(); - $runner = $this->getProcessRunner($logger); - - $process = $this->createProcessMock(1, false, '--helloworld--', null, "Error Output", true); - try{ - $runner->run($process, new \SplObjectStorage(), false); - $this->fail('An exception should have been raised'); - } - catch (ExecutionFailureException $e){ - $this->assertEquals("--helloworld--", $e->getCommand()); - $this->assertEquals("Error Output", $e->getErrorOutput()); - } - - } - -} \ No newline at end of file diff --git a/tests/Alchemy/BinaryDriver/LTSProcessBuilder.php b/tests/Alchemy/BinaryDriver/LTSProcessBuilder.php deleted file mode 100644 index dc6c033..0000000 --- a/tests/Alchemy/BinaryDriver/LTSProcessBuilder.php +++ /dev/null @@ -1,54 +0,0 @@ -arguments = $arguments; - parent::__construct($arguments); - } - - public function setArguments(array $arguments) - { - $this->arguments = $arguments; - - return $this; - } - - public function setPrefix($prefix) - { - $this->prefix = $prefix; - - return $this; - } - - public function setTimeout($timeout) - { - $this->timeout = $timeout; - - return $this; - } - - public function getProcess() - { - if (!$this->prefix && !count($this->arguments)) { - throw new LogicException('You must add() command arguments before calling getProcess().'); - } - - $args = $this->prefix ? array_merge(array($this->prefix), $this->arguments) : $this->arguments; - $script = implode(' ', array_map('escapeshellarg', $args)); - - return new Process($script, null, null, null, $this->timeout); - } -} diff --git a/tests/Alchemy/BinaryDriver/LTSProcessBuilderFactoryTest.php b/tests/Alchemy/BinaryDriver/LTSProcessBuilderFactoryTest.php deleted file mode 100644 index 4ab1d30..0000000 --- a/tests/Alchemy/BinaryDriver/LTSProcessBuilderFactoryTest.php +++ /dev/null @@ -1,28 +0,0 @@ -markTestSkipped('ProcessBuilder is not available.'); - return; - } - - parent::setUp(); - } - - protected function getProcessBuilderFactory($binary) - { - $factory = new ProcessBuilderFactory($binary); - $factory->setBuilder(new LTSProcessBuilder()); - ProcessBuilderFactory::$emulateSfLTS = false; - $factory->useBinary($binary); - - return $factory; - } -} diff --git a/tests/Alchemy/BinaryDriver/Listeners/DebugListenerTest.php b/tests/Alchemy/BinaryDriver/Listeners/DebugListenerTest.php deleted file mode 100644 index 29bf5f5..0000000 --- a/tests/Alchemy/BinaryDriver/Listeners/DebugListenerTest.php +++ /dev/null @@ -1,34 +0,0 @@ -on('debug', function ($line) use (&$lines) { - $lines[] = $line; - }); - $listener->handle(Process::ERR, "first line\nsecond line"); - $listener->handle(Process::OUT, "cool output"); - $listener->handle('unknown', "lalala"); - $listener->handle(Process::OUT, "another output\n"); - - $expected = [ - '[ERROR] first line', - '[ERROR] second line', - '[OUT] cool output', - '[OUT] another output', - '[OUT] ', - ]; - - $this->assertEquals($expected, $lines); - } -} diff --git a/tests/Alchemy/BinaryDriver/Listeners/ListenersTest.php b/tests/Alchemy/BinaryDriver/Listeners/ListenersTest.php deleted file mode 100644 index 67f9934..0000000 --- a/tests/Alchemy/BinaryDriver/Listeners/ListenersTest.php +++ /dev/null @@ -1,93 +0,0 @@ -register($listener); - - $n = 0; - $listener->on('received', function ($type, $data) use (&$n, &$capturedType, &$capturedData) { - $n++; - $capturedData = $data; - $capturedType = $type; - }); - - $type = 'type'; - $data = 'data'; - - $listener->handle($type, $data); - $listener->handle($type, $data); - - $listeners->unregister($listener); - - $listener->handle($type, $data); - - $this->assertEquals(3, $n); - $this->assertEquals($type, $capturedType); - $this->assertEquals($data, $capturedData); - } - - public function testRegisterAndForwardThenUnregister() - { - $listener = new MockListener(); - $target = new EventEmitter(); - - $n = 0; - $target->on('received', function ($type, $data) use (&$n, &$capturedType, &$capturedData) { - $n++; - $capturedData = $data; - $capturedType = $type; - }); - - $m = 0; - $listener->on('received', function ($type, $data) use (&$m, &$capturedType2, &$capturedData2) { - $m++; - $capturedData2 = $data; - $capturedType2 = $type; - }); - - $listeners = new Listeners(); - $listeners->register($listener, $target); - - $type = 'type'; - $data = 'data'; - - $listener->handle($type, $data); - $listener->handle($type, $data); - - $listeners->unregister($listener, $target); - - $listener->handle($type, $data); - - $this->assertEquals(2, $n); - $this->assertEquals(3, $m); - $this->assertEquals($type, $capturedType); - $this->assertEquals($data, $capturedData); - $this->assertEquals($type, $capturedType2); - $this->assertEquals($data, $capturedData2); - } -} - -class MockListener extends EventEmitter implements ListenerInterface -{ - public function handle($type, $data) - { - $this->emit('received', [$type, $data]); - } - - public function forwardedEvents() - { - return ['received']; - } -} diff --git a/tests/Alchemy/BinaryDriver/NONLTSProcessBuilderFactoryTest.php b/tests/Alchemy/BinaryDriver/NONLTSProcessBuilderFactoryTest.php deleted file mode 100644 index fe5f343..0000000 --- a/tests/Alchemy/BinaryDriver/NONLTSProcessBuilderFactoryTest.php +++ /dev/null @@ -1,15 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Alchemy\Tests\BinaryDriver; - -use Alchemy\BinaryDriver\ProcessRunner; -use Alchemy\BinaryDriver\BinaryDriverTestCase; -use Alchemy\BinaryDriver\Exception\ExecutionFailureException; -use Alchemy\BinaryDriver\Listeners\ListenerInterface; -use Evenement\EventEmitter; -use Symfony\Component\Process\Exception\RuntimeException as ProcessRuntimeException; - -class ProcessRunnerTest extends BinaryDriverTestCase -{ - public function getProcessRunner($logger) - { - return new ProcessRunner($logger, 'test-runner'); - } - - public function testRunSuccessFullProcess() - { - $logger = $this->createLoggerMock(); - $runner = $this->getProcessRunner($logger); - - $process = $this->createProcessMock(1, true, '--helloworld--', "Kikoo Romain", null, true); - - $logger - ->expects($this->never()) - ->method('error'); - $logger - ->expects($this->exactly(2)) - ->method('info'); - - $this->assertEquals('Kikoo Romain', $runner->run($process, new \SplObjectStorage(), false)); - } - - public function testRunSuccessFullProcessBypassingErrors() - { - $logger = $this->createLoggerMock(); - $runner = $this->getProcessRunner($logger); - - $process = $this->createProcessMock(1, true, '--helloworld--', "Kikoo Romain", null, true); - - $logger - ->expects($this->never()) - ->method('error'); - $logger - ->expects($this->exactly(2)) - ->method('info'); - - $this->assertEquals('Kikoo Romain', $runner->run($process, new \SplObjectStorage(), true)); - } - - public function testRunFailingProcess() - { - $logger = $this->createLoggerMock(); - $runner = $this->getProcessRunner($logger); - - $process = $this->createProcessMock(1, false, '--helloworld--', null, null, true); - - $logger - ->expects($this->once()) - ->method('error'); - $logger - ->expects($this->once()) - ->method('info'); - - try { - $runner->run($process, new \SplObjectStorage(), false); - $this->fail('An exception should have been raised'); - } catch (ExecutionFailureException $e) { - - } - } - - public function testRunFailingProcessWithException() - { - $logger = $this->createLoggerMock(); - $runner = $this->getProcessRunner($logger); - - $exception = new ProcessRuntimeException('Process Failed'); - $process = $this->getMockBuilder('Symfony\Component\Process\Process') - ->disableOriginalConstructor() - ->getMock(); - $process->expects($this->once()) - ->method('run') - ->will($this->throwException($exception)); - - $logger - ->expects($this->once()) - ->method('error'); - $logger - ->expects($this->once()) - ->method('info'); - - try { - $runner->run($process, new \SplObjectStorage(), false); - $this->fail('An exception should have been raised'); - } catch (ExecutionFailureException $e) { - $this->assertEquals($exception, $e->getPrevious()); - } - } - - public function testRunfailingProcessBypassingErrors() - { - $logger = $this->createLoggerMock(); - $runner = $this->getProcessRunner($logger); - - $process = $this->createProcessMock(1, false, '--helloworld--', 'Hello output', null, true); - - $logger - ->expects($this->once()) - ->method('error'); - $logger - ->expects($this->once()) - ->method('info'); - - $this->assertNull($runner->run($process, new \SplObjectStorage(), true)); - } - - public function testRunFailingProcessWithExceptionBypassingErrors() - { - $logger = $this->createLoggerMock(); - $runner = $this->getProcessRunner($logger); - - $exception = new ProcessRuntimeException('Process Failed'); - $process = $this->getMockBuilder('Symfony\Component\Process\Process') - ->disableOriginalConstructor() - ->getMock(); - $process->expects($this->once()) - ->method('run') - ->will($this->throwException($exception)); - - $logger - ->expects($this->once()) - ->method('error'); - $logger - ->expects($this->once()) - ->method('info'); - - $this->assertNull($runner->run($process, new \SplObjectStorage(), true)); - } - - public function testRunSuccessFullProcessWithHandlers() - { - $logger = $this->createLoggerMock(); - $runner = $this->getProcessRunner($logger); - - $capturedCallback = null; - - $process = $this->createProcessMock(1, true, '--helloworld--', "Kikoo Romain", null, true); - $process->expects($this->once()) - ->method('run') - ->with($this->isInstanceOf('Closure')) - ->will($this->returnCallback(function ($callback) use (&$capturedCallback) { - $capturedCallback = $callback; - })); - - $logger - ->expects($this->never()) - ->method('error'); - $logger - ->expects($this->exactly(2)) - ->method('info'); - - $listener = new TestListener(); - $storage = new \SplObjectStorage(); - $storage->attach($listener); - - $capturedType = $capturedData = null; - - $listener->on('received', function ($type, $data) use (&$capturedType, &$capturedData) { - $capturedData = $data; - $capturedType = $type; - }); - - $this->assertEquals('Kikoo Romain', $runner->run($process, $storage, false)); - - $type = 'err'; - $data = 'data'; - - $capturedCallback($type, $data); - - $this->assertEquals($data, $capturedData); - $this->assertEquals($type, $capturedType); - } -} - -class TestListener extends EventEmitter implements ListenerInterface -{ - public function handle($type, $data) - { - return $this->emit('received', array($type, $data)); - } - - public function forwardedEvents() - { - return array(); - } -} diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php new file mode 100644 index 0000000..5d36321 --- /dev/null +++ b/tests/ExampleTest.php @@ -0,0 +1,5 @@ +toBeTrue(); +}); diff --git a/tests/FFMpeg/BaseTestCase.php b/tests/FFMpeg/BaseTestCase.php deleted file mode 100644 index 30622e2..0000000 --- a/tests/FFMpeg/BaseTestCase.php +++ /dev/null @@ -1,13 +0,0 @@ -assertTrue(is_scalar($value), $message); - } -} diff --git a/tests/FFMpeg/Functional/AdvancedMediaTest.php b/tests/FFMpeg/Functional/AdvancedMediaTest.php deleted file mode 100644 index f0616e6..0000000 --- a/tests/FFMpeg/Functional/AdvancedMediaTest.php +++ /dev/null @@ -1,300 +0,0 @@ -getFFMpeg(); - $inputs = [realpath(__DIR__.'/../files/Test.ogv')]; - $format = new Mp3(); - $output = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'extracted_with_map.mp3'; - - // You can run it without -filter_complex, just using -map. - $advancedMedia = $ffmpeg->openAdvanced($inputs); - $advancedMedia - ->map(['0:a'], $format, $output) - ->save(); - - $this->assertFileExists($output); - $this->assertEquals( - 'MP2/3 (MPEG audio layer 2/3)', - $ffmpeg->open($output)->getFormat()->get('format_long_name') - ); - unlink($output); - } - - public function testAudio() - { - $ffmpeg = $this->getFFMpeg(); - $inputs = [realpath(__DIR__.'/../files/Audio.mp3')]; - $format = new Mp3(); - $format->setAudioKiloBitrate(30); - $output = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'audio_test.mp3'; - - $advancedMedia = $ffmpeg->openAdvanced($inputs); - $advancedMedia - ->map(['0:a'], $format, $output) - ->save(); - - $this->assertFileExists($output); - $this->assertEquals( - 'MP2/3 (MPEG audio layer 2/3)', - $ffmpeg->open($output)->getFormat()->get('format_long_name') - ); - unlink($output); - } - - public function testMultipleInputs() - { - $ffmpeg = $this->getFFMpeg(); - $inputs = [ - realpath(__DIR__.'/../files/portrait.MOV'), - realpath(__DIR__.'/../files/portrait.MOV'), - ]; - $format = new X264('aac', 'libx264'); - $output = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'multiple_inputs_test.mp4'; - - $advancedMedia = $ffmpeg->openAdvanced($inputs); - $advancedMedia->filters() - ->custom('[0:v][1:v]', 'hstack', '[v]'); - $advancedMedia - ->map(['0:a', '[v]'], $format, $output) - ->save(); - - $this->assertFileExists($output); - $this->assertEquals( - 'QuickTime / MOV', - $ffmpeg->open($output)->getFormat()->get('format_long_name') - ); - unlink($output); - } - - /** - * @covers \FFMpeg\Media\AdvancedMedia::map - */ - public function testMultipleOutputsTestAbsenceOfInputs() - { - $ffmpeg = $this->getFFMpeg(); - // in this test we use only computed inputs - // and can ignore -i part of the command, pass empty inputs array. - $inputs = []; - $formatX264 = new X264('aac', 'libx264'); - $formatMp3 = new Mp3(); - - $outputMp3 = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'test_multiple_outputs.mp3'; - $outputVideo1 = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'test_multiple_outputs_v1.mp4'; - $outputVideo2 = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'test_multiple_outputs_v2.mp4'; - - $advancedMedia = $ffmpeg->openAdvanced($inputs); - $advancedMedia->filters() - ->sine('[a]', 5) - ->testSrc('[v1]', TestSrcFilter::TESTSRC, '160x120', 5) - ->testSrc('[v2]', TestSrcFilter::TESTSRC, '160x120', 5) - ->custom('[v1]', 'negate', '[v1negate]') - ->custom('[v2]', 'edgedetect', '[v2edgedetect]'); - $advancedMedia - ->map(['[a]'], $formatMp3, $outputMp3) - ->map(['[v1negate]'], $formatX264, $outputVideo1) - ->map(['[v2edgedetect]'], $formatX264, $outputVideo2) - ->save(); - - $this->assertFileExists($outputMp3); - $this->assertEquals( - 'MP2/3 (MPEG audio layer 2/3)', - $ffmpeg->open($outputMp3)->getFormat()->get('format_long_name') - ); - unlink($outputMp3); - - $this->assertFileExists($outputVideo1); - $this->assertEquals( - 'QuickTime / MOV', - $ffmpeg->open($outputVideo1)->getFormat()->get('format_long_name') - ); - unlink($outputVideo1); - - $this->assertFileExists($outputVideo2); - $this->assertEquals( - 'QuickTime / MOV', - $ffmpeg->open($outputVideo2)->getFormat()->get('format_long_name') - ); - unlink($outputVideo2); - } - - /** - * @covers \FFMpeg\Filters\AdvancedMedia\TestSrcFilter - * @covers \FFMpeg\Filters\AdvancedMedia\SineFilter - */ - public function testTestSrcFilterTestSineFilter() - { - $ffmpeg = $this->getFFMpeg(); - $inputs = [realpath(__DIR__.'/../files/Test.ogv')]; - $format = new X264('aac', 'libx264'); - $output = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'testsrc.mp4'; - - $advancedMedia = $ffmpeg->openAdvanced($inputs); - $advancedMedia->filters() - ->sine('[a]', 10) - ->testSrc('[v]', TestSrcFilter::TESTSRC, '160x120', 10); - $advancedMedia - ->map(['[a]', '[v]'], $format, $output) - ->save(); - - $this->assertFileExists($output); - $this->assertEquals( - 'QuickTime / MOV', - $ffmpeg->open($output)->getFormat()->get('format_long_name') - ); - unlink($output); - } - - /** - * XStack filter is supported starting from 4.1 ffmpeg version. - * - * @covers \FFMpeg\Filters\AdvancedMedia\XStackFilter - * @covers \FFMpeg\Filters\AdvancedMedia\SineFilter - */ - public function testXStackFilter() - { - $xStack = new XStackFilter('', 0); - $ffmpeg = $this->getFFMpeg(); - $ffmpegVersion = $ffmpeg->getFFMpegDriver()->getVersion(); - if (version_compare($ffmpegVersion, $xStack->getMinimalFFMpegVersion(), '<')) { - $this->markTestSkipped('XStack filter is supported starting from ffmpeg version ' - .$xStack->getMinimalFFMpegVersion().', your version is ' - .$ffmpegVersion); - - return; - } - - $inputs = [realpath(__DIR__.'/../files/Test.ogv')]; - $format = new X264('aac', 'libx264'); - $output = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'xstack_test.mp4'; - - $advancedMedia = $ffmpeg->openAdvanced($inputs); - $advancedMedia->filters() - ->sine('[a]', 5) - ->testSrc('[v1]', TestSrcFilter::TESTSRC, '160x120', 5) - ->testSrc('[v2]', TestSrcFilter::TESTSRC, '160x120', 5) - ->testSrc('[v3]', TestSrcFilter::TESTSRC, '160x120', 5) - ->testSrc('[v4]', TestSrcFilter::TESTSRC, '160x120', 5) - ->xStack( - '[v1][v2][v3][v4]', - XStackFilter::LAYOUT_2X2, - 4, - '[v]' - ); - $advancedMedia - ->map(['[a]', '[v]'], $format, $output) - ->save(); - - $this->assertFileExists($output); - $this->assertEquals( - 'QuickTime / MOV', - $ffmpeg->open($output)->getFormat()->get('format_long_name') - ); - unlink($output); - } - - public function testOfCompatibilityWithExistedFilters() - { - $ffmpeg = $this->getFFMpeg(); - $inputs = [realpath(__DIR__.'/../files/Test.ogv')]; - $watermark = realpath(__DIR__.'/../files/watermark.png'); - $format = new X264('aac', 'libx264'); - $output = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'test_of_compatibility_with_existed_filters.mp4'; - - $advancedMedia = $ffmpeg->openAdvanced($inputs); - $advancedMedia->filters() - // For unknown reasons WatermarkFilter produce an error on Windows, - // because the path to the watermark becomes corrupted. - // This behaviour related with Alchemy\BinaryDriver\AbstractBinary::command(). - // The path inside filter becomes like - // "D:ServerswwwPHP-FFMpegtestsfileswatermark.png" (without slashes). - // But on Linux systems filter works as expected. - //->watermark('[0:v]', $watermark, '[v]') - ->pad('[0:v]', new Dimension(300, 100), '[v]'); - $advancedMedia - ->map(['0:a', '[v]'], $format, $output) - ->save(); - - $this->assertFileExists($output); - $this->assertEquals( - 'QuickTime / MOV', - $ffmpeg->open($output)->getFormat()->get('format_long_name') - ); - unlink($output); - } - - public function testForceDisableAudio() - { - $ffmpeg = $this->getFFMpeg(); - $format = new X264(); - - $advancedMedia1 = $ffmpeg->openAdvanced([__FILE__]); - $advancedMedia1 - ->map(['test'], $format, 'outputFile.mp4', false); - $this->assertStringContainsString('acodec', $advancedMedia1->getFinalCommand()); - - $advancedMedia2 = $ffmpeg->openAdvanced([__FILE__]); - $advancedMedia2 - ->map(['test'], $format, 'outputFile.mp4', true); - $this->assertStringNotContainsString('acodec', $advancedMedia2->getFinalCommand()); - } - - public function testForceDisableVideo() - { - $ffmpeg = $this->getFFMpeg(); - $format = new X264(); - - $advancedMedia1 = $ffmpeg->openAdvanced([__FILE__]); - $advancedMedia1->map( - ['test'], - $format, - 'outputFile.mp4', - false, - false - ); - $this->assertStringContainsString('vcodec', $advancedMedia1->getFinalCommand()); - - $advancedMedia2 = $ffmpeg->openAdvanced([__FILE__]); - $advancedMedia2->map( - ['test'], - $format, - 'outputFile.mp4', - false, - true - ); - $this->assertStringNotContainsString('vcodec', $advancedMedia2->getFinalCommand()); - } - - public function testGlobalOptions() - { - $configuration = [ - 'ffmpeg.threads' => 3, - 'ffmpeg.filter_threads' => 13, - 'ffmpeg.filter_complex_threads' => 24, - ]; - - $ffmpeg = $this->getFFMpeg($configuration); - $advancedMedia = $ffmpeg->openAdvanced([__FILE__]); - $command = $advancedMedia->getFinalCommand(); - - foreach ($configuration as $optionName => $optionValue) { - $optionName = str_replace('ffmpeg.', '', $optionName); - $this->assertStringContainsString('-'.$optionName.' '.$optionValue, $command); - } - } -} diff --git a/tests/FFMpeg/Functional/AudioConcatenationTest.php b/tests/FFMpeg/Functional/AudioConcatenationTest.php deleted file mode 100644 index cd9f195..0000000 --- a/tests/FFMpeg/Functional/AudioConcatenationTest.php +++ /dev/null @@ -1,28 +0,0 @@ -getFFMpeg(); - - $files = [ - realpath(__DIR__ . '/../files/Jahzzar_-_05_-_Siesta.mp3'), - realpath(__DIR__ . '/../files/02_-_Favorite_Secrets.mp3'), - ]; - - $audio = $ffmpeg->open(reset($files)); - - $this->assertInstanceOf('FFMpeg\Media\Audio', $audio); - - clearstatcache(); - $filename = __DIR__ . '/output/concat-output.mp3'; - - $audio->concat($files)->saveFromSameCodecs($filename, true); - - $this->assertFileExists($filename); - unlink($filename); - } -} diff --git a/tests/FFMpeg/Functional/FFProbeTest.php b/tests/FFMpeg/Functional/FFProbeTest.php deleted file mode 100644 index 213920e..0000000 --- a/tests/FFMpeg/Functional/FFProbeTest.php +++ /dev/null @@ -1,40 +0,0 @@ -assertGreaterThan(0, count($ffprobe->streams(__DIR__.'/../files/Audio.mp3'))); - } - - public function testValidateExistingFile() - { - $ffprobe = FFProbe::create(); - $this->assertTrue($ffprobe->isValid(__DIR__.'/../files/sample.3gp')); - } - - public function testValidateNonExistingFile() - { - $ffprobe = FFProbe::create(); - $this->assertFalse($ffprobe->isValid(__DIR__.'/../files/WrongFile.mp4')); - } - - public function testProbeOnNonExistantFile() - { - $this->expectException('\FFMpeg\Exception\RuntimeException'); - - $ffprobe = FFProbe::create(); - $ffprobe->streams('/path/to/no/file'); - } - - public function testProbeOnRemoteFile() - { - $ffprobe = FFProbe::create(); - $this->assertGreaterThan(0, count($ffprobe->streams('http://vjs.zencdn.net/v/oceans.mp4'))); - } -} diff --git a/tests/FFMpeg/Functional/FunctionalTestCase.php b/tests/FFMpeg/Functional/FunctionalTestCase.php deleted file mode 100644 index 5c8b670..0000000 --- a/tests/FFMpeg/Functional/FunctionalTestCase.php +++ /dev/null @@ -1,19 +0,0 @@ - 300], $configuration)); - } -} diff --git a/tests/FFMpeg/Functional/VideoTranscodeTest.php b/tests/FFMpeg/Functional/VideoTranscodeTest.php deleted file mode 100644 index abfe233..0000000 --- a/tests/FFMpeg/Functional/VideoTranscodeTest.php +++ /dev/null @@ -1,146 +0,0 @@ -getFFMpeg(); - $video = $ffmpeg->open(__DIR__.'/../files/Test.ogv'); - - $this->assertInstanceOf('FFMpeg\Media\Video', $video); - - $lastPercentage = null; - $phpunit = $this; - - $codec = new X264('aac'); - $codec->on('progress', function ($video, $codec, $percentage) use ($phpunit, &$lastPercentage) { - if (null !== $lastPercentage) { - $phpunit->assertGreaterThanOrEqual($lastPercentage, $percentage); - } - $lastPercentage = $percentage; - $phpunit->assertGreaterThanOrEqual(0, $percentage); - $phpunit->assertLessThanOrEqual(100, $percentage); - }); - - $video->save($codec, $filename); - $this->assertFileExists($filename); - unlink($filename); - } - - public function testAacTranscodeX264() - { - $filename = __DIR__.'/output/output-x264_2.mp4'; - if (is_file($filename)) { - unlink(__DIR__.'/output/output-x264_2.mp4'); - } - - $ffmpeg = $this->getFFMpeg(); - $video = $ffmpeg->open(__DIR__.'/../files/sample.3gp'); - - $this->assertInstanceOf('FFMpeg\Media\Video', $video); - - $lastPercentage = null; - $phpunit = $this; - - $codec = new X264('aac'); - $codec->on('progress', function ($video, $codec, $percentage) use ($phpunit, &$lastPercentage) { - if (null !== $lastPercentage) { - $phpunit->assertGreaterThanOrEqual($lastPercentage, $percentage); - } - $lastPercentage = $percentage; - $phpunit->assertGreaterThanOrEqual(0, $percentage); - $phpunit->assertLessThanOrEqual(100, $percentage); - }); - - $video->save($codec, $filename); - $this->assertFileExists($filename); - unlink($filename); - } - - public function testTranscodeInvalidFile() - { - $this->expectException('\FFMpeg\Exception\RuntimeException'); - $ffmpeg = $this->getFFMpeg(); - $ffmpeg->open(__DIR__.'/../files/UnknownFileTest.ogv'); - } - - public function testSaveInvalidForgedVideo() - { - $ffmpeg = $this->getFFMpeg(); - $video = new Video(__DIR__.'/../files/UnknownFileTest.ogv', $ffmpeg->getFFMpegDriver(), $ffmpeg->getFFProbe()); - - $this->expectException('\FFMpeg\Exception\RuntimeException'); - $video->save(new X264('aac'), __DIR__.'/output/output-x264.mp4'); - } - - public function testTranscodePortraitVideo() - { - $info = $this->getNameAndVersion(); - - if ('avconv' === $info['name'] && version_compare($info['version'], '0.9', '<')) { - $this->markTestSkipped('This version of avconv is buggy and does not support this test.'); - } - - $filename = __DIR__.'/output/output-x264.mp4'; - if (is_file($filename)) { - unlink(__DIR__.'/output/output-x264.mp4'); - } - - $ffmpeg = $this->getFFMpeg(); - $video = $ffmpeg->open(__DIR__.'/../files/portrait.MOV'); - - $video->filters() - ->resize(new Dimension(320, 240), ResizeFilter::RESIZEMODE_INSET) - ->rotate(RotateFilter::ROTATE_90); - $video->save(new X264('aac'), $filename); - - $dimension = $ffmpeg->getFFProbe() - ->streams($filename) - ->videos() - ->first() - ->getDimensions(); - - $this->assertLessThan(1, $dimension->getRatio(false)->getValue()); - $this->assertEquals(240, $dimension->getHeight()); - - $this->assertFileExists($filename); - unlink($filename); - } - - private function getNameAndVersion() - { - $binary = $this - ->getFFMpeg() - ->getFFMpegDriver() - ->getProcessBuilderFactory() - ->getBinary(); - - $output = $matches = null; - exec($binary.' -version 2>&1', $output); - - if (!isset($output[0])) { - return ['name' => null, 'version' => null]; - } - - preg_match('/^([a-z]+)\s+version\s+([0-9\.]+)/i', $output[0], $matches); - - if (count($matches) > 0) { - return ['name' => $matches[1], 'version' => $matches[2]]; - } - - return ['name' => null, 'version' => null]; - } -} diff --git a/tests/FFMpeg/Functional/output/.placeholder b/tests/FFMpeg/Functional/output/.placeholder deleted file mode 100644 index e69de29..0000000 diff --git a/tests/FFMpeg/Unit/Coordinate/AspectRatioTest.php b/tests/FFMpeg/Unit/Coordinate/AspectRatioTest.php deleted file mode 100644 index 0712534..0000000 --- a/tests/FFMpeg/Unit/Coordinate/AspectRatioTest.php +++ /dev/null @@ -1,83 +0,0 @@ -assertEquals($expected, $ratio->getValue()); - - $this->assertEquals($calculatedHeight, $ratio->calculateHeight(240, $modulus)); - $this->assertEquals($calculatedWidth, $ratio->calculateWidth(320, $modulus)); - } - - public function provideDimensionsAndExpectedratio() - { - return [ - //AR_5_4 - [720, 576, false, 5 / 4, 400, 192], - [720, 577, false, 5 / 4, 400, 192], - [720, 620, false, 720 / 620, 372, 206], - [720, 576, true, 5 / 4, 400, 192], - //AR_ROTATED_4_5 - [576, 720, false, 4 / 5, 256, 300], - [576, 720, true, 4 / 5, 256, 300], - //AR_4_3 - [320, 240, false, 4 / 3, 426, 180], - [320, 240, true, 4 / 3, 426, 180], - //AR_ROTATED_3_4 - [240, 320, false, 3 / 4, 240, 320], - [240, 320, true, 3 / 4, 240, 320], - //AR_16_9 - [1920, 1080, false, 16 / 9, 568, 136], - [1920, 1080, true, 16 / 9, 568, 136], - [1280, 720, false, 16 / 9, 568, 136], - [1280, 720, true, 16 / 9, 568, 136], - [3840, 2160, false, 16 / 9, 568, 136], - [3840, 2160, true, 16 / 9, 568, 136], - // modulus 4 - [1920, 1080, false, 16 / 9, 568, 136, 4], - [1920, 1080, true, 16 / 9, 568, 136, 4], - [1280, 720, false, 16 / 9, 568, 136, 4], - [1280, 720, true, 16 / 9, 568, 136, 4], - [3840, 2160, false, 16 / 9, 568, 136, 4], - [3840, 2160, true, 16 / 9, 568, 136, 4], - // modulus 16 - [1920, 1080, false, 16 / 9, 576, 128, 16], - [1920, 1080, true, 16 / 9, 576, 128, 16], - [1280, 720, false, 16 / 9, 576, 128, 16], - [1280, 720, true, 16 / 9, 576, 128, 16], - [3840, 2160, false, 16 / 9, 576, 128, 16], - [3840, 2160, true, 16 / 9, 576, 128, 16], - //AR_ROTATED_9_16 - [1080, 1920, false, 9 / 16, 180, 426], - [1080, 1920, true, 9 / 16, 180, 426], - [720, 1280, false, 9 / 16, 180, 426], - [720, 1280, true, 9 / 16, 180, 426], - [2160, 3840, false, 9 / 16, 180, 426], - [2160, 3840, true, 9 / 16, 180, 426], - //AR_3_2 - [360, 240, false, 3 / 2, 480, 160], - [360, 240, true, 3 / 2, 480, 160], - //AR_ROTATED_2_3 - [240, 360, false, 2 / 3, 214, 360], - [240, 360, true, 2 / 3, 214, 360], - //AR_5_3 - //AR_ROTATED_3_5 - //AR_1_1 - //AR_1_DOT_85_1 - //AR_ROTATED_1_DOT_85 - //AR_2_DOT_39_1 - //AR_ROTATED_2_DOT_39 - ]; - } -} diff --git a/tests/FFMpeg/Unit/Coordinate/DimensionTest.php b/tests/FFMpeg/Unit/Coordinate/DimensionTest.php deleted file mode 100644 index 3f7d471..0000000 --- a/tests/FFMpeg/Unit/Coordinate/DimensionTest.php +++ /dev/null @@ -1,38 +0,0 @@ -expectException('\FFMpeg\Exception\InvalidArgumentException'); - new Dimension($width, $height); - } - - public function provideInvalidDimensions() - { - return [ - [320, 0], - [320, -10], - [0, 240], - [-10, 240], - [0, 0], - [0, -10], - [-10, 0], - ]; - } - - public function testGetters() - { - $dimension = new Dimension(320, 240); - $this->assertEquals(320, $dimension->getWidth()); - $this->assertEquals(240, $dimension->getHeight()); - } -} diff --git a/tests/FFMpeg/Unit/Coordinate/FrameRateTest.php b/tests/FFMpeg/Unit/Coordinate/FrameRateTest.php deleted file mode 100644 index 3f95eb2..0000000 --- a/tests/FFMpeg/Unit/Coordinate/FrameRateTest.php +++ /dev/null @@ -1,31 +0,0 @@ -assertEquals(23.997, $fr->getValue()); - } - - /** - * @dataProvider provideInvalidFrameRates - */ - public function testInvalidFrameRate($value) - { - $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); - new FrameRate($value); - } - - public function provideInvalidFrameRates() - { - return [ - [0], [-1.5], [-2], - ]; - } -} diff --git a/tests/FFMpeg/Unit/Coordinate/PointTest.php b/tests/FFMpeg/Unit/Coordinate/PointTest.php deleted file mode 100644 index 0881698..0000000 --- a/tests/FFMpeg/Unit/Coordinate/PointTest.php +++ /dev/null @@ -1,23 +0,0 @@ -assertEquals(4, $point->getX()); - $this->assertEquals(25, $point->getY()); - } - - public function testDynamicPointGetters() - { - $point = new Point('t*100', 't', true); - $this->assertEquals('t*100', $point->getX()); - $this->assertEquals('t', $point->getY()); - } -} diff --git a/tests/FFMpeg/Unit/Coordinate/TimeCodeTest.php b/tests/FFMpeg/Unit/Coordinate/TimeCodeTest.php deleted file mode 100644 index 60b3577..0000000 --- a/tests/FFMpeg/Unit/Coordinate/TimeCodeTest.php +++ /dev/null @@ -1,58 +0,0 @@ -assertEquals((string) $tc, $expected); - } - - public function provideTimeCodes() - { - return [ - ['1:02:04:05:20', '26:04:05.20'], - ['1:02:04:05.20', '26:04:05.20'], - ['02:04:05:20', '02:04:05.20'], - ['02:04:05.20', '02:04:05.20'], - ['00:00:05.20', '00:00:05.20'], - ['00:00:00.00', '00:00:00.00'], - ]; - } - - public function testFromInvalidString() - { - $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); - TimeCode::fromString('lalali lala'); - } - - /** - * @dataProvider provideSeconds - */ - public function testFromSeconds($seconds, $expected) - { - $tc = TimeCode::fromSeconds($seconds); - $this->assertEquals($expected, (string) $tc); - } - - public function provideSeconds() - { - return [ - [0.467, '00:00:00.47'], - [12.467, '00:00:12.47'], - [59.867, '00:00:59.87'], - [72.467, '00:01:12.47'], - [3599.467, '00:59:59.47'], - [3600.467, '01:00:00.47'], - [86422.467, '24:00:22.47'], - ]; - } -} diff --git a/tests/FFMpeg/Unit/Driver/FFMpegDriverTest.php b/tests/FFMpeg/Unit/Driver/FFMpegDriverTest.php deleted file mode 100644 index ee3c8f6..0000000 --- a/tests/FFMpeg/Unit/Driver/FFMpegDriverTest.php +++ /dev/null @@ -1,49 +0,0 @@ -find($name)) { - $found = true; - break; - } - } - - if (!$found) { - $this->markTestSkipped('Neither ffmpeg or avconv found'); - } - } - - public function testCreate() - { - $logger = $this->getLoggerMock(); - $ffmpeg = FFMpegDriver::create($logger, []); - $this->assertInstanceOf('FFMpeg\Driver\FFMpegDriver', $ffmpeg); - $this->assertEquals($logger, $ffmpeg->getProcessRunner()->getLogger()); - } - - public function testCreateWithConfig() - { - $conf = new Configuration(); - $ffmpeg = FFMpegDriver::create($this->getLoggerMock(), $conf); - $this->assertEquals($conf, $ffmpeg->getConfiguration()); - } - - public function testCreateFailureThrowsAnException() - { - $this->expectException('\FFMpeg\Exception\ExecutableNotFoundException'); - FFMpegDriver::create($this->getLoggerMock(), ['ffmpeg.binaries' => '/path/to/nowhere']); - } -} diff --git a/tests/FFMpeg/Unit/Driver/FFProbeDriverTest.php b/tests/FFMpeg/Unit/Driver/FFProbeDriverTest.php deleted file mode 100644 index f476fda..0000000 --- a/tests/FFMpeg/Unit/Driver/FFProbeDriverTest.php +++ /dev/null @@ -1,49 +0,0 @@ -find($name)) { - $found = true; - break; - } - } - - if (!$found) { - $this->markTestSkipped('Neither ffprobe or avprobe found'); - } - } - - public function testCreate() - { - $logger = $this->getLoggerMock(); - $ffprobe = FFProbeDriver::create([], $logger); - $this->assertInstanceOf('FFMpeg\Driver\FFProbeDriver', $ffprobe); - $this->assertEquals($logger, $ffprobe->getProcessRunner()->getLogger()); - } - - public function testCreateWithConfig() - { - $conf = new Configuration(); - $ffprobe = FFProbeDriver::create($conf, $this->getLoggerMock()); - $this->assertEquals($conf, $ffprobe->getConfiguration()); - } - - public function testCreateFailureThrowsAnException() - { - $this->expectException('\FFMpeg\Exception\ExecutableNotFoundException'); - FFProbeDriver::create(['ffprobe.binaries' => '/path/to/nowhere']); - } -} diff --git a/tests/FFMpeg/Unit/FFMpegTest.php b/tests/FFMpeg/Unit/FFMpegTest.php deleted file mode 100644 index fb75484..0000000 --- a/tests/FFMpeg/Unit/FFMpegTest.php +++ /dev/null @@ -1,110 +0,0 @@ -expectException( - '\FFMpeg\Exception\RuntimeException', - 'Unable to probe "/path/to/unknown/file"' - ); - $ffmpeg = new FFMpeg($this->getFFMpegDriverMock(), $this->getFFProbeMock()); - $ffmpeg->open('/path/to/unknown/file'); - } - - public function testOpenAudio() - { - $streams = $this->getStreamCollectionMock(); - $streams->expects($this->once()) - ->method('audios') - ->will($this->returnValue(new StreamCollection([new Stream([])]))); - $streams->expects($this->once()) - ->method('videos') - ->will($this->returnValue([])); - - $ffprobe = $this->getFFProbeMock(); - $ffprobe->expects($this->once()) - ->method('streams') - ->with(__FILE__) - ->will($this->returnValue($streams)); - - $ffmpeg = new FFMpeg($this->getFFMpegDriverMock(), $ffprobe); - $this->assertInstanceOf('FFMpeg\Media\Audio', $ffmpeg->open(__FILE__)); - } - - public function testOpenVideo() - { - $streams = $this->getStreamCollectionMock(); - $streams->expects($this->once()) - ->method('videos') - ->will($this->returnValue(new StreamCollection([new Stream([])]))); - $streams->expects($this->never()) - ->method('audios'); - - $ffprobe = $this->getFFProbeMock(); - $ffprobe->expects($this->once()) - ->method('streams') - ->with(__FILE__) - ->will($this->returnValue($streams)); - - $ffmpeg = new FFMpeg($this->getFFMpegDriverMock(), $ffprobe); - $this->assertInstanceOf('FFMpeg\Media\Video', $ffmpeg->open(__FILE__)); - } - - public function testOpenUnknown() - { - $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); - $ffprobe = $this->getFFProbeMock(); - $ffprobe->expects($this->once()) - ->method('streams') - ->with(__FILE__) - ->will($this->returnValue(new StreamCollection())); - - $ffmpeg = new FFMpeg($this->getFFMpegDriverMock(), $ffprobe); - $ffmpeg->open(__FILE__); - } - - public function testCreateWithoutLoggerOrProbe() - { - $this->assertInstanceOf('FFMpeg\FFMpeg', FFMpeg::create()); - } - - public function testCreateWithLoggerAndProbe() - { - $logger = $this->getLoggerMock(); - $ffprobe = $this->getFFProbeMock(); - - $ffmpeg = FFMpeg::create(['timeout' => 42], $logger, $ffprobe); - $this->assertInstanceOf('FFMpeg\FFMpeg', $ffmpeg); - - $this->assertSame($logger, $ffmpeg->getFFMpegDriver()->getProcessRunner()->getLogger()); - $this->assertSame($ffprobe, $ffmpeg->getFFProbe()); - $this->assertSame(42, $ffmpeg->getFFMpegDriver()->getProcessBuilderFactory()->getTimeout()); - } - - public function testGetSetFFProbe() - { - $ffprobe = $this->getFFProbeMock(); - $ffmpeg = new FFMpeg($this->getFFMpegDriverMock(), $ffprobe); - $this->assertSame($ffprobe, $ffmpeg->getFFProbe()); - $anotherFFProbe = $this->getFFProbeMock(); - $ffmpeg->setFFProbe($anotherFFProbe); - $this->assertSame($anotherFFProbe, $ffmpeg->getFFProbe()); - } - - public function testGetSetDriver() - { - $driver = $this->getFFMpegDriverMock(); - $ffmpeg = new FFMpeg($driver, $this->getFFProbeMock()); - $this->assertSame($driver, $ffmpeg->getFFMpegDriver()); - $anotherDriver = $this->getFFMpegDriverMock(); - $ffmpeg->setFFMpegDriver($anotherDriver); - $this->assertSame($anotherDriver, $ffmpeg->getFFMpegDriver()); - } -} diff --git a/tests/FFMpeg/Unit/FFProbe/DataMapping/AbstractDataTest.php b/tests/FFMpeg/Unit/FFProbe/DataMapping/AbstractDataTest.php deleted file mode 100644 index ff16314..0000000 --- a/tests/FFMpeg/Unit/FFProbe/DataMapping/AbstractDataTest.php +++ /dev/null @@ -1,52 +0,0 @@ - 'value1', 'key2' => 'value2']); - - $this->assertTrue($imp->has('key1')); - $this->assertTrue($imp->has('key2')); - $this->assertFalse($imp->has('value1')); - $this->assertFalse($imp->has('key3')); - } - - public function testGet() - { - $imp = new Implementation(['key1' => 'value1', 'key2' => 'value2']); - - $this->assertEquals('value1', $imp->get('key1')); - $this->assertEquals('value2', $imp->get('key2')); - } - - public function testGetDefault() - { - $imp = new Implementation(['key1' => 'value1', 'key2' => 'value2']); - $this->assertSame('yololo', $imp->get('key3', 'yololo')); - } - - public function testKeys() - { - $imp = new Implementation(['key1' => 'value1', 'key2' => 'value2']); - - $this->assertEquals(['key1', 'key2'], $imp->keys()); - } - - public function testAll() - { - $values = ['key1' => 'value1', 'key2' => 'value2']; - $imp = new Implementation($values); - - $this->assertEquals($values, $imp->all()); - } -} - -class Implementation extends AbstractData -{ -} diff --git a/tests/FFMpeg/Unit/FFProbe/DataMapping/StreamCollectionTest.php b/tests/FFMpeg/Unit/FFProbe/DataMapping/StreamCollectionTest.php deleted file mode 100644 index 1f5787f..0000000 --- a/tests/FFMpeg/Unit/FFProbe/DataMapping/StreamCollectionTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getStreamMock(); - - $collection = new StreamCollection(); - $this->assertEquals([], $collection->all()); - $collection->add($stream); - $this->assertEquals([$stream], $collection->all()); - $collection->add($stream); - $this->assertEquals([$stream, $stream], $collection->all()); - } - - public function testVideos() - { - $audio = $this->getStreamMock(); - $audio->expects($this->once()) - ->method('isVideo') - ->will($this->returnValue(false)); - - $video = $this->getStreamMock(); - $video->expects($this->once()) - ->method('isVideo') - ->will($this->returnValue(true)); - - $collection = new StreamCollection([$audio, $video]); - $videos = $collection->videos(); - - $this->assertInstanceOf('FFMpeg\FFProbe\DataMapping\StreamCollection', $videos); - $this->assertCount(1, $videos); - $this->assertEquals([$video], $videos->all()); - } - - public function testAudios() - { - $audio = $this->getStreamMock(); - $audio->expects($this->once()) - ->method('isAudio') - ->will($this->returnValue(true)); - - $video = $this->getStreamMock(); - $video->expects($this->once()) - ->method('isAudio') - ->will($this->returnValue(false)); - - $collection = new StreamCollection([$audio, $video]); - $audios = $collection->audios(); - - $this->assertInstanceOf('FFMpeg\FFProbe\DataMapping\StreamCollection', $audios); - $this->assertCount(1, $audios); - $this->assertEquals([$audio], $audios->all()); - } - - public function testCount() - { - $stream = $this->getStreamMock(); - - $collection = new StreamCollection([$stream]); - $this->assertCount(1, $collection); - } - - public function testGetIterator() - { - $audio = $this->getStreamMock(); - $video = $this->getStreamMock(); - - $collection = new StreamCollection([$audio, $video]); - $this->assertInstanceOf('\Iterator', $collection->getIterator()); - $this->assertCount(2, $collection->getIterator()); - } - - public function testFirst() - { - $stream1 = $this->getStreamMock(); - $stream2 = $this->getStreamMock(); - - $coll = new StreamCollection([$stream1, $stream2]); - - $this->assertSame($stream1, $coll->first()); - } -} diff --git a/tests/FFMpeg/Unit/FFProbe/DataMapping/StreamTest.php b/tests/FFMpeg/Unit/FFProbe/DataMapping/StreamTest.php deleted file mode 100644 index d1cf766..0000000 --- a/tests/FFMpeg/Unit/FFProbe/DataMapping/StreamTest.php +++ /dev/null @@ -1,136 +0,0 @@ -assertTrue($isAudio === $stream->isAudio()); - } - - public function provideAudioCases() - { - return [ - [true, ['codec_type' => 'audio']], - [false, ['codec_type' => 'video']], - ]; - } - - /** - * @dataProvider provideVideoCases - */ - public function testIsVideo($isVideo, $properties) - { - $stream = new Stream($properties); - $this->assertTrue($isVideo === $stream->isVideo()); - } - - public function provideVideoCases() - { - return [ - [true, ['codec_type' => 'video']], - [false, ['codec_type' => 'audio']], - ]; - } - - public function testGetDimensionsFromAudio() - { - $this->expectException( - '\FFMpeg\Exception\LogicException', - 'Dimensions can only be retrieved from video streams.' - ); - $stream = new Stream(['codec_type' => 'audio']); - $stream->getDimensions(); - } - - public function testGetDimensionsFromVideo() - { - $stream = new Stream(['codec_type' => 'video', 'width' => 960, 'height' => 720]); - $this->assertEquals(new Dimension(960, 720), $stream->getDimensions()); - } - - /** - * @dataProvider provideInvalidPropertiesForDimensionsExtraction - */ - public function testUnableToGetDimensionsFromVideo($properties) - { - $this->expectException( - '\FFMpeg\Exception\RuntimeException', - 'Unable to extract dimensions.' - ); - $stream = new Stream(['codec_type' => 'video', 'width' => 960]); - $stream->getDimensions(); - } - - public function provideInvalidPropertiesForDimensionsExtraction() - { - return [ - ['codec_type' => 'video', 'width' => 960], - ['codec_type' => 'video', 'height' => 960], - ]; - } - - /** - * @dataProvider providePropertiesForDimensionsExtraction - */ - public function testGetDimensionsFromVideoWithDisplayRatio($data) - { - $stream = new Stream([ - 'codec_type' => 'video', - 'width' => $data['width'], - 'height' => $data['height'], - 'sample_aspect_ratio' => $data['sar'], - 'display_aspect_ratio' => $data['dar'], - ]); - $this->assertEquals(new Dimension($data['result_width'], $data['result_height']), $stream->getDimensions()); - } - - /** - * @dataProvider provideInvalidRatios - */ - public function testGetDimensionsFromVideoWithInvalidDisplayRatio($invalidRatio) - { - $stream = new Stream(['codec_type' => 'video', 'width' => 960, 'height' => 720, 'sample_aspect_ratio' => $invalidRatio, 'display_aspect_ratio' => '16:9']); - $this->assertEquals(new Dimension(960, 720), $stream->getDimensions()); - } - - public function provideInvalidRatios() - { - return [['0:1'], ['2:1:3']]; - } - - public function providePropertiesForDimensionsExtraction() - { - return [ - [ - ['width' => '960', 'height' => '720', - 'sar' => '4:3', 'dar' => '16:9', - 'result_width' => '1280', 'result_height' => '720', ], - ], - [ - ['width' => '1920', 'height' => '1080', - 'sar' => '1:1', 'dar' => '16:9', - 'result_width' => '1920', 'result_height' => '1080', ], - ], - [ - ['width' => '640', 'height' => '480', - 'sar' => '75:74', 'dar' => '50:37', - 'result_width' => '649', 'result_height' => '480', ], - ], - [ - ['width' => '720', 'height' => '576', - 'sar' => '52:28', 'dar' => '16:9', - 'result_width' => '1337', 'result_height' => '752', ], - ], - ]; - } -} diff --git a/tests/FFMpeg/Unit/FFProbe/MapperTest.php b/tests/FFMpeg/Unit/FFProbe/MapperTest.php deleted file mode 100644 index 1abf304..0000000 --- a/tests/FFMpeg/Unit/FFProbe/MapperTest.php +++ /dev/null @@ -1,42 +0,0 @@ -assertEquals($expected, $mapper->map($type, $data)); - } - - public function testMapInvalidArgument() - { - $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); - $mapper = new Mapper(); - $mapper->map('cool type', 'data'); - } - - public function provideMappings() - { - $format = json_decode(file_get_contents(__DIR__.'/../../fixtures/ffprobe/show_format.json'), true); - $streams = json_decode(file_get_contents(__DIR__.'/../../fixtures/ffprobe/show_streams.json'), true); - - return [ - [FFProbe::TYPE_FORMAT, $format, new Format($format['format'])], - [FFProbe::TYPE_STREAMS, $streams, new StreamCollection(array_map(function ($streamData) { - return new Stream($streamData); - }, $streams['streams']))], - ]; - } -} diff --git a/tests/FFMpeg/Unit/FFProbe/OptionsTesterTest.php b/tests/FFMpeg/Unit/FFProbe/OptionsTesterTest.php deleted file mode 100644 index dd693f8..0000000 --- a/tests/FFMpeg/Unit/FFProbe/OptionsTesterTest.php +++ /dev/null @@ -1,132 +0,0 @@ -expectException( - '\FFMpeg\Exception\RuntimeException', - 'Your FFProbe version is too old and does not support `-help` option, please upgrade.' - ); - $cache = $this->getCacheMock(); - - $executionFailerExceptionMock = $this->getMockBuilder('Alchemy\BinaryDriver\Exception\ExecutionFailureException') - ->disableOriginalConstructor() - ->getMock(); - - $ffprobe = $this->getFFProbeDriverMock(); - $ffprobe->expects($this->once()) - ->method('command') - ->with(['-help', '-loglevel', 'quiet']) - ->will($this->throwException($executionFailerExceptionMock)); - - $tester = new OptionsTester($ffprobe, $cache); - $tester->has('-print_format'); - } - - /** - * @dataProvider provideOptions - */ - public function testHasOptionWithCacheEmpty($isPresent, $data, $optionName) - { - $cache = $this->getCacheMock(); - - $cache->expects($this->exactly(2)) - ->method('getItem') - ->will($this->returnValue(new CacheItem)); - - $cache->expects($this->exactly(2)) - ->method('hasItem') - ->will($this->returnValue(false)); - - $cache->expects($this->exactly(2)) - ->method('save'); - - $ffprobe = $this->getFFProbeDriverMock(); - $ffprobe->expects($this->once()) - ->method('command') - ->with(['-help', '-loglevel', 'quiet']) - ->will($this->returnValue($data)); - - $tester = new OptionsTester($ffprobe, $cache); - $this->assertTrue($isPresent === $tester->has($optionName)); - } - - public function provideOptions() - { - $data = file_get_contents(__DIR__ . '/../../fixtures/ffprobe/help.raw'); - - return [ - [true, $data, '-print_format'], - [false, $data, '-another_print_format'], - ]; - } - - /** - * @dataProvider provideOptions - */ - public function testHasOptionWithHelpCacheLoaded($isPresent, $data, $optionName) - { - $cache = $this->getCacheMock(); - - $cacheItem = new CacheItem; - $cacheItem->set($data); - - $cache->expects($this->exactly(2)) - ->method('getItem') - ->willReturnOnConsecutiveCalls( - $this->returnValue($cacheItem), - $this->returnValue(new CacheItem) - ); - - $cache->expects($this->exactly(2)) - ->method('hasItem') - ->willReturnOnConsecutiveCalls( - $this->returnValue(false), - $this->returnValue(true) - ); - $cache->expects($this->once()) - ->method('save'); - - $ffprobe = $this->getFFProbeDriverMock(); - $ffprobe->expects($this->never()) - ->method('command'); - - $tester = new OptionsTester($ffprobe, $cache); - $this->assertTrue($isPresent === $tester->has($optionName)); - } - - /** - * @dataProvider provideOptions - */ - public function testHasOptionWithCacheFullyLoaded($isPresent, $data, $optionName) - { - $cache = $this->getCacheMock(); - - $cacheItem = new CacheItem(); - $cacheItem->set($isPresent); - - $cache->expects($this->once()) - ->method('getItem') - ->with(md5('option-' . $optionName)) - ->will($this->returnValue($cacheItem)); - - $cache->expects($this->once()) - ->method('hasItem') - ->with(md5('option-' . $optionName)) - ->will($this->returnValue(true)); - - $ffprobe = $this->getFFProbeDriverMock(); - $ffprobe->expects($this->never()) - ->method('command'); - - $tester = new OptionsTester($ffprobe, $cache); - $this->assertTrue($isPresent === $tester->has($optionName)); - } -} diff --git a/tests/FFMpeg/Unit/FFProbe/OutputParserTest.php b/tests/FFMpeg/Unit/FFProbe/OutputParserTest.php deleted file mode 100644 index 71247fb..0000000 --- a/tests/FFMpeg/Unit/FFProbe/OutputParserTest.php +++ /dev/null @@ -1,40 +0,0 @@ -assertEquals($expectedOutput, $parser->parse($type, $data)); - } - - public function testParseWithInvalidArgument() - { - $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); - $parser = new OutputParser(); - $parser->parse('comme ca', 'data'); - } - - public function provideTypeDataAndOutput() - { - $expectedFormat = json_decode(file_get_contents(__DIR__.'/../../fixtures/ffprobe/show_format.json'), true); - $expectedStreams = json_decode(file_get_contents(__DIR__.'/../../fixtures/ffprobe/show_streams.json'), true); - - $rawFormat = file_get_contents(__DIR__.'/../../fixtures/ffprobe/show_format.raw'); - $rawStreams = file_get_contents(__DIR__.'/../../fixtures/ffprobe/show_streams.raw'); - - return [ - [FFProbe::TYPE_FORMAT, $rawFormat, $expectedFormat], - [FFProbe::TYPE_STREAMS, $rawStreams, $expectedStreams], - ]; - } -} diff --git a/tests/FFMpeg/Unit/FFProbeTest.php b/tests/FFMpeg/Unit/FFProbeTest.php deleted file mode 100644 index 08f1f3f..0000000 --- a/tests/FFMpeg/Unit/FFProbeTest.php +++ /dev/null @@ -1,301 +0,0 @@ -getFFProbeDriverMock(), $this->getCacheMock()); - $parser = $this->getFFProbeParserMock(); - - $ffprobe->setParser($parser); - $this->assertSame($parser, $ffprobe->getParser()); - } - - public function testGetSetFFProbeDriver() - { - $ffprobe = new FFProbe($this->getFFProbeDriverMock(), $this->getCacheMock()); - $driver = $this->getFFProbeDriverMock(); - - $ffprobe->setFFProbeDriver($driver); - $this->assertSame($driver, $ffprobe->getFFProbeDriver()); - } - - public function testGetSetFFProbeMapper() - { - $ffprobe = new FFProbe($this->getFFProbeDriverMock(), $this->getCacheMock()); - $mapper = $this->getFFProbeMapperMock(); - - $ffprobe->setMapper($mapper); - $this->assertSame($mapper, $ffprobe->getMapper()); - } - - public function testGetSetOptionsTester() - { - $ffprobe = new FFProbe($this->getFFProbeDriverMock(), $this->getCacheMock()); - $tester = $this->getFFProbeOptionsTesterMock(); - - $ffprobe->setOptionsTester($tester); - $this->assertSame($tester, $ffprobe->getOptionsTester()); - } - - public function testGetSetCache() - { - $ffprobe = new FFProbe($this->getFFProbeDriverMock(), $this->getCacheMock()); - $cache = $this->getCacheMock(); - - $ffprobe->setCache($cache); - $this->assertSame($cache, $ffprobe->getCache()); - } - - public function provideDataWhitoutCache() - { - $stream = $this->getStreamMock(); - $format = $this->getFormatMock(); - - return [ - [$stream, 'streams', ['-show_streams', '-print_format'], FFProbe::TYPE_STREAMS, [__FILE__, '-show_streams', '-print_format', 'json'], false], - [$format, 'format', ['-show_format', '-print_format'], FFProbe::TYPE_FORMAT, [__FILE__, '-show_format', '-print_format', 'json'], false], - [$stream, 'streams', ['-show_streams'], FFProbe::TYPE_STREAMS, [__FILE__, '-show_streams'], true], - [$format, 'format', ['-show_format'], FFProbe::TYPE_FORMAT, [__FILE__, '-show_format'], true], - ]; - } - - /** - * @dataProvider provideDataWhitoutCache - */ - public function testProbeWithoutCache($output, $method, $commands, $type, $caughtCommands, $isRaw) - { - $pathfile = __FILE__; - $data = ['key' => 'value']; - $rawData = 'raw data'; - - $ffprobe = new FFProbe($this->getFFProbeDriverMock(), $this->getCacheMock()); - - $mapper = $this->getFFProbeMapperMock(); - $mapper->expects($this->once()) - ->method('map') - ->with($type, $data) - ->will($this->returnValue($output)); - - $parser = $this->getFFProbeParserMock(); - - if ($isRaw) { - $parser->expects($this->once()) - ->method('parse') - ->with($type, $rawData) - ->will($this->returnValue($data)); - } else { - $parser->expects($this->never()) - ->method('parse'); - } - - $tester = $this->getFFProbeOptionsTesterMockWithOptions($commands); - - $cache = $this->getCacheMock(); - $cache->expects($this->once()) - ->method('hasItem') - ->will($this->returnValue(false)); - $cache->expects($this->once()) - ->method('getItem') - ->will($this->returnValue(new CacheItem)); - $cache->expects($this->once()) - ->method('save') - ->with($this->anything()); - - $driver = $this->getFFProbeDriverMock(); - $driver->expects($this->once()) - ->method('command') - ->with($caughtCommands) - ->will($this->returnValue($isRaw ? $rawData : json_encode($data))); - - $ffprobe->setOptionsTester($tester) - ->setCache($cache) - ->setMapper($mapper) - ->setFFProbeDriver($driver) - ->setParser($parser); - - $this->assertEquals($output, call_user_func([$ffprobe, $method], $pathfile)); - } - - public function provideDataForInvalidJson() - { - $stream = $this->getStreamMock(); - $format = $this->getFormatMock(); - - return [ - [$stream, 'streams', ['-show_streams', '-print_format'], FFProbe::TYPE_STREAMS, [__FILE__, '-show_streams', '-print_format', 'json']], - [$format, 'format', ['-show_format', '-print_format'], FFProbe::TYPE_FORMAT, [__FILE__, '-show_format', '-print_format', 'json']], - ]; - } - - /** - * @dataProvider provideDataForInvalidJson - */ - public function testProbeWithWrongJson($output, $method, $commands, $type, $caughtCommands) - { - $pathfile = __FILE__; - $data = ['key' => 'value']; - - $ffprobe = new FFProbe($this->getFFProbeDriverMock(), $this->getCacheMock()); - - $mapper = $this->getFFProbeMapperMock(); - $mapper->expects($this->once()) - ->method('map') - ->with($this->isType('string'), 'good data parsed') - ->will($this->returnValue($output)); - - $parser = $this->getFFProbeParserMock(); - $parser->expects($this->once()) - ->method('parse') - ->with($this->isType('string', json_encode($data).'lala')) - ->will($this->returnValue('good data parsed')); - - $tester = $this->getFFProbeOptionsTesterMockWithOptions($commands); - - $cache = $this->getCacheMock(); - $cache->expects($this->exactly(2)) - ->method('hasItem') - ->will($this->returnValue(false)); - $cache->expects($this->once()) - ->method('getItem') - ->will($this->returnValue(new CacheItem)); - - $driver = $this->getFFProbeDriverMock(); - $driver->expects($this->exactly(2)) - ->method('command') - ->will($this->returnValue(json_encode($data).'lala')); - - $ffprobe->setOptionsTester($tester) - ->setCache($cache) - ->setMapper($mapper) - ->setFFProbeDriver($driver) - ->setParser($parser); - - $this->assertEquals($output, call_user_func([$ffprobe, $method], $pathfile)); - } - - public function provideProbingDataWithCache() - { - $stream = $this->getStreamMock(); - $format = $this->getFormatMock(); - - return [ - [$stream, 'streams'], - [$format, 'format'], - ]; - } - - /** - * @dataProvider provideProbingDataWithCache - */ - public function testProbeWithCache($output, $method) - { - $pathfile = __FILE__; - - $ffprobe = new FFProbe($this->getFFProbeDriverMock(), $this->getCacheMock()); - - $mapper = $this->getFFProbeMapperMock(); - $mapper->expects($this->never()) - ->method('map'); - - $tester = $this->getFFProbeOptionsTesterMock(); - - $cacheItem = new CacheItem; - $cacheItem->set($output); - - $cache = $this->getCacheMock(); - $cache->expects($this->once()) - ->method('hasItem') - ->will($this->returnValue(true)); - $cache->expects($this->once()) - ->method('getItem') - ->will($this->returnValue($cacheItem)); - $cache->expects($this->never()) - ->method('save'); - - $driver = $this->getFFProbeDriverMock(); - $driver->expects($this->never()) - ->method('command'); - - $ffprobe->setOptionsTester($tester) - ->setCache($cache) - ->setMapper($mapper) - ->setFFProbeDriver($driver); - - $this->assertEquals($output, call_user_func([$ffprobe, $method], $pathfile)); - } - - public function provideProbeMethod() - { - return [ - ['streams'], - ['format'], - ]; - } - - /** - * @dataProvider provideProbeMethod - */ - public function testProbeWithoutShowStreamsAvailable($method) - { - $this->expectException('\FFMpeg\Exception\RuntimeException'); - $pathfile = __FILE__; - - $ffprobe = new FFProbe($this->getFFProbeDriverMock(), $this->getCacheMock()); - $ffprobe->setOptionsTester($this->getFFProbeOptionsTesterMock()); - call_user_func([$ffprobe, $method], $pathfile); - } - - /** - * @dataProvider provideCreateOptions - */ - public function testCreate($logger, $conf, $cache) - { - $finder = new ExecutableFinder(); - - $found = false; - foreach (['avprobe', 'ffprobe'] as $name) { - if (null !== $finder->find($name)) { - $found = true; - } - } - - if (!$found) { - $this->markTestSkipped('Unable to find avprobe or ffprobe on system'); - } - - $ffprobe = FFProbe::create(); - $this->assertInstanceOf('FFMpeg\FFprobe', $ffprobe); - - $ffprobe = FFProbe::create($conf, $logger, $cache); - $this->assertInstanceOf('FFMpeg\FFprobe', $ffprobe); - - if (null !== $cache) { - $this->assertSame($cache, $ffprobe->getCache()); - } - if (null !== $logger) { - $this->assertSame($logger, $ffprobe->getFFProbeDriver()->getProcessRunner()->getLogger()); - } - if ($conf instanceof ConfigurationInterface) { - $this->assertSame($conf, $ffprobe->getFFProbeDriver()->getConfiguration()); - } - } - - public function provideCreateOptions() - { - return [ - [null, ['key' => 'value'], null], - [$this->getLoggerMock(), ['key' => 'value'], null], - [null, new Configuration(), null], - [null, ['key' => 'value'], $this->getCacheMock()], - ]; - } -} diff --git a/tests/FFMpeg/Unit/Filters/Audio/AudioClipTest.php b/tests/FFMpeg/Unit/Filters/Audio/AudioClipTest.php deleted file mode 100644 index a8b5b05..0000000 --- a/tests/FFMpeg/Unit/Filters/Audio/AudioClipTest.php +++ /dev/null @@ -1,48 +0,0 @@ -getAudioMock(); - $audio->expects($this->once()) - ->method('addFilter') - ->with($this->isInstanceOf('FFMpeg\Filters\Audio\AudioClipFilter')) - ->will($this->returnCallback(function ($filter) use (&$capturedFilter) { - $capturedFilter = $filter; - })); - $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock(); - - $filters = new AudioFilters($audio); - - $filters->clip(TimeCode::fromSeconds(5)); - $this->assertEquals([0 => '-ss', 1 => '00:00:05.00', 2 => '-acodec', 3 => 'copy'], $capturedFilter->apply($audio, $format)); - } - - public function testClippingWithDuration() - { - $capturedFilter = null; - - $audio = $this->getAudioMock(); - $audio->expects($this->once()) - ->method('addFilter') - ->with($this->isInstanceOf('FFMpeg\Filters\Audio\AudioClipFilter')) - ->will($this->returnCallback(function ($filter) use (&$capturedFilter) { - $capturedFilter = $filter; - })); - $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock(); - - $filters = new AudioFilters($audio); - - $filters->clip(TimeCode::fromSeconds(5), TimeCode::fromSeconds(5)); - $this->assertEquals([0 => '-ss', 1 => '00:00:05.00', 2 => '-t', 3 => '00:00:05.00', 4 => '-acodec', 5 => 'copy'], $capturedFilter->apply($audio, $format)); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Audio/AudioFiltersTest.php b/tests/FFMpeg/Unit/Filters/Audio/AudioFiltersTest.php deleted file mode 100644 index 3bbeae9..0000000 --- a/tests/FFMpeg/Unit/Filters/Audio/AudioFiltersTest.php +++ /dev/null @@ -1,26 +0,0 @@ -getAudioMock(); - $audio->expects($this->once()) - ->method('addFilter') - ->with($this->isInstanceOf('FFMpeg\Filters\Audio\AudioResamplableFilter')) - ->will($this->returnCallback(function ($filter) use (&$capturedFilter) { - $capturedFilter = $filter; - })); - - $filters = new AudioFilters($audio); - $filters->resample(8000); - $this->assertEquals(8000, $capturedFilter->getRate()); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Audio/AudioMetadataTest.php b/tests/FFMpeg/Unit/Filters/Audio/AudioMetadataTest.php deleted file mode 100644 index c9872d7..0000000 --- a/tests/FFMpeg/Unit/Filters/Audio/AudioMetadataTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getAudioMock(); - $audio->expects($this->once()) - ->method('addFilter') - ->with($this->isInstanceOf('FFMpeg\Filters\Audio\AddMetadataFilter')) - ->will($this->returnCallback(function ($filter) use (&$capturedFilter) { - $capturedFilter = $filter; - })); - $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock(); - - $filters = new AudioFilters($audio); - $filters->addMetadata(['title' => 'Hello World']); - $this->assertEquals([0 => '-metadata', 1 => 'title=Hello World'], $capturedFilter->apply($audio, $format)); - } - - public function testAddArtwork() - { - $capturedFilter = null; - - $audio = $this->getAudioMock(); - $audio->expects($this->once()) - ->method('addFilter') - ->with($this->isInstanceOf('FFMpeg\Filters\Audio\AddMetadataFilter')) - ->will($this->returnCallback(function ($filter) use (&$capturedFilter) { - $capturedFilter = $filter; - })); - $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock(); - - $filters = new AudioFilters($audio); - $filters->addMetadata(['genre' => 'Some Genre', 'artwork' => '/path/to/file.jpg']); - $this->assertEquals([0 => '-i', 1 => '/path/to/file.jpg', 2 => '-map', 3 => '0', 4 => '-map', 5 => '1', 6 => '-metadata', 7 => 'genre=Some Genre'], $capturedFilter->apply($audio, $format)); - $this->assertEquals([0 => '-i', 1 => '/path/to/file.jpg', 2 => '-map', 3 => '0', 4 => '-map', 5 => '1', 6 => '-metadata', 7 => 'genre=Some Genre'], $capturedFilter->apply($audio, $format)); - } - - public function testRemoveMetadata() - { - $capturedFilter = null; - - $audio = $this->getAudioMock(); - $audio->expects($this->once()) - ->method('addFilter') - ->with($this->isInstanceOf('FFMpeg\Filters\Audio\AddMetadataFilter')) - ->will($this->returnCallback(function ($filter) use (&$capturedFilter) { - $capturedFilter = $filter; - })); - $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock(); - - $filters = new AudioFilters($audio); - $filters->addMetadata(); - $this->assertEquals([0 => '-map_metadata', 1 => '-1', 2 => '-vn'], $capturedFilter->apply($audio, $format)); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Audio/AudioResamplableFilterTest.php b/tests/FFMpeg/Unit/Filters/Audio/AudioResamplableFilterTest.php deleted file mode 100644 index d3b9479..0000000 --- a/tests/FFMpeg/Unit/Filters/Audio/AudioResamplableFilterTest.php +++ /dev/null @@ -1,24 +0,0 @@ -assertEquals(500, $filter->getRate()); - } - - public function testApply() - { - $audio = $this->getAudioMock(); - $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock(); - - $filter = new AudioResamplableFilter(500); - $this->assertEquals(['-ac', 2, '-ar', 500], $filter->apply($audio, $format)); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Audio/CustomFilterTest.php b/tests/FFMpeg/Unit/Filters/Audio/CustomFilterTest.php deleted file mode 100644 index 29e1ffa..0000000 --- a/tests/FFMpeg/Unit/Filters/Audio/CustomFilterTest.php +++ /dev/null @@ -1,18 +0,0 @@ -getAudioMock(); - $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock(); - - $filter = new CustomFilter('whatever i put would end up as a filter'); - $this->assertEquals(['-af', 'whatever i put would end up as a filter'], $filter->apply($audio, $format)); - } -} diff --git a/tests/FFMpeg/Unit/Filters/FiltersCollectionTest.php b/tests/FFMpeg/Unit/Filters/FiltersCollectionTest.php deleted file mode 100644 index 5e1cc61..0000000 --- a/tests/FFMpeg/Unit/Filters/FiltersCollectionTest.php +++ /dev/null @@ -1,62 +0,0 @@ -assertCount(0, $coll); - - $coll->add($this->getMockBuilder('FFMpeg\Filters\FilterInterface')->getMock()); - $this->assertCount(1, $coll); - - $coll->add($this->getMockBuilder('FFMpeg\Filters\FilterInterface')->getMock()); - $this->assertCount(2, $coll); - } - - public function testIterator() - { - $coll = new FiltersCollection(); - $coll->add($this->getMockBuilder('FFMpeg\Filters\FilterInterface')->getMock()); - $coll->add($this->getMockBuilder('FFMpeg\Filters\FilterInterface')->getMock()); - - $this->assertInstanceOf('\ArrayIterator', $coll->getIterator()); - $this->assertCount(2, $coll->getIterator()); - } - - public function testEmptyIterator() - { - $coll = new FiltersCollection(); - $this->assertInstanceOf('\ArrayIterator', $coll->getIterator()); - } - - public function testIteratorSort() - { - $coll = new FiltersCollection(); - $coll->add(new SimpleFilter(['a'])); - $coll->add(new SimpleFilter(['1'], 12)); - $coll->add(new SimpleFilter(['b'])); - $coll->add(new SimpleFilter(['2'], 12)); - $coll->add(new SimpleFilter(['c'])); - $coll->add(new SimpleFilter(['3'], 10)); - $coll->add(new SimpleFilter(['d'])); - $coll->add(new SimpleFilter(['4'], -2)); - $coll->add(new SimpleFilter(['e'])); - - $data = []; - $video = $this->getVideoMock(); - $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock(); - - foreach ($coll as $filter) { - $data = array_merge($data, $filter->apply($video, $format)); - } - - $this->assertEquals(['1', '2', '3', 'a', 'b', 'c', 'd', 'e', '4'], $data); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Frame/CustomFrameFilterTest.php b/tests/FFMpeg/Unit/Filters/Frame/CustomFrameFilterTest.php deleted file mode 100644 index a9bc102..0000000 --- a/tests/FFMpeg/Unit/Filters/Frame/CustomFrameFilterTest.php +++ /dev/null @@ -1,17 +0,0 @@ -getFrameMock(); - - $filter = new CustomFrameFilter('whatever i put would end up as a filter'); - $this->assertEquals(['-vf', 'whatever i put would end up as a filter'], $filter->apply($frame)); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Frame/DisplayRatioFixerFilterTest.php b/tests/FFMpeg/Unit/Filters/Frame/DisplayRatioFixerFilterTest.php deleted file mode 100644 index 0ce38a6..0000000 --- a/tests/FFMpeg/Unit/Filters/Frame/DisplayRatioFixerFilterTest.php +++ /dev/null @@ -1,28 +0,0 @@ - 'video', 'width' => 960, 'height' => 720]); - $streams = new StreamCollection([$stream]); - - $video = $this->getVideoMock(__FILE__); - $video->expects($this->once()) - ->method('getStreams') - ->will($this->returnValue($streams)); - - $frame = new Frame($video, $this->getFFMpegDriverMock(), $this->getFFProbeMock(), new TimeCode(0, 0, 0, 0)); - $filter = new DisplayRatioFixerFilter(); - $this->assertEquals(['-s', '960x720'], $filter->apply($frame)); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Frame/FrameFiltersTest.php b/tests/FFMpeg/Unit/Filters/Frame/FrameFiltersTest.php deleted file mode 100644 index 7658d43..0000000 --- a/tests/FFMpeg/Unit/Filters/Frame/FrameFiltersTest.php +++ /dev/null @@ -1,21 +0,0 @@ -getFrameMock(); - $filters = new FrameFilters($frame); - - $frame->expects($this->once()) - ->method('addFilter') - ->with($this->isInstanceOf('FFMpeg\Filters\Frame\DisplayRatioFixerFilter')); - - $filters->fixDisplayRatio(); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Video/CropFilterTest.php b/tests/FFMpeg/Unit/Filters/Video/CropFilterTest.php deleted file mode 100644 index a217dbb..0000000 --- a/tests/FFMpeg/Unit/Filters/Video/CropFilterTest.php +++ /dev/null @@ -1,38 +0,0 @@ - 320, 'height' => 240, 'codec_type' => 'video']); - $streams = new StreamCollection([$stream]); - - $video = $this->getVideoMock(); - $video->expects($this->once()) - ->method('getStreams') - ->will($this->returnValue($streams)); - - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - - $dimension = new Dimension(200, 150); - $point = new Point(25, 35); - $filter = new CropFilter($point, $dimension); - $expected = [ - '-filter:v', - 'crop='.$dimension->getWidth().':'.$dimension->getHeight().':'.$point->getX().':'.$point->getY(), - ]; - $this->assertEquals($expected, $filter->apply($video, $format)); - - $this->assertEquals(200, $stream->get('width')); - $this->assertEquals(150, $stream->get('height')); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Video/CustomFilterTest.php b/tests/FFMpeg/Unit/Filters/Video/CustomFilterTest.php deleted file mode 100644 index 2f46960..0000000 --- a/tests/FFMpeg/Unit/Filters/Video/CustomFilterTest.php +++ /dev/null @@ -1,18 +0,0 @@ -getVideoMock(); - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - - $filter = new CustomFilter('whatever i put would end up as a filter'); - $this->assertEquals(['-vf', 'whatever i put would end up as a filter'], $filter->apply($video, $format)); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Video/ExtractMultipleFramesFilterTest.php b/tests/FFMpeg/Unit/Filters/Video/ExtractMultipleFramesFilterTest.php deleted file mode 100644 index 13545a0..0000000 --- a/tests/FFMpeg/Unit/Filters/Video/ExtractMultipleFramesFilterTest.php +++ /dev/null @@ -1,73 +0,0 @@ -getVideoMock(); - $pathfile = '/path/to/file'.mt_rand(); - - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - $format->expects($this->any()) - ->method('getModulus') - ->will($this->returnValue($modulus)); - - $streams = new StreamCollection([ - new Stream([ - 'codec_type' => 'video', - 'duration' => $duration, - ]), - ]); - - $video->expects($this->once()) - ->method('getStreams') - ->will($this->returnValue($streams)); - - $filter = new ExtractMultipleFramesFilter($frameRate, $destinationFolder); - $filter->setFrameFileType($frameFileType); - $this->assertEquals($expected, $filter->apply($video, $format)); - } - - public function provideFrameRates() - { - return [ - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_SEC, 'jpg', '/', 100, 2, ['-vf', 'fps=1/1', '/frame-%03d.jpg']], - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_2SEC, 'jpg', '/', 100, 2, ['-vf', 'fps=1/2', '/frame-%02d.jpg']], - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_5SEC, 'jpg', '/', 100, 2, ['-vf', 'fps=1/5', '/frame-%02d.jpg']], - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_10SEC, 'jpg', '/', 100, 2, ['-vf', 'fps=1/10', '/frame-%02d.jpg']], - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_30SEC, 'jpg', '/', 100, 2, ['-vf', 'fps=1/30', '/frame-%02d.jpg']], - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_60SEC, 'jpg', '/', 100, 2, ['-vf', 'fps=1/60', '/frame-%02d.jpg']], - - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_SEC, 'jpeg', '/', 100, 2, ['-vf', 'fps=1/1', '/frame-%03d.jpeg']], - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_2SEC, 'jpeg', '/', 100, 2, ['-vf', 'fps=1/2', '/frame-%02d.jpeg']], - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_5SEC, 'jpeg', '/', 100, 2, ['-vf', 'fps=1/5', '/frame-%02d.jpeg']], - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_10SEC, 'jpeg', '/', 100, 2, ['-vf', 'fps=1/10', '/frame-%02d.jpeg']], - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_30SEC, 'jpeg', '/', 100, 2, ['-vf', 'fps=1/30', '/frame-%02d.jpeg']], - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_60SEC, 'jpeg', '/', 100, 2, ['-vf', 'fps=1/60', '/frame-%02d.jpeg']], - - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_SEC, 'png', '/', 100, 2, ['-vf', 'fps=1/1', '/frame-%03d.png']], - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_2SEC, 'png', '/', 100, 2, ['-vf', 'fps=1/2', '/frame-%02d.png']], - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_5SEC, 'png', '/', 100, 2, ['-vf', 'fps=1/5', '/frame-%02d.png']], - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_10SEC, 'png', '/', 100, 2, ['-vf', 'fps=1/10', '/frame-%02d.png']], - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_30SEC, 'png', '/', 100, 2, ['-vf', 'fps=1/30', '/frame-%02d.png']], - [ExtractMultipleFramesFilter::FRAMERATE_EVERY_60SEC, 'png', '/', 100, 2, ['-vf', 'fps=1/60', '/frame-%02d.png']], - ]; - } - - public function testInvalidFrameFileType() - { - $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); - $filter = new ExtractMultipleFramesFilter('1/1', '/'); - $filter->setFrameFileType('webm'); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Video/FrameRateFilterTest.php b/tests/FFMpeg/Unit/Filters/Video/FrameRateFilterTest.php deleted file mode 100644 index e5700d8..0000000 --- a/tests/FFMpeg/Unit/Filters/Video/FrameRateFilterTest.php +++ /dev/null @@ -1,44 +0,0 @@ -getVideoMock(); - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - $format->expects($this->any()) - ->method('supportBFrames') - ->will($this->returnValue(true)); - - $expected = ['-r', 54, '-b_strategy', '1', '-bf', '3', '-g', 42]; - - $filter = new FrameRateFilter($framerate, $gop); - $this->assertEquals($expected, $filter->apply($video, $format)); - } - - public function testApplyWithAFormatThatDoesNotSupportsBFrames() - { - $framerate = new FrameRate(54); - $gop = 42; - - $video = $this->getVideoMock(); - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - $format->expects($this->any()) - ->method('supportBFrames') - ->will($this->returnValue(false)); - - $expected = ['-r', 54]; - - $filter = new FrameRateFilter($framerate, $gop); - $this->assertEquals($expected, $filter->apply($video, $format)); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Video/PadFilterTest.php b/tests/FFMpeg/Unit/Filters/Video/PadFilterTest.php deleted file mode 100644 index 703b909..0000000 --- a/tests/FFMpeg/Unit/Filters/Video/PadFilterTest.php +++ /dev/null @@ -1,44 +0,0 @@ -getVideoMock(); - $pathfile = '/path/to/file'.mt_rand(); - - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - - $streams = new StreamCollection([ - new Stream([ - 'codec_type' => 'video', - 'width' => $width, - 'height' => $height, - ]), - ]); - - $filter = new PadFilter($dimension); - $this->assertEquals($expected, $filter->apply($video, $format)); - } - - public function provideDimensions() - { - return [ - [new Dimension(1000, 800), 640, 480, ['-vf', 'scale=iw*min(1000/iw\,800/ih):ih*min(1000/iw\,800/ih),pad=1000:800:(1000-iw)/2:(800-ih)/2']], - [new Dimension(300, 600), 640, 480, ['-vf', 'scale=iw*min(300/iw\,600/ih):ih*min(300/iw\,600/ih),pad=300:600:(300-iw)/2:(600-ih)/2']], - [new Dimension(100, 900), 640, 480, ['-vf', 'scale=iw*min(100/iw\,900/ih):ih*min(100/iw\,900/ih),pad=100:900:(100-iw)/2:(900-ih)/2']], - [new Dimension(1200, 200), 640, 480, ['-vf', 'scale=iw*min(1200/iw\,200/ih):ih*min(1200/iw\,200/ih),pad=1200:200:(1200-iw)/2:(200-ih)/2']], - ]; - } -} diff --git a/tests/FFMpeg/Unit/Filters/Video/ResizeFilterTest.php b/tests/FFMpeg/Unit/Filters/Video/ResizeFilterTest.php deleted file mode 100644 index 158e73d..0000000 --- a/tests/FFMpeg/Unit/Filters/Video/ResizeFilterTest.php +++ /dev/null @@ -1,75 +0,0 @@ -getVideoMock(); - $pathfile = '/path/to/file'.mt_rand(); - - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - $format->expects($this->any()) - ->method('getModulus') - ->will($this->returnValue($modulus)); - - $streams = new StreamCollection([ - new Stream([ - 'codec_type' => 'video', - 'width' => $width, - 'height' => $height, - ]), - ]); - - $video->expects($this->once()) - ->method('getStreams') - ->will($this->returnValue($streams)); - - $filter = new ResizeFilter($dimension, $mode, $forceStandards); - $this->assertEquals($expected, $filter->apply($video, $format)); - } - - public function provideDimensions() - { - return [ - [new Dimension(320, 240), ResizeFilter::RESIZEMODE_FIT, 640, 480, 2, ['-vf', '[in]scale=320:240 [out]']], - [new Dimension(320, 240), ResizeFilter::RESIZEMODE_INSET, 640, 480, 2, ['-vf', '[in]scale=320:240 [out]']], - [new Dimension(320, 240), ResizeFilter::RESIZEMODE_SCALE_HEIGHT, 640, 480, 2, ['-vf', '[in]scale=320:240 [out]']], - [new Dimension(320, 240), ResizeFilter::RESIZEMODE_SCALE_WIDTH, 640, 480, 2, ['-vf', '[in]scale=320:240 [out]']], - - [new Dimension(640, 480), ResizeFilter::RESIZEMODE_FIT, 320, 240, 2, ['-vf', '[in]scale=640:480 [out]']], - [new Dimension(640, 480), ResizeFilter::RESIZEMODE_INSET, 320, 240, 2, ['-vf', '[in]scale=640:480 [out]']], - [new Dimension(640, 480), ResizeFilter::RESIZEMODE_SCALE_HEIGHT, 320, 240, 2, ['-vf', '[in]scale=640:480 [out]']], - [new Dimension(640, 480), ResizeFilter::RESIZEMODE_SCALE_WIDTH, 320, 240, 2, ['-vf', '[in]scale=640:480 [out]']], - - [new Dimension(640, 360), ResizeFilter::RESIZEMODE_FIT, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']], - [new Dimension(640, 360), ResizeFilter::RESIZEMODE_INSET, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']], - [new Dimension(640, 360), ResizeFilter::RESIZEMODE_SCALE_HEIGHT, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']], - [new Dimension(640, 360), ResizeFilter::RESIZEMODE_SCALE_WIDTH, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']], - - [new Dimension(640, 360), ResizeFilter::RESIZEMODE_FIT, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']], - [new Dimension(640, 360), ResizeFilter::RESIZEMODE_INSET, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']], - [new Dimension(640, 360), ResizeFilter::RESIZEMODE_SCALE_HEIGHT, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']], - [new Dimension(640, 360), ResizeFilter::RESIZEMODE_SCALE_WIDTH, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']], - - // test non standard dimension - [new Dimension(700, 150), ResizeFilter::RESIZEMODE_INSET, 123, 456, 2, ['-vf', '[in]scale=62:150 [out]'], true], - [new Dimension(700, 150), ResizeFilter::RESIZEMODE_INSET, 123, 456, 2, ['-vf', '[in]scale=40:150 [out]'], false], - - [new Dimension(320, 320), ResizeFilter::RESIZEMODE_FIT, 640, 480, 2, ['-vf', '[in]scale=320:320 [out]']], - [new Dimension(320, 320), ResizeFilter::RESIZEMODE_INSET, 640, 480, 2, ['-vf', '[in]scale=320:240 [out]']], - [new Dimension(320, 320), ResizeFilter::RESIZEMODE_SCALE_HEIGHT, 640, 480, 2, ['-vf', '[in]scale=320:240 [out]']], - [new Dimension(320, 320), ResizeFilter::RESIZEMODE_SCALE_WIDTH, 640, 480, 2, ['-vf', '[in]scale=426:320 [out]']], - ]; - } -} diff --git a/tests/FFMpeg/Unit/Filters/Video/RotateFilterTest.php b/tests/FFMpeg/Unit/Filters/Video/RotateFilterTest.php deleted file mode 100644 index ff94b90..0000000 --- a/tests/FFMpeg/Unit/Filters/Video/RotateFilterTest.php +++ /dev/null @@ -1,72 +0,0 @@ - 320, 'height' => 240, 'codec_type' => 'video']); - $streams = new StreamCollection([$stream]); - - $video = $this->getVideoMock(); - $video->expects($this->once()) - ->method('getStreams') - ->will($this->returnValue($streams)); - - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - - $filter = new RotateFilter($value); - $this->assertEquals(['-vf', $value, '-metadata:s:v:0', 'rotate=0'], $filter->apply($video, $format)); - - $this->assertEquals(240, $stream->get('width')); - $this->assertEquals(320, $stream->get('height')); - } - - public function provide90degresTranspositions() - { - return [ - [RotateFilter::ROTATE_90], - [RotateFilter::ROTATE_270], - ]; - } - - /** - * @dataProvider provideDegresWithoutTranspositions - */ - public function testApplyWithoutSizeTransformation($value) - { - $video = $this->getVideoMock(); - $video->expects($this->never()) - ->method('getStreams'); - - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - - $filter = new RotateFilter($value); - $this->assertEquals(['-vf', $value, '-metadata:s:v:0', 'rotate=0'], $filter->apply($video, $format)); - } - - public function provideDegresWithoutTranspositions() - { - return [ - [RotateFilter::ROTATE_180], - ]; - } - - public function testApplyInvalidAngle() - { - $this->expectException( - '\FFMpeg\Exception\InvalidArgumentException', - 'Invalid angle value.' - ); - new RotateFilter('90'); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Video/SynchronizeFilterTest.php b/tests/FFMpeg/Unit/Filters/Video/SynchronizeFilterTest.php deleted file mode 100644 index 262314c..0000000 --- a/tests/FFMpeg/Unit/Filters/Video/SynchronizeFilterTest.php +++ /dev/null @@ -1,18 +0,0 @@ -getVideoMock(); - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - - $filter = new SynchronizeFilter(); - $this->assertEquals(['-async', '1', '-metadata:s:v:0', 'start_time=0'], $filter->apply($video, $format)); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Video/VideoFiltersTest.php b/tests/FFMpeg/Unit/Filters/Video/VideoFiltersTest.php deleted file mode 100644 index c7114c5..0000000 --- a/tests/FFMpeg/Unit/Filters/Video/VideoFiltersTest.php +++ /dev/null @@ -1,79 +0,0 @@ -getVideoMock(); - $filters = new VideoFilters($video); - $dimension = $this->getDimensionMock(); - - $video->expects($this->once()) - ->method('addFilter') - ->with($this->isInstanceOf('FFMpeg\Filters\Video\ResizeFilter')) - ->will($this->returnCallback(function ($filter) use (&$capturedFilter) { - $capturedFilter = $filter; - })); - - $filters->resize($dimension, $mode, $forceStandards); - - $this->assertSame($mode, $capturedFilter->getMode()); - $this->assertSame($forceStandards, $capturedFilter->areStandardsForced()); - $this->assertSame($dimension, $capturedFilter->getDimension()); - } - - public function provideResizeOptions() - { - return [ - [ResizeFilter::RESIZEMODE_FIT, true], - [ResizeFilter::RESIZEMODE_SCALE_WIDTH, true], - [ResizeFilter::RESIZEMODE_SCALE_HEIGHT, false], - [ResizeFilter::RESIZEMODE_INSET, false], - ]; - } - - public function testResample() - { - $capturedFilter = null; - - $video = $this->getVideoMock(); - $filters = new VideoFilters($video); - $framerate = $this->getFramerateMock(); - $gop = 42; - - $video->expects($this->once()) - ->method('addFilter') - ->with($this->isInstanceOf('FFMpeg\Filters\Video\FrameRateFilter')) - ->will($this->returnCallback(function ($filter) use (&$capturedFilter) { - $capturedFilter = $filter; - })); - - $filters->framerate($framerate, $gop); - - $this->assertSame($framerate, $capturedFilter->getFramerate()); - $this->assertSame($gop, $capturedFilter->getGOP()); - } - - public function testSynchronize() - { - $video = $this->getVideoMock(); - $filters = new VideoFilters($video); - - $video->expects($this->once()) - ->method('addFilter') - ->with($this->isInstanceOf('FFMpeg\Filters\Video\SynchronizeFilter')); - - $filters->synchronize(); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Video/WatermarkFilterTest.php b/tests/FFMpeg/Unit/Filters/Video/WatermarkFilterTest.php deleted file mode 100644 index 8bed38c..0000000 --- a/tests/FFMpeg/Unit/Filters/Video/WatermarkFilterTest.php +++ /dev/null @@ -1,62 +0,0 @@ - 320, 'height' => 240, 'codec_type' => 'video']); - $streams = new StreamCollection([$stream]); - - $video = $this->getVideoMock(); - - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - - $filter = new WatermarkFilter(__DIR__.'/../../../files/watermark.png'); - $this->assertEquals(['-vf', 'movie='.__DIR__.'/../../../files/watermark.png [watermark]; [in][watermark] overlay=0:0 [out]'], $filter->apply($video, $format)); - - // check size of video is unchanged - $this->assertEquals(320, $stream->get('width')); - $this->assertEquals(240, $stream->get('height')); - } - - public function testDifferentCoordinaates() - { - $video = $this->getVideoMock(); - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - - // test position absolute - $filter = new WatermarkFilter(__DIR__.'/../../../files/watermark.png', [ - 'position' => 'absolute', - 'x' => 10, 'y' => 5, - ]); - $this->assertEquals(['-vf', 'movie='.__DIR__.'/../../../files/watermark.png [watermark]; [in][watermark] overlay=10:5 [out]'], $filter->apply($video, $format)); - - // test position relative - $filter = new WatermarkFilter(__DIR__.'/../../../files/watermark.png', [ - 'position' => 'relative', - 'bottom' => 10, 'left' => 5, - ]); - $this->assertEquals(['-vf', 'movie='.__DIR__.'/../../../files/watermark.png [watermark]; [in][watermark] overlay=5:main_h - 10 - overlay_h [out]'], $filter->apply($video, $format)); - - // test position relative - $filter = new WatermarkFilter(__DIR__.'/../../../files/watermark.png', [ - 'position' => 'relative', - 'bottom' => 5, 'right' => 4, - ]); - $this->assertEquals(['-vf', 'movie='.__DIR__.'/../../../files/watermark.png [watermark]; [in][watermark] overlay=main_w - 4 - overlay_w:main_h - 5 - overlay_h [out]'], $filter->apply($video, $format)); - - // test position relative - $filter = new WatermarkFilter(__DIR__.'/../../../files/watermark.png', [ - 'position' => 'relative', - 'left' => 5, 'top' => 11, - ]); - $this->assertEquals(['-vf', 'movie='.__DIR__.'/../../../files/watermark.png [watermark]; [in][watermark] overlay=5:11 [out]'], $filter->apply($video, $format)); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Waveform/WaveformDownmixFilterTest.php b/tests/FFMpeg/Unit/Filters/Waveform/WaveformDownmixFilterTest.php deleted file mode 100644 index 9cadc4d..0000000 --- a/tests/FFMpeg/Unit/Filters/Waveform/WaveformDownmixFilterTest.php +++ /dev/null @@ -1,27 +0,0 @@ - 'audio', 'width' => 960, 'height' => 720]); - $streams = new StreamCollection([$stream]); - - $audio = $this->getAudioMock(__FILE__); - $audio->expects($this->once()) - ->method('getStreams') - ->will($this->returnValue($streams)); - - $waveform = new Waveform($audio, $this->getFFMpegDriverMock(), $this->getFFProbeMock(), 640, 120); - $filter = new WaveformDownmixFilter(true); - $this->assertEquals(['"aformat=channel_layouts=mono"'], $filter->apply($waveform)); - } -} diff --git a/tests/FFMpeg/Unit/Filters/Waveform/WaveformFiltersTest.php b/tests/FFMpeg/Unit/Filters/Waveform/WaveformFiltersTest.php deleted file mode 100644 index e7cf6fb..0000000 --- a/tests/FFMpeg/Unit/Filters/Waveform/WaveformFiltersTest.php +++ /dev/null @@ -1,21 +0,0 @@ -getWaveformMock(); - $filters = new WaveformFilters($Waveform); - - $Waveform->expects($this->once()) - ->method('addFilter') - ->with($this->isInstanceOf('FFMpeg\Filters\Waveform\WaveformDownmixFilter')); - - $filters->setDownmix(); - } -} diff --git a/tests/FFMpeg/Unit/Format/Audio/AacTest.php b/tests/FFMpeg/Unit/Format/Audio/AacTest.php deleted file mode 100644 index 7c316b5..0000000 --- a/tests/FFMpeg/Unit/Format/Audio/AacTest.php +++ /dev/null @@ -1,13 +0,0 @@ -getFormat()->getExtraParams(); - - $this->assertIsArray($extraParams); - - foreach ($extraParams as $param) { - $this->assertScalar($param); - } - } - - public function testGetAudioCodec() - { - $this->assertScalar($this->getFormat()->getAudioCodec()); - $this->assertContains($this->getFormat()->getAudioCodec(), $this->getFormat()->getAvailableAudioCodecs()); - } - - public function testSetAudioCodec() - { - $format = $this->getFormat(); - - foreach ($format->getAvailableAudioCodecs() as $codec) { - $format->setAudioCodec($codec); - $this->assertEquals($codec, $format->getAudioCodec()); - } - } - - public function testSetInvalidAudioCodec() - { - $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); - $this->getFormat()->setAudioCodec('invalid-random-audio-codec'); - } - - public function testGetAvailableAudioCodecs() - { - $this->assertGreaterThan(0, count($this->getFormat()->getAvailableAudioCodecs())); - } - - public function testGetAudioKiloBitrate() - { - $this->assertIsInt($this->getFormat()->getAudioKiloBitrate()); - } - - public function testSetAudioKiloBitrate() - { - $format = $this->getFormat(); - $format->setAudioKiloBitrate(256); - $this->assertEquals(256, $format->getAudioKiloBitrate()); - } - - public function testSetInvalidKiloBitrate() - { - $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); - $this->getFormat()->setAudioKiloBitrate(0); - } - - public function testSetNegativeKiloBitrate() - { - $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); - $this->getFormat()->setAudioKiloBitrate(-10); - } - - public function testGetAudioChannels() - { - $this->assertNull($this->getFormat()->getAudioChannels()); - } - - public function testSetAudioChannels() - { - $format = $this->getFormat(); - $format->setAudioChannels(2); - $this->assertEquals(2, $format->getAudioChannels()); - } - - public function testSetInvalidChannels() - { - $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); - $this->getFormat()->setAudioChannels(0); - } - - public function testSetNegativeChannels() - { - $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); - $this->getFormat()->setAudioChannels(-10); - } - - public function testCreateProgressListener() - { - $media = $this->getMockBuilder('FFMpeg\Media\MediaTypeInterface')->getMock(); - $media->expects($this->any()) - ->method('getPathfile') - ->will($this->returnValue(__FILE__)); - $format = $this->getFormat(); - $ffprobe = $this->getFFProbeMock(); - - foreach ($format->createProgressListener($media, $ffprobe, 1, 3) as $listener) { - $this->assertInstanceOf('FFMpeg\Format\ProgressListener\AudioProgressListener', $listener); - $this->assertSame($ffprobe, $listener->getFFProbe()); - $this->assertSame(__FILE__, $listener->getPathfile()); - $this->assertSame(1, $listener->getCurrentPass()); - $this->assertSame(3, $listener->getTotalPass()); - } - } - - /** - * @return DefaultAudio - */ - abstract public function getFormat(); -} diff --git a/tests/FFMpeg/Unit/Format/Audio/FlacTest.php b/tests/FFMpeg/Unit/Format/Audio/FlacTest.php deleted file mode 100644 index cbcc2f4..0000000 --- a/tests/FFMpeg/Unit/Format/Audio/FlacTest.php +++ /dev/null @@ -1,13 +0,0 @@ -getFFProbeMock(); - $ffprobe->expects($this->once()) - ->method('format') - ->with(__FILE__) - ->will($this->returnValue(new Format([ - 'size' => $size, - 'duration' => $duration, - ]))); - - $listener = new AudioProgressListener($ffprobe, __FILE__, $currentPass, $totalPass); - $phpunit = $this; - $n = 0; - $listener->on('progress', function ($percent, $remaining, $rate) use (&$n, $phpunit, $expectedPercent, $expectedRemaining, $expectedRate, $expectedPercent2, $expectedRemaining2, $expectedRate2) { - if (0 === $n) { - $phpunit->assertEquals($expectedPercent, $percent); - $phpunit->assertEquals($expectedRemaining, $remaining); - $phpunit->assertEquals($expectedRate, $rate); - } elseif (1 === $n) { - $phpunit->assertEquals($expectedPercent2, $percent); - $phpunit->assertEquals($expectedRemaining2, $remaining); - $phpunit->assertLessThan($expectedRate2 + 3, $rate); - $phpunit->assertGreaterThan($expectedRate2 - 3, $rate); - } - ++$n; - }); - // first one does not trigger progress event - $listener->handle('any-type'.mt_rand(), $data); - sleep(1); - $listener->handle('any-type'.mt_rand(), $data); - sleep(1); - $listener->handle('any-type'.mt_rand(), $data2); - $this->assertEquals(2, $n); - } - - public function provideData() - { - return [ - [ - 2894412, - 180.900750, - 'size= 712kB time=00:00:45.50 bitrate= 128.1kbits/s', - 25, - 0, - 0, - 'size= 1274kB time=00:01:29.32 bitrate= 142.8kbits/s', - 49, - 2, - 563, - 1, - 1, - ], - [ - 2894412, - 180.900750, - 'size= 712kB time=00:00:45.50 bitrate= 128.1kbits/s', - 12, - 0, - 0, - 'size= 1274kB time=00:01:29.32 bitrate= 142.8kbits/s', - 24, - 2, - 563, - 1, - 2, - ], - ]; - } -} diff --git a/tests/FFMpeg/Unit/Format/ProgressListener/VideoProgressListenerTest.php b/tests/FFMpeg/Unit/Format/ProgressListener/VideoProgressListenerTest.php deleted file mode 100644 index eed94e6..0000000 --- a/tests/FFMpeg/Unit/Format/ProgressListener/VideoProgressListenerTest.php +++ /dev/null @@ -1,113 +0,0 @@ -getFFProbeMock(); - $ffprobe->expects($this->once()) - ->method('format') - ->with(__FILE__) - ->will($this->returnValue(new Format([ - 'size' => $size, - 'duration' => $duration, - ]))); - - $listener = new VideoProgressListener($ffprobe, __FILE__, $currentPass, $totalPass, $newVideoDuration); - $phpunit = $this; - $n = 0; - $listener->on('progress', function ($percent, $remaining, $rate) use (&$n, $phpunit, $expectedPercent, $expectedRemaining, $expectedRate, $expectedPercent2, $expectedRemaining2, $expectedRate2) { - if (0 === $n) { - $phpunit->assertEquals($expectedPercent, $percent); - $phpunit->assertEquals($expectedRemaining, $remaining); - $phpunit->assertEquals($expectedRate, $rate); - } elseif (1 === $n) { - $phpunit->assertEquals($expectedPercent2, $percent); - $phpunit->assertEquals($expectedRemaining2, $remaining); - $phpunit->assertLessThan($expectedRate2 + 10, $rate); - $phpunit->assertGreaterThan($expectedRate2 - 10, $rate); - } - ++$n; - }); - // first one does not trigger progress event - $listener->handle('any-type'.mt_rand(), $data); - sleep(1); - $listener->handle('any-type'.mt_rand(), $data); - sleep(1); - $listener->handle('any-type'.mt_rand(), $data2); - $this->assertEquals(2, $n); - } - - public function provideData() - { - return [ - [ - 147073958, - 281.147533, - 281.147533, - 'frame= 206 fps=202 q=10.0 size= 571kB time=00:00:07.12 bitrate= 656.8kbits/s dup=9 drop=0', - 2, - 0, - 0, - 'frame= 854 fps=113 q=20.0 size= 4430kB time=00:00:33.04 bitrate=1098.5kbits/s dup=36 drop=0', - 11, - 32, - 3868, - 1, - 1, - ], - [ - 147073958, - 281.147533, - 281.147533, - 'frame= 206 fps=202 q=10.0 size= 571kB time=00:00:07.12 bitrate= 656.8kbits/s dup=9 drop=0', - 1, - 0, - 0, - 'frame= 854 fps=113 q=20.0 size= 4430kB time=00:00:33.04 bitrate=1098.5kbits/s dup=36 drop=0', - 5, - 32, - 3868, - 1, - 2, - ], - [ - 147073958, - 281.147533, - 35, - 'frame= 206 fps=202 q=10.0 size= 571kB time=00:00:07.12 bitrate= 656.8kbits/s dup=9 drop=0', - 60, - 0, - 0, - 'frame= 854 fps=113 q=20.0 size= 4430kB time=00:00:33.04 bitrate=1098.5kbits/s dup=36 drop=0', - 97, - 0, - 3868, - 2, - 2, - ], - ]; - } -} diff --git a/tests/FFMpeg/Unit/Format/Video/InitialParametersTest.php b/tests/FFMpeg/Unit/Format/Video/InitialParametersTest.php deleted file mode 100644 index 9152870..0000000 --- a/tests/FFMpeg/Unit/Format/Video/InitialParametersTest.php +++ /dev/null @@ -1,16 +0,0 @@ -setInitialParameters(['-acodec', 'libopus']); - $this->assertEquals(['-acodec', 'libopus'], $format->getInitialParameters()); - } -} diff --git a/tests/FFMpeg/Unit/Format/Video/OggTest.php b/tests/FFMpeg/Unit/Format/Video/OggTest.php deleted file mode 100644 index 56f03db..0000000 --- a/tests/FFMpeg/Unit/Format/Video/OggTest.php +++ /dev/null @@ -1,13 +0,0 @@ -assertScalar($this->getFormat()->getVideoCodec()); - $this->assertContains($this->getFormat()->getVideoCodec(), $this->getFormat()->getAvailableVideoCodecs()); - } - - public function testSupportBFrames() - { - $this->assertIsBool($this->getFormat()->supportBFrames()); - } - - public function testSetVideoCodec() - { - $format = $this->getFormat(); - - foreach ($format->getAvailableVideoCodecs() as $codec) { - $format->setVideoCodec($codec); - $this->assertEquals($codec, $format->getVideoCodec()); - } - } - - public function testGetKiloBitrate() - { - $this->assertIsInt($this->getFormat()->getKiloBitrate()); - } - - public function testSetKiloBitrate() - { - $format = $this->getFormat(); - $format->setKiloBitrate(2560); - $this->assertEquals(2560, $format->getKiloBitrate()); - } - - public function testSetKiloBitrateBelowZero() - { - $this->expectException('FFMpeg\Exception\InvalidArgumentException'); - $format = $this->getFormat(); - $format->setKiloBitrate(-1); - } - - public function testSetInvalidVideoCodec() - { - $this->expectException('FFMpeg\Exception\InvalidArgumentException'); - $this->getFormat()->setVideoCodec('invalid-random-video-codec'); - } - - public function testGetAvailableVideoCodecs() - { - $this->assertGreaterThan(0, count($this->getFormat()->getAvailableVideoCodecs())); - } - - public function testCreateProgressListener() - { - $media = $this->getMockBuilder('FFMpeg\Media\MediaTypeInterface')->getMock(); - $media->expects($this->any()) - ->method('getPathfile') - ->will($this->returnValue(__FILE__)); - $format = $this->getFormat(); - $ffprobe = $this->getFFProbeMock(); - - foreach ($format->createProgressListener($media, $ffprobe, 1, 3) as $listener) { - $this->assertInstanceOf('FFMpeg\Format\ProgressListener\VideoProgressListener', $listener); - $this->assertSame($ffprobe, $listener->getFFProbe()); - $this->assertSame(__FILE__, $listener->getPathfile()); - $this->assertSame(1, $listener->getCurrentPass()); - $this->assertSame(3, $listener->getTotalPass()); - } - } - - public function testGetPasses() - { - $this->assertIsInt($this->getFormat()->getPasses()); - $this->assertGreaterThan(0, $this->getFormat()->getPasses()); - } - - public function testGetModulus() - { - $this->assertIsInt($this->getFormat()->getModulus()); - $this->assertGreaterThan(0, $this->getFormat()->getModulus()); - $this->assertEquals(0, $this->getFormat()->getModulus() % 2); - } -} diff --git a/tests/FFMpeg/Unit/Format/Video/WMV3Test.php b/tests/FFMpeg/Unit/Format/Video/WMV3Test.php deleted file mode 100644 index edfccd7..0000000 --- a/tests/FFMpeg/Unit/Format/Video/WMV3Test.php +++ /dev/null @@ -1,13 +0,0 @@ -getClassName(); - $ffprobe = $this->getFFProbeMock(); - $format = $this->getFormatMock(); - - $ffprobe->expects($this->once()) - ->method('format') - ->with(__FILE__) - ->will($this->returnValue($format)); - - $media = new $classname(__FILE__, $this->getFFMpegDriverMock(), $ffprobe); - $this->assertSame($format, $media->getFormat()); - } - - public function testGetFormat() - { - $classname = $this->getClassName(); - $ffprobe = $this->getFFProbeMock(); - $streams = $this->getStreamCollectionMock(); - - $ffprobe->expects($this->once()) - ->method('streams') - ->with(__FILE__) - ->will($this->returnValue($streams)); - - $media = new $classname(__FILE__, $this->getFFMpegDriverMock(), $ffprobe); - $this->assertSame($streams, $media->getStreams()); - } - - abstract protected function getClassName(); -} diff --git a/tests/FFMpeg/Unit/Media/AdvancedMediaTest.php b/tests/FFMpeg/Unit/Media/AdvancedMediaTest.php deleted file mode 100644 index 3f882b1..0000000 --- a/tests/FFMpeg/Unit/Media/AdvancedMediaTest.php +++ /dev/null @@ -1,73 +0,0 @@ -getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $advancedMedia = new AdvancedMedia([__FILE__, __FILE__], $driver, $ffprobe); - $this->assertSame([__FILE__, __FILE__], $advancedMedia->getInputs()); - } - - public function testGetInputsCount() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $advancedMedia = new AdvancedMedia([__FILE__, __FILE__], $driver, $ffprobe); - $this->assertEquals(2, $advancedMedia->getInputsCount()); - } - - public function testFiltersReturnFilters() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $advancedMedia = new AdvancedMedia([__FILE__, __FILE__], $driver, $ffprobe); - $this->assertInstanceOf('FFMpeg\Filters\AdvancedMedia\ComplexFilters', $advancedMedia->filters()); - } - - public function testGetTemporaryDirectoryWithoutCustomConfiguration() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $configuration = $this->getConfigurationMock(); - - $driver->expects($this->any()) - ->method('getConfiguration') - ->will($this->returnValue($configuration)); - - $configuration->expects($this->once()) - ->method('get') - ->with($this->equalTo('temporary_directory')) - ->will($this->returnValue(null)); - - $advancedMedia = new AdvancedMedia([__FILE__, __FILE__], $driver, $ffprobe); - $this->assertEquals('', $advancedMedia->getTemporaryDirectory()->path()); - } - - public function testGetTemporaryDirectoryWithCustomConfiguration() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $configuration = $this->getConfigurationMock(); - - $driver->expects($this->any()) - ->method('getConfiguration') - ->will($this->returnValue($configuration)); - - $configuration->expects($this->once()) - ->method('get') - ->with($this->equalTo('temporary_directory')) - ->will($this->returnValue('/var/ffmpeg')); - - $advancedMedia = new AdvancedMedia([__FILE__, __FILE__], $driver, $ffprobe); - $this->assertEquals('/var/ffmpeg', $advancedMedia->getTemporaryDirectory()->path()); - } -} diff --git a/tests/FFMpeg/Unit/Media/AudioProg.php b/tests/FFMpeg/Unit/Media/AudioProg.php deleted file mode 100644 index 54342da..0000000 --- a/tests/FFMpeg/Unit/Media/AudioProg.php +++ /dev/null @@ -1,10 +0,0 @@ -getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $audio = new Audio(__FILE__, $driver, $ffprobe); - $this->assertInstanceOf('FFMpeg\Filters\Audio\AudioFilters', $audio->filters()); - } - - public function testAddFiltersAddsAFilter() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $filters = $this->getMockBuilder('FFMpeg\Filters\FiltersCollection') - ->disableOriginalConstructor() - ->getMock(); - - $audio = new Audio(__FILE__, $driver, $ffprobe); - $audio->setFiltersCollection($filters); - - $filter = $this->getMockBuilder('FFMpeg\Filters\Audio\AudioFilterInterface')->getMock(); - - $filters->expects($this->once()) - ->method('add') - ->with($filter); - - $audio->addFilter($filter); - } - - public function testAddAVideoFilterThrowsException() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $filters = $this->getMockBuilder('FFMpeg\Filters\FiltersCollection') - ->disableOriginalConstructor() - ->getMock(); - - $audio = new Audio(__FILE__, $driver, $ffprobe); - $audio->setFiltersCollection($filters); - - $filter = $this->getMockBuilder('FFMpeg\Filters\Video\VideoFilterInterface')->getMock(); - - $filters->expects($this->never()) - ->method('add'); - - $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); - $audio->addFilter($filter); - } - - public function testSaveWithFailure() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $outputPathfile = '/target/file'; - - $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock(); - $format->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - - $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock(); - - $driver->expects($this->any()) - ->method('getConfiguration') - ->will($this->returnValue($configuration)); - - $failure = new RuntimeException('failed to encode'); - $driver->expects($this->once()) - ->method('command') - ->will($this->throwException($failure)); - - $audio = new Audio(__FILE__, $driver, $ffprobe); - $this->expectException('\FFMpeg\Exception\RuntimeException'); - $audio->save($format, $outputPathfile); - } - - public function testSaveAppliesFilters() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $outputPathfile = '/target/file'; - $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock(); - $format->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - - $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock(); - - $driver->expects($this->any()) - ->method('getConfiguration') - ->will($this->returnValue($configuration)); - - $audio = new Audio(__FILE__, $driver, $ffprobe); - - $filter = $this->getMockBuilder('FFMpeg\Filters\Audio\AudioFilterInterface')->getMock(); - $filter->expects($this->once()) - ->method('apply') - ->with($audio, $format) - ->will($this->returnValue(['extra-filter-command'])); - - $capturedCommands = []; - - $driver->expects($this->once()) - ->method('command') - ->with($this->isType('array'), false, $this->anything()) - ->will($this->returnCallback(function ($commands, $errors, $listeners) use (&$capturedCommands) { - $capturedCommands[] = $commands; - })); - - $audio->addFilter($filter); - $audio->save($format, $outputPathfile); - - foreach ($capturedCommands as $commands) { - $this->assertEquals('-y', $commands[0]); - $this->assertEquals('-i', $commands[1]); - $this->assertEquals(__FILE__, $commands[2]); - $this->assertEquals('extra-filter-command', $commands[3]); - } - } - - /** - * @dataProvider provideSaveData - */ - public function testSaveShouldSave($threads, $expectedCommands, $expectedListeners, $format) - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock(); - - $driver->expects($this->any()) - ->method('getConfiguration') - ->will($this->returnValue($configuration)); - - $configuration->expects($this->once()) - ->method('has') - ->with($this->equalTo('ffmpeg.threads')) - ->will($this->returnValue($threads)); - - if ($threads) { - $configuration->expects($this->once()) - ->method('get') - ->with($this->equalTo('ffmpeg.threads')) - ->will($this->returnValue(24)); - } else { - $configuration->expects($this->never()) - ->method('get'); - } - - $capturedCommand = $capturedListeners = null; - - $driver->expects($this->once()) - ->method('command') - ->with($this->isType('array'), false, $this->anything()) - ->will($this->returnCallback(function ($commands, $errors, $listeners) use (&$capturedCommand, &$capturedListeners) { - $capturedCommand = $commands; - $capturedListeners = $listeners; - })); - - $outputPathfile = '/target/file'; - - $audio = new Audio(__FILE__, $driver, $ffprobe); - $audio->save($format, $outputPathfile); - - $this->assertEquals($expectedCommands, $capturedCommand); - $this->assertEquals($expectedListeners, $capturedListeners); - } - - public function provideSaveData() - { - $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock(); - $format->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - $format->expects($this->any()) - ->method('getAudioKiloBitrate') - ->will($this->returnValue(663)); - $format->expects($this->any()) - ->method('getAudioChannels') - ->will($this->returnValue(5)); - - $audioFormat = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock(); - $audioFormat->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - $audioFormat->expects($this->any()) - ->method('getAudioKiloBitrate') - ->will($this->returnValue(664)); - $audioFormat->expects($this->any()) - ->method('getAudioChannels') - ->will($this->returnValue(5)); - $audioFormat->expects($this->any()) - ->method('getAudioCodec') - ->will($this->returnValue('patati-patata-audio')); - - $formatExtra = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock(); - $formatExtra->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue(['extra', 'param'])); - $formatExtra->expects($this->any()) - ->method('getAudioKiloBitrate') - ->will($this->returnValue(665)); - $formatExtra->expects($this->any()) - ->method('getAudioChannels') - ->will($this->returnValue(5)); - - $listeners = [$this->getMockBuilder('Alchemy\BinaryDriver\Listeners\ListenerInterface')->getMock()]; - - $progressableFormat = $this->getMockBuilder('Tests\FFMpeg\Unit\Media\AudioProg') - ->disableOriginalConstructor()->getMock(); - $progressableFormat->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - $progressableFormat->expects($this->any()) - ->method('createProgressListener') - ->will($this->returnValue($listeners)); - $progressableFormat->expects($this->any()) - ->method('getAudioKiloBitrate') - ->will($this->returnValue(666)); - $progressableFormat->expects($this->any()) - ->method('getAudioChannels') - ->will($this->returnValue(5)); - - return [ - [false, [ - '-y', '-i', __FILE__, - '-b:a', '663k', - '-ac', '5', - '/target/file', - ], null, $format], - [false, [ - '-y', '-i', __FILE__, - '-acodec', 'patati-patata-audio', - '-b:a', '664k', - '-ac', '5', - '/target/file', - ], null, $audioFormat], - [false, [ - '-y', '-i', __FILE__, - 'extra', 'param', - '-b:a', '665k', - '-ac', '5', - '/target/file', - ], null, $formatExtra], - [true, [ - '-y', '-i', __FILE__, - '-threads', 24, - '-b:a', '663k', - '-ac', '5', - '/target/file', - ], null, $format], - [true, [ - '-y', '-i', __FILE__, - 'extra', 'param', - '-threads', 24, - '-b:a', '665k', - '-ac', '5', - '/target/file', - ], null, $formatExtra], - [false, [ - '-y', '-i', __FILE__, - '-b:a', '666k', - '-ac', '5', - '/target/file', - ], $listeners, $progressableFormat], - [true, [ - '-y', '-i', __FILE__, - '-threads', 24, - '-b:a', '666k', - '-ac', '5', - '/target/file', - ], $listeners, $progressableFormat], - ]; - } - - public function testSaveShouldNotStoreCodecFiltersInTheMedia() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock(); - - $driver->expects($this->any()) - ->method('getConfiguration') - ->will($this->returnValue($configuration)); - - $configuration->expects($this->any()) - ->method('has') - ->with($this->equalTo('ffmpeg.threads')) - ->will($this->returnValue(true)); - - $configuration->expects($this->any()) - ->method('get') - ->with($this->equalTo('ffmpeg.threads')) - ->will($this->returnValue(24)); - - $capturedCommands = []; - - $driver->expects($this->exactly(2)) - ->method('command') - ->with($this->isType('array'), false, $this->anything()) - ->will($this->returnCallback(function ($commands, $errors, $listeners) use (&$capturedCommands, &$capturedListeners) { - $capturedCommands[] = $commands; - })); - - $outputPathfile = '/target/file'; - - $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock(); - $format->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue(['param'])); - - $audio = new Audio(__FILE__, $driver, $ffprobe); - $audio->save($format, $outputPathfile); - $audio->save($format, $outputPathfile); - - $expected = [ - '-y', '-i', __FILE__, 'param', '-threads', 24, '/target/file', - ]; - - foreach ($capturedCommands as $capturedCommand) { - $this->assertEquals($expected, $capturedCommand); - } - } - - public function getClassName() - { - return 'FFMpeg\Media\Audio'; - } -} diff --git a/tests/FFMpeg/Unit/Media/ClipTest.php b/tests/FFMpeg/Unit/Media/ClipTest.php deleted file mode 100644 index 8f0212e..0000000 --- a/tests/FFMpeg/Unit/Media/ClipTest.php +++ /dev/null @@ -1,67 +0,0 @@ -getConfigurationMock(); - - $driver = $this->getFFMpegDriverMock(); - $driver->expects($this->any()) - ->method('getConfiguration') - ->will($this->returnValue($configuration)); - - $ffprobe = $this->getFFProbeMock(); - - $start = $this->getTimeCodeMock(); - $start->expects($this->once()) - ->method('__toString') - ->will($this->returnValue($startValue)); - - $duration = null; - if (null !== $durationValue) { - $duration = $this->getTimeCodeMock(); - $duration->expects($this->once()) - ->method('__toString') - ->will($this->returnValue($durationValue)); - } - - $outputPathfile = '/target/file'; - - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - $format->expects($this->any()) - ->method('getPasses') - ->will($this->returnValue(1)); - $format->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - - $clip = new Clip($this->getVideoMock(__FILE__), $driver, $ffprobe, $start, $duration); - $fc = $clip->getFinalCommand($format, $outputPathfile); - - $this->assertCount(1, $fc); - $this->assertStringStartsWith(implode(' ', $commands), $fc[0]); - } - - public function provideBuildOptions() - { - return [ - ['SS01', null, [ - '-y', '-ss', 'SS01', - '-i', __FILE__, ], - ], - ['SS02', 'D02', [ - '-y', '-ss', 'SS02', - '-i', __FILE__, - '-t', 'D02', ], - ], - ]; - } -} diff --git a/tests/FFMpeg/Unit/Media/ConcatTest.php b/tests/FFMpeg/Unit/Media/ConcatTest.php deleted file mode 100644 index 21e8f1e..0000000 --- a/tests/FFMpeg/Unit/Media/ConcatTest.php +++ /dev/null @@ -1,161 +0,0 @@ -getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $concat = new Concat([__FILE__, __FILE__], $driver, $ffprobe); - $this->assertSame([__FILE__, __FILE__], $concat->getSources()); - } - - public function testFiltersReturnFilters() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $concat = new Concat([__FILE__, __FILE__], $driver, $ffprobe); - $this->assertInstanceOf('FFMpeg\Filters\Concat\ConcatFilters', $concat->filters()); - } - - public function testAddFiltersAddsAFilter() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $filters = $this->getMockBuilder('FFMpeg\Filters\FiltersCollection') - ->disableOriginalConstructor() - ->getMock(); - - $filter = $this->getMockBuilder('FFMpeg\Filters\Concat\ConcatFilterInterface')->getMock(); - - $filters->expects($this->once()) - ->method('add') - ->with($filter); - - $concat = new Concat([__FILE__, __FILE__], $driver, $ffprobe); - $concat->setFiltersCollection($filters); - $concat->addFilter($filter); - } - - /** - * @dataProvider provideSaveFromSameCodecsOptions - */ - public function testSaveFromSameCodecs($streamCopy, $commands) - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $pathfile = '/target/destination'; - - array_push($commands, $pathfile); - - $configuration = Mockery::mock('Alchemy\BinaryDriver\ConfigurationInterface'); - - $driver->expects($this->any()) - ->method('getConfiguration') - ->will($this->returnValue($configuration)); - - $configuration->shouldReceive('get') - ->once() - ->with('temporary_directory') - ->andReturnNull(); - - $driver->expects($this->exactly(1)) - ->method('command') - ->with($this->isType('array'), false, $this->anything()) - ->will($this->returnCallback(function ($commands, $errors, $listeners) { - })); - - $concat = new Concat([__FILE__, 'concat-2.mp4'], $driver, $ffprobe); - $concat->saveFromSameCodecs($pathfile, $streamCopy); - - $this->assertEquals('-f', $commands[0]); - $this->assertEquals('concat', $commands[1]); - $this->assertEquals('-safe', $commands[2]); - $this->assertEquals('0', $commands[3]); - $this->assertEquals('-i', $commands[4]); - if (isset($commands[6]) && (0 == strcmp($commands[6], '-c'))) { - $this->assertEquals('-c', $commands[6]); - $this->assertEquals('copy', $commands[7]); - } - } - - public function provideSaveFromSameCodecsOptions() - { - $fs = (new TemporaryDirectory())->create(); - $tmpFile = $fs->path('ffmpeg-concat'); - touch($tmpFile); - - return [ - [ - true, - [ - '-f', 'concat', - '-safe', '0', - '-i', $tmpFile, - '-c', 'copy', - ], - ], - [ - false, - [ - '-f', 'concat', - '-safe', '0', - '-i', $tmpFile, - ], - ], - ]; - } - - /** - * @dataProvider provideSaveFromDifferentCodecsOptions - */ - public function testSaveFromDifferentCodecs($commands) - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $format = $this->getFormatInterfaceMock(); - - $pathfile = '/target/destination'; - - array_push($commands, $pathfile); - - $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock(); - - $driver->expects($this->any()) - ->method('getConfiguration') - ->will($this->returnValue($configuration)); - - $driver->expects($this->once()) - ->method('command') - ->with($commands); - - $concat = new Concat([__FILE__, 'concat-2.mp4'], $driver, $ffprobe); - $this->assertSame($concat, $concat->saveFromDifferentCodecs($format, $pathfile)); - } - - public function provideSaveFromDifferentCodecsOptions() - { - return [ - [ - [ - '-i', __FILE__, - '-i', 'concat-2.mp4', - '-filter_complex', - '[0:v:0] [0:a:0] [1:v:0] [1:a:0] concat=n=2:v=1:a=1 [v] [a]', - '-map', '[v]', - '-map', '[a]', - ], - ], - ]; - } -} diff --git a/tests/FFMpeg/Unit/Media/FrameTest.php b/tests/FFMpeg/Unit/Media/FrameTest.php deleted file mode 100644 index 74515d4..0000000 --- a/tests/FFMpeg/Unit/Media/FrameTest.php +++ /dev/null @@ -1,108 +0,0 @@ -getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $timecode = $this->getTimeCodeMock(); - - $frame = new Frame($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode); - $this->assertSame($timecode, $frame->getTimeCode()); - } - - public function testFiltersReturnFilters() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $timecode = $this->getTimeCodeMock(); - - $frame = new Frame($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode); - $this->assertInstanceOf('FFMpeg\Filters\Frame\FrameFilters', $frame->filters()); - } - - public function testAddFiltersAddsAFilter() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $timecode = $this->getTimeCodeMock(); - - $filters = $this->getMockBuilder('FFMpeg\Filters\FiltersCollection') - ->disableOriginalConstructor() - ->getMock(); - - $filter = $this->getMockBuilder('FFMpeg\Filters\Frame\FrameFilterInterface')->getMock(); - - $filters->expects($this->once()) - ->method('add') - ->with($filter); - - $frame = new Frame($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode); - $frame->setFiltersCollection($filters); - $frame->addFilter($filter); - } - - /** - * @dataProvider provideSaveOptions - */ - public function testSave($accurate, $base64, $commands) - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $timecode = $this->getTimeCodeMock(); - $timecode->expects($this->once()) - ->method('__toString') - ->will($this->returnValue('timecode')); - - $pathfile = '/target/destination'; - - if (!$base64) { - array_push($commands, $pathfile); - } - - $driver->expects($this->once()) - ->method('command') - ->with($commands); - - if (!$base64) { - $frame = new Frame($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode); - $this->assertSame($frame, $frame->save($pathfile, $accurate, $base64)); - } else { - $frame = new Frame($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode); - $frame->save($pathfile, $accurate, $base64); - } - } - - public function provideSaveOptions() - { - return [ - [false, false, [ - '-y', '-ss', 'timecode', - '-i', __FILE__, - '-vframes', '1', - '-f', 'image2', ], - ], - [true, false, [ - '-y', '-i', __FILE__, - '-vframes', '1', '-ss', 'timecode', - '-f', 'image2', ], - ], - [false, true, [ - '-y', '-ss', 'timecode', - '-i', __FILE__, - '-vframes', '1', - '-f', 'image2pipe', '-', ], - ], - [true, true, [ - '-y', '-i', __FILE__, - '-vframes', '1', '-ss', 'timecode', - '-f', 'image2pipe', '-', ], - ], - ]; - } -} diff --git a/tests/FFMpeg/Unit/Media/GifTest.php b/tests/FFMpeg/Unit/Media/GifTest.php deleted file mode 100644 index 1d91d44..0000000 --- a/tests/FFMpeg/Unit/Media/GifTest.php +++ /dev/null @@ -1,116 +0,0 @@ -getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $timecode = $this->getTimeCodeMock(); - $dimension = $this->getDimensionMock(); - - $gif = new Gif($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode, $dimension); - $this->assertSame($timecode, $gif->getTimeCode()); - } - - public function testGetDimension() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $timecode = $this->getTimeCodeMock(); - $dimension = $this->getDimensionMock(); - - $gif = new Gif($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode, $dimension); - $this->assertSame($dimension, $gif->getDimension()); - } - - public function testFiltersReturnFilters() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $timecode = $this->getTimeCodeMock(); - $dimension = $this->getDimensionMock(); - - $gif = new Gif($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode, $dimension); - $this->assertInstanceOf('FFMpeg\Filters\Gif\GifFilters', $gif->filters()); - } - - public function testAddFiltersAddsAFilter() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $timecode = $this->getTimeCodeMock(); - $dimension = $this->getDimensionMock(); - - $filters = $this->getMockBuilder('FFMpeg\Filters\FiltersCollection') - ->disableOriginalConstructor() - ->getMock(); - - $filter = $this->getMockBuilder('FFMpeg\Filters\Gif\GifFilterInterface')->getMock(); - - $filters->expects($this->once()) - ->method('add') - ->with($filter); - - $gif = new Gif($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode, $dimension); - $gif->setFiltersCollection($filters); - $gif->addFilter($filter); - } - - /** - * @dataProvider provideSaveOptions - */ - public function testSave($dimension, $duration, $commands) - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $timecode = $this->getTimeCodeMock(); - - $timecode->expects($this->once()) - ->method('__toString') - ->will($this->returnValue('timecode')); - - $pathfile = '/target/destination'; - - array_push($commands, $pathfile); - - $driver->expects($this->once()) - ->method('command') - ->with($commands); - - $gif = new Gif($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode, $dimension, $duration); - $this->assertSame($gif, $gif->save($pathfile)); - } - - public function provideSaveOptions() - { - return [ - [ - new Dimension(320, 240), 3, - [ - '-ss', 'timecode', - '-t', '3', - '-i', __FILE__, - '-vf', - 'scale=320:-1', '-gifflags', - '+transdiff', '-y', - ], - ], - [ - new Dimension(320, 240), null, - [ - '-ss', 'timecode', - '-i', __FILE__, - '-vf', - 'scale=320:-1', '-gifflags', - '+transdiff', '-y', - ], - ], - ]; - } -} diff --git a/tests/FFMpeg/Unit/Media/Prog.php b/tests/FFMpeg/Unit/Media/Prog.php deleted file mode 100644 index 6cdc345..0000000 --- a/tests/FFMpeg/Unit/Media/Prog.php +++ /dev/null @@ -1,10 +0,0 @@ -getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $video = new Video(__FILE__, $driver, $ffprobe); - $this->assertInstanceOf('FFMpeg\Filters\Video\VideoFilters', $video->filters()); - } - - public function testAddFiltersAddsAFilter() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $filters = $this->getMockBuilder('FFMpeg\Filters\FiltersCollection') - ->disableOriginalConstructor() - ->getMock(); - - $video = new Video(__FILE__, $driver, $ffprobe); - $video->setFiltersCollection($filters); - - $filter = $this->getMockBuilder('FFMpeg\Filters\Video\VideoFilterInterface')->getMock(); - - $filters->expects($this->once()) - ->method('add') - ->with($filter); - - $video->addFilter($filter); - } - - public function testAddAudioFilterAddsAFilter() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $filters = $this->getMockBuilder('FFMpeg\Filters\FiltersCollection') - ->disableOriginalConstructor() - ->getMock(); - - $video = new Video(__FILE__, $driver, $ffprobe); - $video->setFiltersCollection($filters); - - $filter = $this->getMockBuilder('FFMpeg\Filters\Audio\AudioFilterInterface')->getMock(); - - $filters->expects($this->once()) - ->method('add') - ->with($filter); - - $video->addFilter($filter); - } - - public function testFrameShouldReturnAFrame() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $at = $this->getTimeCodeMock(); - - $video = new Video(__FILE__, $driver, $ffprobe); - $frame = $video->frame($at); - - $this->assertInstanceOf('FFMpeg\Media\Frame', $frame); - $this->assertSame($at, $frame->getTimeCode()); - $this->assertSame(__FILE__, $frame->getPathfile()); - } - - public function testSaveWithFailure() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $outputPathfile = '/target/file'; - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - $format->expects($this->any()) - ->method('getPasses') - ->will($this->returnValue(1)); - $format->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - - $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock(); - - $driver->expects($this->any()) - ->method('getConfiguration') - ->will($this->returnValue($configuration)); - - $failure = new RuntimeException('failed to encode'); - $driver->expects($this->once()) - ->method('command') - ->will($this->throwException($failure)); - - $video = new Video(__FILE__, $driver, $ffprobe); - $this->expectException('\FFMpeg\Exception\RuntimeException'); - $video->save($format, $outputPathfile); - } - - public function testSaveAppliesFilters() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - $outputPathfile = '/target/file'; - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - $format->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - $format->expects($this->any()) - ->method('getPasses') - ->will($this->returnValue(2)); - - $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock(); - - $driver->expects($this->any()) - ->method('getConfiguration') - ->will($this->returnValue($configuration)); - - $video = new Video(__FILE__, $driver, $ffprobe); - - $filter = $this->getMockBuilder('FFMpeg\Filters\Video\VideoFilterInterface')->getMock(); - $filter->expects($this->once()) - ->method('apply') - ->with($video, $format) - ->will($this->returnValue(['extra-filter-command'])); - - $capturedCommands = []; - - $driver->expects($this->exactly(2)) - ->method('command') - ->with($this->isType('array'), false, $this->anything()) - ->will($this->returnCallback(function ($commands, $errors, $listeners) use (&$capturedCommands) { - $capturedCommands[] = $commands; - })); - - $video->addFilter($filter); - $video->save($format, $outputPathfile); - - foreach ($capturedCommands as $commands) { - $this->assertEquals('-y', $commands[0]); - $this->assertEquals('-i', $commands[1]); - $this->assertEquals(__FILE__, $commands[2]); - $this->assertEquals('extra-filter-command', $commands[3]); - } - } - - /** - * @dataProvider provideSaveData - */ - public function testSaveShouldSave($threads, $expectedCommands, $expectedListeners, $format) - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $configuration = Mockery::mock('Alchemy\BinaryDriver\ConfigurationInterface'); - - $driver->expects($this->any()) - ->method('getConfiguration') - ->will($this->returnValue($configuration)); - - $configuration->shouldReceive('has') - ->once() - ->with('ffmpeg.threads') - ->andReturn($threads); - - $configuration->shouldReceive('get') - ->once() - ->with('temporary_directory') - ->andReturnNull(); - - if ($threads) { - $configuration->shouldReceive('get') - ->once() - ->with('ffmpeg.threads') - ->andReturn(24); - } - - $capturedCommands = []; - $capturedListeners = null; - - $driver->expects($this->exactly(count($expectedCommands))) - ->method('command') - ->with($this->isType('array'), false, $this->anything()) - ->will($this->returnCallback(function ($commands, $errors, $listeners) use (&$capturedCommands, &$capturedListeners) { - $capturedCommands[] = $commands; - $capturedListeners = $listeners; - })); - - $outputPathfile = '/target/file'; - - $video = new Video(__FILE__, $driver, $ffprobe); - $video->save($format, $outputPathfile); - - foreach ($capturedCommands as $passKey => $pass) { - $prefix = null; - if (count($expectedCommands) > 1) { - // look for pass commands only in multipass cases - foreach ($pass as $command) { - $prefix = null; - if (false !== strpos($command, '/pass-')) { - $prefix = $command; - break; - } - } - - if (null === $prefix) { - $this->fail('Unable to find pass prefix command.'); - } - } - - $found = false || (null === $prefix); - foreach ($pass as $key => $command) { - if ($command === $prefix) { - $found = true; - unset($capturedCommands[$passKey][$key]); - $capturedCommands[$passKey] = array_values($capturedCommands[$passKey]); - break; - } - } - - if (!$found) { - $this->fail('Unable to find pass prefix command back.'); - } - } - - $this->assertEquals($expectedCommands, $capturedCommands); - $this->assertEquals($expectedListeners, $capturedListeners); - } - - public function provideSaveData() - { - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - $format->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - $format->expects($this->any()) - ->method('getKiloBitrate') - ->will($this->returnValue(663)); - $format->expects($this->any()) - ->method('getAudioKiloBitrate') - ->will($this->returnValue(92)); - $format->expects($this->any()) - ->method('getAudioChannels') - ->will($this->returnValue(2)); - $format->expects($this->any()) - ->method('getPasses') - ->will($this->returnValue(2)); - $format->expects($this->any()) - ->method('getAdditionalParameters') - ->will($this->returnValue(['foo', 'bar'])); - - $format2 = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - $format2->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - $format2->expects($this->any()) - ->method('getKiloBitrate') - ->will($this->returnValue(663)); - $format2->expects($this->any()) - ->method('getAudioKiloBitrate') - ->will($this->returnValue(92)); - $format2->expects($this->any()) - ->method('getAudioChannels') - ->will($this->returnValue(2)); - $format2->expects($this->any()) - ->method('getPasses') - ->will($this->returnValue(2)); - $format2->expects($this->any()) - ->method('getAdditionalParameters') - ->will($this->returnValue(['foo', 'bar'])); - - $audioFormat = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock(); - $audioFormat->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - $audioFormat->expects($this->any()) - ->method('getAudioCodec') - ->will($this->returnValue('patati-patata-audio')); - $audioFormat->expects($this->any()) - ->method('getAudioKiloBitrate') - ->will($this->returnValue(92)); - $audioFormat->expects($this->any()) - ->method('getAudioChannels') - ->will($this->returnValue(2)); - $audioFormat->expects($this->any()) - ->method('getPasses') - ->will($this->returnValue(1)); - - $audioVideoFormat = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - $audioVideoFormat->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - $audioVideoFormat->expects($this->any()) - ->method('getVideoCodec') - ->will($this->returnValue('gloubi-boulga-video')); - $audioVideoFormat->expects($this->any()) - ->method('getAudioCodec') - ->will($this->returnValue('patati-patata-audio')); - $audioVideoFormat->expects($this->any()) - ->method('getKiloBitrate') - ->will($this->returnValue(664)); - $audioVideoFormat->expects($this->any()) - ->method('getAudioKiloBitrate') - ->will($this->returnValue(92)); - $audioVideoFormat->expects($this->any()) - ->method('getAudioChannels') - ->will($this->returnValue(2)); - $audioVideoFormat->expects($this->any()) - ->method('getPasses') - ->will($this->returnValue(2)); - $audioVideoFormat->expects($this->any()) - ->method('getAdditionalParameters') - ->will($this->returnValue([])); - - $audioVideoFormatSinglePass = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - $audioVideoFormatSinglePass->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - $audioVideoFormatSinglePass->expects($this->any()) - ->method('getVideoCodec') - ->will($this->returnValue('gloubi-boulga-video')); - $audioVideoFormatSinglePass->expects($this->any()) - ->method('getAudioCodec') - ->will($this->returnValue('patati-patata-audio')); - $audioVideoFormatSinglePass->expects($this->any()) - ->method('getKiloBitrate') - ->will($this->returnValue(664)); - $audioVideoFormatSinglePass->expects($this->any()) - ->method('getAudioKiloBitrate') - ->will($this->returnValue(92)); - $audioVideoFormatSinglePass->expects($this->any()) - ->method('getAudioChannels') - ->will($this->returnValue(2)); - $audioVideoFormatSinglePass->expects($this->any()) - ->method('getPasses') - ->will($this->returnValue(1)); - $audioVideoFormatSinglePass->expects($this->any()) - ->method('getAdditionalParameters') - ->will($this->returnValue([])); - - $formatExtra = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - $formatExtra->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue(['extra', 'param'])); - $formatExtra->expects($this->any()) - ->method('getKiloBitrate') - ->will($this->returnValue(665)); - $formatExtra->expects($this->any()) - ->method('getAudioKiloBitrate') - ->will($this->returnValue(92)); - $formatExtra->expects($this->any()) - ->method('getAudioChannels') - ->will($this->returnValue(2)); - $formatExtra->expects($this->any()) - ->method('getPasses') - ->will($this->returnValue(2)); - $formatExtra->expects($this->any()) - ->method('getAdditionalParameters') - ->will($this->returnValue([])); - - $formatExtra2 = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - $formatExtra2->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue(['extra', 'param'])); - $formatExtra2->expects($this->any()) - ->method('getKiloBitrate') - ->will($this->returnValue(665)); - $formatExtra2->expects($this->any()) - ->method('getAudioKiloBitrate') - ->will($this->returnValue(92)); - $formatExtra2->expects($this->any()) - ->method('getAudioChannels') - ->will($this->returnValue(2)); - $formatExtra2->expects($this->any()) - ->method('getPasses') - ->will($this->returnValue(2)); - $formatExtra2->expects($this->any()) - ->method('getAdditionalParameters') - ->will($this->returnValue([])); - - $listeners = [$this->getMockBuilder('Alchemy\BinaryDriver\Listeners\ListenerInterface')->getMock()]; - - $progressableFormat = $this->getMockBuilder('Tests\FFMpeg\Unit\Media\Prog') - ->disableOriginalConstructor()->getMock(); - $progressableFormat->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - $progressableFormat->expects($this->any()) - ->method('createProgressListener') - ->will($this->returnValue($listeners)); - $progressableFormat->expects($this->any()) - ->method('getKiloBitrate') - ->will($this->returnValue(666)); - $progressableFormat->expects($this->any()) - ->method('getAudioKiloBitrate') - ->will($this->returnValue(92)); - $progressableFormat->expects($this->any()) - ->method('getAudioChannels') - ->will($this->returnValue(2)); - $progressableFormat->expects($this->any()) - ->method('getPasses') - ->will($this->returnValue(2)); - - $progressableFormat2 = $this->getMockBuilder('Tests\FFMpeg\Unit\Media\Prog') - ->disableOriginalConstructor()->getMock(); - $progressableFormat2->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - $progressableFormat2->expects($this->any()) - ->method('createProgressListener') - ->will($this->returnValue($listeners)); - $progressableFormat2->expects($this->any()) - ->method('getKiloBitrate') - ->will($this->returnValue(666)); - $progressableFormat2->expects($this->any()) - ->method('getAudioKiloBitrate') - ->will($this->returnValue(92)); - $progressableFormat2->expects($this->any()) - ->method('getAudioChannels') - ->will($this->returnValue(2)); - $progressableFormat2->expects($this->any()) - ->method('getPasses') - ->will($this->returnValue(2)); - - $progressableAudioFormat = $this->getMockBuilder('Tests\FFMpeg\Unit\Media\AudioProg') - ->disableOriginalConstructor()->getMock(); - $progressableAudioFormat->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - $progressableAudioFormat->expects($this->any()) - ->method('getAudioCodec') - ->will($this->returnValue('patati-patata-audio')); - $progressableAudioFormat->expects($this->any()) - ->method('createProgressListener') - ->will($this->returnValue($listeners)); - $progressableAudioFormat->expects($this->any()) - ->method('getAudioKiloBitrate') - ->will($this->returnValue(92)); - $progressableAudioFormat->expects($this->any()) - ->method('getAudioChannels') - ->will($this->returnValue(2)); - $progressableAudioFormat->expects($this->any()) - ->method('getPasses') - ->will($this->returnValue(1)); - - return [ - [false, [[ - '-y', '-i', __FILE__, '-b:v', '663k', - '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', - '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', 2, 'foo', 'bar', '-pass', 1, '-passlogfile', - '/target/file', - ], [ - '-y', '-i', __FILE__, - '-b:v', '663k', - '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', - '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', 2, 'foo', 'bar', '-pass', 2, '-passlogfile', - '/target/file', - ]], null, $format], - [false, [[ - '-y', '-i', __FILE__, - '-vcodec', 'gloubi-boulga-video', - '-acodec', 'patati-patata-audio', '-b:v', '664k', - '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', - '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '1', '-passlogfile', - '/target/file', - ], [ - '-y', '-i', __FILE__, - '-vcodec', 'gloubi-boulga-video', - '-acodec', 'patati-patata-audio', - '-b:v', '664k', - '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', - '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '2', '-passlogfile', - '/target/file', - ]], null, $audioVideoFormat], - [false, [[ - '-y', '-i', __FILE__, - '-vcodec', 'gloubi-boulga-video', - '-acodec', 'patati-patata-audio', '-b:v', '664k', - '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', - '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', - '/target/file', - ]], null, $audioVideoFormatSinglePass], - [false, [[ - '-y', '-i', __FILE__, - 'extra', 'param', '-b:v', '665k', - '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', - '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '1', '-passlogfile', - '/target/file', - ], [ - '-y', '-i', __FILE__, - 'extra', 'param', '-b:v', '665k', - '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', - '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '2', '-passlogfile', - '/target/file', - ]], null, $formatExtra], - [true, [[ - '-y', '-i', __FILE__, - '-threads', 24, '-b:v', '663k', - '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', - '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', 2, 'foo', 'bar', '-pass', 1, '-passlogfile', - '/target/file', - ], [ - '-y', '-i', __FILE__, - '-threads', 24, - '-b:v', '663k', - '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', - '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', 2, 'foo', 'bar', '-pass', 2, '-passlogfile', - '/target/file', - ]], null, $format2], - [true, [[ - '-y', '-i', __FILE__, - 'extra', 'param', '-threads', 24, '-b:v', '665k', - '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', - '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '1', '-passlogfile', - '/target/file', - ], [ - '-y', '-i', __FILE__, - 'extra', 'param', '-threads', 24, '-b:v', '665k', - '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', - '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '2', '-passlogfile', - '/target/file', - ]], null, $formatExtra2], - [false, [[ - '-y', '-i', __FILE__, '-b:v', '666k', - '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', - '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '1', '-passlogfile', - '/target/file', - ], [ - '-y', '-i', __FILE__, - '-b:v', '666k', - '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', - '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '2', '-passlogfile', - '/target/file', - ]], $listeners, $progressableFormat2], - [true, [[ - '-y', '-i', __FILE__, - '-threads', 24, '-b:v', '666k', - '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', - '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '1', '-passlogfile', - '/target/file', - ], [ - '-y', '-i', __FILE__, - '-threads', 24, - '-b:v', '666k', - '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', - '-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '2', '-passlogfile', - '/target/file', - ]], $listeners, $progressableFormat], - [true, [[ - '-y', '-i', __FILE__, - '-threads', 24, '-acodec', 'patati-patata-audio', - '-b:a', '92k', '-ac', '2', - '/target/file', - ]], null, $audioFormat], - [true, [[ - '-y', '-i', __FILE__, - '-threads', 24, '-acodec', 'patati-patata-audio', - '-b:a', '92k', '-ac', '2', - '/target/file', - ]], $listeners, $progressableAudioFormat], - ]; - } - - public function testSaveShouldNotStoreCodecFiltersInTheMedia() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $configuration = Mockery::mock('Alchemy\BinaryDriver\ConfigurationInterface'); - - $driver->expects($this->any()) - ->method('getConfiguration') - ->will($this->returnValue($configuration)); - - $configuration->shouldReceive('has') - ->with('ffmpeg.threads') - ->andReturn(true); - - $configuration->shouldReceive('get') - ->once() - ->with('ffmpeg.threads') - ->andReturn(24); - - $configuration->shouldReceive('get') - ->once() - ->with('temporary_directory') - ->andReturnNull(); - - $capturedCommands = []; - - $driver->expects($this->exactly(4)) - ->method('command') - ->with($this->isType('array'), false, $this->anything()) - ->will($this->returnCallback(function ($commands, $errors, $listeners) use (&$capturedCommands, &$capturedListeners) { - $capturedCommands[] = $commands; - })); - - $outputPathfile = '/target/file'; - - $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock(); - $format->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue(['param'])); - $format->expects($this->any()) - ->method('getPasses') - ->will($this->returnValue(2)); - - $video = new Video(__FILE__, $driver, $ffprobe); - $video->save($format, $outputPathfile); - $video->save($format, $outputPathfile); - - $expectedPass1 = [ - '-y', '-i', __FILE__, 'param', '-threads', 24, '-b:v', 'k', '-refs', - '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', - '-qcomp', '0.6', '-qdiff', '4', '-trellis', '1', - '-pass', '1', '-passlogfile', '/target/file', - ]; - $expectedPass2 = [ - '-y', '-i', __FILE__, 'param', '-threads', 24, '-b:v', 'k', '-refs', - '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', - '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', - '-qcomp', '0.6', '-qdiff', '4', '-trellis', '1', - '-pass', '2', '-passlogfile', '/target/file', - ]; - - $n = 1; - foreach ($capturedCommands as $capturedCommand) { - $prefix = null; - foreach ($capturedCommand as $command) { - if (false !== strpos($command, '/pass-')) { - $prefix = $command; - break; - } - } - - if (null === $prefix) { - $this->fail('Unable to find pass prefix command.'); - } - - $found = false; - foreach ($capturedCommand as $key => $command) { - if ($command === $prefix) { - $found = true; - unset($capturedCommand[$key]); - $capturedCommand = array_values($capturedCommand); - break; - } - } - - if (!$found) { - $this->fail('Unable to find pass prefix command back.'); - } - - if (0 === $n % 2) { - $this->assertEquals($expectedPass2, $capturedCommand); - } else { - $this->assertEquals($expectedPass1, $capturedCommand); - } - ++$n; - } - } - - public function testCaseWhereKiloBitRateIsEqualToZero() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $pathfile = '/target/destination'; - $outputPathfile = '/target/file'; - - $format = new X264(); - $format->setKiloBitrate(0); - - $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock(); - - $driver->expects($this->any()) - ->method('getConfiguration') - ->will($this->returnValue($configuration)); - - $self = $this; - - $driver->expects($this->exactly(1)) - ->method('command') - ->with($this->isType('array'), false, $this->anything()) - ->will($this->returnCallback(function ($commands, $errors, $listeners) use ($self) { - $self->assertTrue(!in_array('-b:v', $commands)); - })); - - $video = new Video(__FILE__, $driver, $ffprobe); - $video->save($format, $outputPathfile); - } - - public function getClassName() - { - return 'FFMpeg\Media\Video'; - } -} diff --git a/tests/FFMpeg/Unit/Media/WaveformTest.php b/tests/FFMpeg/Unit/Media/WaveformTest.php deleted file mode 100644 index a358cf4..0000000 --- a/tests/FFMpeg/Unit/Media/WaveformTest.php +++ /dev/null @@ -1,70 +0,0 @@ -getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $waveform = new Waveform($this->getAudioMock(__FILE__), $driver, $ffprobe, 640, 120); - $this->assertInstanceOf('FFMpeg\Filters\Waveform\WaveformFilters', $waveform->filters()); - } - - public function testAddFiltersAddsAFilter() - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $filters = $this->getMockBuilder('FFMpeg\Filters\FiltersCollection') - ->disableOriginalConstructor() - ->getMock(); - - $filter = $this->getMockBuilder('FFMpeg\Filters\Waveform\WaveformFilterInterface')->getMock(); - - $filters->expects($this->once()) - ->method('add') - ->with($filter); - - $waveform = new Waveform($this->getAudioMock(__FILE__), $driver, $ffprobe, 640, 120); - $waveform->setFiltersCollection($filters); - $waveform->addFilter($filter); - } - - /** - * @dataProvider provideSaveOptions - */ - public function testSave($commands) - { - $driver = $this->getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $pathfile = '/tests/files/Audio.mp3'; - - array_push($commands, $pathfile); - - $driver->expects($this->once()) - ->method('command') - ->with($commands); - - $waveform = new Waveform($this->getAudioMock(__FILE__), $driver, $ffprobe, 640, 120, array('#FFFFFF')); - $this->assertSame($waveform, $waveform->save($pathfile)); - } - - public function provideSaveOptions() - { - return [ - [ - [ - '-y', '-i', null, '-filter_complex', - 'showwavespic=colors=#FFFFFF:s=640x120', - '-frames:v', '1', - ], - ], - ]; - } -} diff --git a/tests/FFMpeg/Unit/TestCase.php b/tests/FFMpeg/Unit/TestCase.php deleted file mode 100644 index 47cd2c8..0000000 --- a/tests/FFMpeg/Unit/TestCase.php +++ /dev/null @@ -1,168 +0,0 @@ -getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - } - - public function getCacheMock() - { - return $this->getMockBuilder('Psr\Cache\CacheItemPoolInterface')->getMock(); - } - - public function getTimeCodeMock() - { - return $this->getMockBuilder('FFMpeg\Coordinate\TimeCode') - ->disableOriginalConstructor() - ->getMock(); - } - - public function getDimensionMock() - { - return $this->getMockBuilder('FFMpeg\Coordinate\Dimension') - ->disableOriginalConstructor() - ->getMock(); - } - - public function getFramerateMock() - { - return $this->getMockBuilder('FFMpeg\Coordinate\Framerate') - ->disableOriginalConstructor() - ->getMock(); - } - - public function getFrameMock() - { - return $this->getMockBuilder('FFMpeg\Media\Frame') - ->disableOriginalConstructor() - ->getMock(); - } - - public function getWaveformMock() - { - return $this->getMockBuilder('FFMpeg\Media\Waveform') - ->disableOriginalConstructor() - ->getMock(); - } - - public function getFFMpegDriverMock() - { - return $this->getMockBuilder('FFMpeg\Driver\FFMpegDriver') - ->disableOriginalConstructor() - ->getMock(); - } - - public function getFFProbeDriverMock() - { - return $this->getMockBuilder('FFMpeg\Driver\FFProbeDriver') - ->disableOriginalConstructor() - ->getMock(); - } - - public function getFFProbeMock() - { - return $this->getMockBuilder('FFMpeg\FFProbe') - ->disableOriginalConstructor() - ->getMock(); - } - - public function getStreamMock() - { - return $this->getMockBuilder('FFMpeg\FFProbe\DataMapping\Stream') - ->disableOriginalConstructor() - ->getMock(); - } - - public function getFFProbeParserMock() - { - return $this->getMockBuilder('FFMpeg\FFProbe\OutputParserInterface')->getMock(); - } - - public function getFFProbeOptionsTesterMock() - { - return $this->getMockBuilder('FFMpeg\FFProbe\OptionsTesterInterface')->getMock(); - } - - public function getFFProbeMapperMock() - { - return $this->getMockBuilder('FFMpeg\FFProbe\MapperInterface')->getMock(); - } - - public function getFFProbeOptionsTesterMockWithOptions(array $options) - { - $tester = $this->getFFProbeOptionsTesterMock(); - - $tester->expects($this->any()) - ->method('has') - ->will($this->returnCallback(function ($option) use ($options) { - return in_array($option, $options); - })); - - return $tester; - } - - public function getConfigurationMock() - { - return $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock(); - } - - public function getFormatMock() - { - return $this->getMockBuilder('FFMpeg\FFProbe\DataMapping\Format') - ->disableOriginalConstructor() - ->getMock(); - } - - public function getStreamCollectionMock() - { - return $this->getMockBuilder('FFMpeg\FFProbe\DataMapping\StreamCollection') - ->disableOriginalConstructor() - ->getMock(); - } - - protected function getAudioMock() - { - return $this->getMockBuilder('FFMpeg\Media\Audio') - ->disableOriginalConstructor() - ->getMock(); - } - - protected function getVideoMock($filename = null) - { - $video = $this->getMockBuilder('FFMpeg\Media\Video') - ->disableOriginalConstructor() - ->getMock(); - - $video->expects($this->any()) - ->method('getPathfile') - ->will($this->returnValue($filename)); - - return $video; - } - - public function getConcatMock() - { - return $this->getMockBuilder('FFMpeg\Media\Concat') - ->disableOriginalConstructor() - ->getMock(); - } - - public function getFormatInterfaceMock() - { - $FormatInterface = $this->getMockBuilder('FFMpeg\Format\FormatInterface') - ->disableOriginalConstructor() - ->getMock(); - - $FormatInterface->expects($this->any()) - ->method('getExtraParams') - ->will($this->returnValue([])); - - return $FormatInterface; - } -} diff --git a/tests/FFMpeg/files/02_-_Favorite_Secrets.mp3 b/tests/FFMpeg/files/02_-_Favorite_Secrets.mp3 deleted file mode 100644 index 3f6ef4e..0000000 Binary files a/tests/FFMpeg/files/02_-_Favorite_Secrets.mp3 and /dev/null differ diff --git a/tests/FFMpeg/files/Audio.mp3 b/tests/FFMpeg/files/Audio.mp3 deleted file mode 100644 index f6e33e3..0000000 Binary files a/tests/FFMpeg/files/Audio.mp3 and /dev/null differ diff --git a/tests/FFMpeg/files/Jahzzar_-_05_-_Siesta.mp3 b/tests/FFMpeg/files/Jahzzar_-_05_-_Siesta.mp3 deleted file mode 100644 index 1db27d7..0000000 Binary files a/tests/FFMpeg/files/Jahzzar_-_05_-_Siesta.mp3 and /dev/null differ diff --git a/tests/FFMpeg/files/Test.ogv b/tests/FFMpeg/files/Test.ogv deleted file mode 100644 index 06df24c..0000000 Binary files a/tests/FFMpeg/files/Test.ogv and /dev/null differ diff --git a/tests/FFMpeg/files/WrongFile.mp4 b/tests/FFMpeg/files/WrongFile.mp4 deleted file mode 100644 index 17e5e5f..0000000 Binary files a/tests/FFMpeg/files/WrongFile.mp4 and /dev/null differ diff --git a/tests/FFMpeg/files/concat-list.txt b/tests/FFMpeg/files/concat-list.txt deleted file mode 100644 index fb96780..0000000 --- a/tests/FFMpeg/files/concat-list.txt +++ /dev/null @@ -1,3 +0,0 @@ -file './concat-1.mp4' -file 'concat-2.mp4' -#file 'concat-3.mp4' \ No newline at end of file diff --git a/tests/FFMpeg/files/portrait.MOV b/tests/FFMpeg/files/portrait.MOV deleted file mode 100644 index 4d31edc..0000000 Binary files a/tests/FFMpeg/files/portrait.MOV and /dev/null differ diff --git a/tests/FFMpeg/files/sample.3gp b/tests/FFMpeg/files/sample.3gp deleted file mode 100644 index 4a3d8ea..0000000 Binary files a/tests/FFMpeg/files/sample.3gp and /dev/null differ diff --git a/tests/FFMpeg/files/watermark.png b/tests/FFMpeg/files/watermark.png deleted file mode 100644 index 0c96e54..0000000 Binary files a/tests/FFMpeg/files/watermark.png and /dev/null differ diff --git a/tests/FFMpeg/fixtures/ffprobe/help.raw b/tests/FFMpeg/fixtures/ffprobe/help.raw deleted file mode 100644 index fbcc8ba..0000000 --- a/tests/FFMpeg/fixtures/ffprobe/help.raw +++ /dev/null @@ -1,512 +0,0 @@ -Simple multimedia streams analyzer -usage: ffprobe [OPTIONS] [INPUT_FILE] - -Main options: --L show license --h topic show help --? topic show help --help topic show help ---help topic show help --version show version --formats show available formats --codecs show available codecs --decoders show available decoders --encoders show available encoders --bsfs show available bit stream filters --protocols show available protocols --filters show available filters --pix_fmts show available pixel formats --layouts show standard channel layouts --sample_fmts show available audio sample formats --loglevel loglevel set libav* logging level --v loglevel set libav* logging level --report generate a report --max_alloc bytes set maximum size of a single allocated block --cpuflags flags force specific cpu flags --f format force format --unit show unit of the displayed values --prefix use SI prefixes for the displayed values --byte_binary_prefix use binary prefixes for byte units --sexagesimal use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units --pretty prettify the format of displayed values, make it more human readable --print_format format set the output printing format (available formats are: default, compact, csv, flat, ini, json, xml) --of format alias for -print_format --select_streams stream_specifier select the specified streams --sections print sections structure and section information, and exit --show_data show packets data --show_error show probing error --show_format show format/container info --show_frames show frames info --show_format_entry entry show a particular entry from the format/container info --show_entries entry_list show a set of specified entries --show_packets show packets info --show_streams show streams info --count_frames count the number of frames per stream --count_packets count the number of packets per stream --show_program_version show ffprobe version --show_library_versions show library versions --show_versions show program and library versions --show_private_data show private data --private same as show_private_data --bitexact force bitexact output --default generic catch all option --i input_file read specified file - - -AVFormatContext AVOptions: --avioflags ED.... - direct ED.... reduce buffering --probesize .D.... set probing size (from 32 to INT_MAX) --fflags ED.... - ignidx .D.... ignore index - genpts .D.... generate pts - nofillin .D.... do not fill in missing values that can be exactly calculated - noparse .D.... disable AVParsers, this needs nofillin too - igndts .D.... ignore dts - discardcorrupt .D.... discard corrupted frames - sortdts .D.... try to interleave outputted packets by dts - keepside .D.... dont merge side data - nobuffer .D.... reduce the latency introduced by optional buffering --seek2any .D.... forces seeking to enable seek to any mode (from 0 to 1) --analyzeduration .D.... specify how many microseconds are analyzed to probe the input (from 0 to INT_MAX) --cryptokey .D.... decryption key --indexmem .D.... max memory used for timestamp index (per stream) (from 0 to INT_MAX) --rtbufsize .D.... max memory used for buffering real-time frames (from 0 to INT_MAX) --fdebug ED.... print specific debug info - ts ED.... --max_delay ED.... maximum muxing or demuxing delay in microseconds (from -1 to INT_MAX) --fpsprobesize .D.... number of frames used to probe fps (from -1 to 2.14748e+09) --f_err_detect .D.... set error detection flags (deprecated; use err_detect, save via avconv) - crccheck .D.... verify embedded CRCs - bitstream .D.... detect bitstream specification deviations - buffer .D.... detect improper bitstream length - explode .D.... abort decoding on minor error detection - careful .D.... consider things that violate the spec and have not been seen in the wild as errors - compliant .D.... consider all spec non compliancies as errors - aggressive .D.... consider things that a sane encoder shouldnt do as an error --err_detect .D.... set error detection flags - crccheck .D.... verify embedded CRCs - bitstream .D.... detect bitstream specification deviations - buffer .D.... detect improper bitstream length - explode .D.... abort decoding on minor error detection - careful .D.... consider things that violate the spec and have not been seen in the wild as errors - compliant .D.... consider all spec non compliancies as errors - aggressive .D.... consider things that a sane encoder shouldnt do as an error --use_wallclock_as_timestamps .D.... use wallclock as timestamps (from 0 to 2.14748e+09) --skip_initial_bytes .D.... skip initial bytes (from 0 to 2.14748e+09) --correct_ts_overflow .D.... correct single timestamp overflows (from 0 to 1) - -AVIOContext AVOptions: - -URLContext AVOptions: - -crypto AVOptions: --key .D.... AES decryption key --iv .D.... AES decryption initialization vector - -ffrtmphttp AVOptions: --ffrtmphttp_tls .D.... Use a HTTPS tunneling connection (RTMPTS). (from 0 to 1) - -file AVOptions: - -http AVOptions: --seekable .D.... control seekability of connection (from -1 to 1) --headers ED.... set custom HTTP headers, can override built in default headers --content_type ED.... force a content type --user-agent .D.... override User-Agent header --multiple_requests ED.... use persistent connections (from 0 to 1) --post_data ED.... set custom HTTP post data --timeout ED.... set timeout of socket I/O operations (from -1 to INT_MAX) - -rtmp AVOptions: --rtmp_app ED.... Name of application to connect to on the RTMP server --rtmp_buffer ED.... Set buffer time in milliseconds. The default is 3000. (from 0 to INT_MAX) --rtmp_conn ED.... Append arbitrary AMF data to the Connect message --rtmp_flashver ED.... Version of the Flash plugin used to run the SWF player. --rtmp_live .D.... Specify that the media is a live stream. (from INT_MIN to INT_MAX) - any .D.... both - live .D.... live stream - recorded .D.... recorded stream --rtmp_pageurl .D.... URL of the web page in which the media was embedded. By default no value will be sent. --rtmp_playpath ED.... Stream identifier to play or to publish --rtmp_subscribe .D.... Name of live stream to subscribe to. Defaults to rtmp_playpath. --rtmp_swfhash .D.... SHA256 hash of the decompressed SWF file (32 bytes). --rtmp_swfsize .D.... Size of the decompressed SWF file, required for SWFVerification. (from 0 to INT_MAX) --rtmp_swfurl ED.... URL of the SWF player. By default no value will be sent --rtmp_swfverify .D.... URL to player swf file, compute hash/size automatically. --rtmp_tcurl ED.... URL of the target stream. Defaults to proto://host[:port]/app. --rtmp_listen .D.... Listen for incoming rtmp connections (from INT_MIN to INT_MAX) --timeout .D.... Maximum timeout (in seconds) to wait for incoming connections. -1 is infinite. Implies -rtmp_listen 1 (from INT_MIN to INT_MAX) - -rtmpt AVOptions: --rtmp_app ED.... Name of application to connect to on the RTMP server --rtmp_buffer ED.... Set buffer time in milliseconds. The default is 3000. (from 0 to INT_MAX) --rtmp_conn ED.... Append arbitrary AMF data to the Connect message --rtmp_flashver ED.... Version of the Flash plugin used to run the SWF player. --rtmp_live .D.... Specify that the media is a live stream. (from INT_MIN to INT_MAX) - any .D.... both - live .D.... live stream - recorded .D.... recorded stream --rtmp_pageurl .D.... URL of the web page in which the media was embedded. By default no value will be sent. --rtmp_playpath ED.... Stream identifier to play or to publish --rtmp_subscribe .D.... Name of live stream to subscribe to. Defaults to rtmp_playpath. --rtmp_swfhash .D.... SHA256 hash of the decompressed SWF file (32 bytes). --rtmp_swfsize .D.... Size of the decompressed SWF file, required for SWFVerification. (from 0 to INT_MAX) --rtmp_swfurl ED.... URL of the SWF player. By default no value will be sent --rtmp_swfverify .D.... URL to player swf file, compute hash/size automatically. --rtmp_tcurl ED.... URL of the target stream. Defaults to proto://host[:port]/app. --rtmp_listen .D.... Listen for incoming rtmp connections (from INT_MIN to INT_MAX) --timeout .D.... Maximum timeout (in seconds) to wait for incoming connections. -1 is infinite. Implies -rtmp_listen 1 (from INT_MIN to INT_MAX) - -srtp AVOptions: - -tcp AVOptions: --listen ED.... listen on port instead of connecting (from 0 to 1) --timeout ED.... timeout of socket i/o operations (from 0 to INT_MAX) --listen_timeout ED.... connection awaiting timeout (from -1 to INT_MAX) - -udp AVOptions: --buffer_size ED.... Socket buffer size in bytes (from 0 to INT_MAX) --localport ED.... Set local port to bind to (from 0 to INT_MAX) --localaddr ED.... Choose local IP address --pkt_size ED.... Set size of UDP packets (from 0 to INT_MAX) --reuse ED.... Explicitly allow or disallow reusing UDP sockets (from 0 to 1) --connect ED.... Should connect() be called on socket (from 0 to 1) --fifo_size .D.... Set the UDP receiving circular buffer size, expressed as a number of packets with size of 188 bytes (from 0 to INT_MAX) --overrun_nonfatal .D.... Survive in case of UDP receiving circular buffer overrun (from 0 to 1) --timeout .D.... In read mode: if no data arrived in more than this time interval, raise error (from 0 to INT_MAX) - -Artworx Data Format demuxer AVOptions: --linespeed .D.... set simulated line speed (bytes per second) (from 1 to INT_MAX) --video_size .D.... set video size, such as 640x480 or hd720. --framerate .D.... set framerate (frames per second) - -aqtdec AVOptions: --subfps .D...S set the movie frame rate (from 0 to INT_MAX) - -asf demuxer AVOptions: --no_resync_search .D.... Don't try to resynchronize by looking for a certain optional start code (from 0 to 1) - -avi AVOptions: --use_odml .D.... use odml index (from -1 to 1) - -Binary text demuxer AVOptions: --linespeed .D.... set simulated line speed (bytes per second) (from 1 to INT_MAX) --video_size .D.... set video size, such as 640x480 or hd720. --framerate .D.... set framerate (frames per second) - -cavsvideo demuxer AVOptions: --framerate .D.... - -CDXL demuxer AVOptions: --sample_rate .D.... (from 1 to INT_MAX) --framerate .D.... - -concat demuxer AVOptions: --safe .D.... enable safe mode (from -1 to 1) - -dirac demuxer AVOptions: --framerate .D.... - -dnxhd demuxer AVOptions: --framerate .D.... - -flvdec AVOptions: --flv_metadata .D.V.. Allocate streams according the onMetaData array (from 0 to 1) - -g729 demuxer AVOptions: --bit_rate .D.... (from 0 to INT_MAX) - -GIF demuxer AVOptions: --min_delay .D.... minimum valid delay between frames (in hundredths of second) (from 0 to 6000) --default_delay .D.... default delay between frames (in hundredths of second) (from 0 to 6000) - -gsm demuxer AVOptions: --sample_rate .D.... (from 1 to 6.50753e+07) - -h261 demuxer AVOptions: --framerate .D.... - -h263 demuxer AVOptions: --framerate .D.... - -h264 demuxer AVOptions: --framerate .D.... - -iCE Draw File demuxer AVOptions: --linespeed .D.... set simulated line speed (bytes per second) (from 1 to INT_MAX) --video_size .D.... set video size, such as 640x480 or hd720. --framerate .D.... set framerate (frames per second) - -image2 demuxer AVOptions: --framerate .D.... set the video framerate --loop .D.... force loop over input file sequence (from 0 to 1) --pattern_type .D.... set pattern type (from 0 to INT_MAX) - glob_sequence .D.... select glob/sequence pattern type - glob .D.... select glob pattern type - sequence .D.... select sequence pattern type --pixel_format .D.... set video pixel format --start_number .D.... set first number in the sequence (from 0 to INT_MAX) --start_number_range .D.... set range for looking at the first sequence number (from 1 to INT_MAX) --video_size .D.... set video size --frame_size .D.... force frame size in bytes (from 0 to INT_MAX) - -image2pipe demuxer AVOptions: --framerate .D.... set the video framerate --loop .D.... force loop over input file sequence (from 0 to 1) --pattern_type .D.... set pattern type (from 0 to INT_MAX) - glob_sequence .D.... select glob/sequence pattern type - glob .D.... select glob pattern type - sequence .D.... select sequence pattern type --pixel_format .D.... set video pixel format --start_number .D.... set first number in the sequence (from 0 to INT_MAX) --start_number_range .D.... set range for looking at the first sequence number (from 1 to INT_MAX) --video_size .D.... set video size --frame_size .D.... force frame size in bytes (from 0 to INT_MAX) - -ingenient demuxer AVOptions: --framerate .D.... - -m4v demuxer AVOptions: --framerate .D.... - -mjpeg demuxer AVOptions: --framerate .D.... - -mov,mp4,m4a,3gp,3g2,mj2 AVOptions: --use_absolute_path .D.V.. allow using absolute path when opening alias, this is a possible security issue (from 0 to 1) --ignore_editlist .D.V.. (from 0 to 1) - -mpegtsraw demuxer AVOptions: --compute_pcr .D.... Compute exact PCR for each transport stream packet. (from 0 to 1) - -mpegvideo demuxer AVOptions: --framerate .D.... - -alaw demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -mulaw demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -f64be demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -f64le demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -f32be demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -f32le demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -s32be demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -s32le demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -s24be demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -s24le demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -s16be demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -s16le demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -s8 demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -u32be demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -u32le demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -u24be demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -u24le demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -u16be demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -u16le demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -u8 demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --channels .D.... (from 0 to INT_MAX) - -rawvideo demuxer AVOptions: --video_size .D.... set frame size --pixel_format .D.... set pixel format --framerate .D.... set frame rate - -RTP demuxer AVOptions: --rtp_flags .D.... RTP flags - filter_src .D.... Only receive packets from the negotiated peer IP - listen .D.... Wait for incoming connections --reorder_queue_size .D.... Number of packets to buffer for handling of reordered packets (from -1 to INT_MAX) - -RTSP demuxer AVOptions: --initial_pause .D.... Don't start playing the stream immediately (from 0 to 1) --rtsp_transport ED.... RTSP transport protocols - udp ED.... UDP - tcp ED.... TCP - udp_multicast .D.... UDP multicast - http .D.... HTTP tunneling --rtsp_flags .D.... RTSP flags - filter_src .D.... Only receive packets from the negotiated peer IP - listen .D.... Wait for incoming connections --allowed_media_types .D.... Media types to accept from the server - video .D.... Video - audio .D.... Audio - data .D.... Data --min_port ED.... Minimum local UDP port (from 0 to 65535) --max_port ED.... Maximum local UDP port (from 0 to 65535) --timeout .D.... Maximum timeout (in seconds) to wait for incoming connections. -1 is infinite. Implies flag listen (from INT_MIN to INT_MAX) --reorder_queue_size .D.... Number of packets to buffer for handling of reordered packets (from -1 to INT_MAX) - -sbg_demuxer AVOptions: --sample_rate .D.... (from 0 to INT_MAX) --frame_size .D.... (from 0 to INT_MAX) --max_file_size .D.... (from 0 to INT_MAX) - -SDP demuxer AVOptions: --sdp_flags .D.... SDP flags - filter_src .D.... Only receive packets from the negotiated peer IP - listen .D.... Wait for incoming connections - custom_io .D.... Use custom IO --allowed_media_types .D.... Media types to accept from the server - video .D.... Video - audio .D.... Audio - data .D.... Data --reorder_queue_size .D.... Number of packets to buffer for handling of reordered packets (from -1 to INT_MAX) - -tedcaptions_demuxer AVOptions: --start_time .D...S set the start time (offset) of the subtitles, in ms (from I64_MIN to I64_MAX) - -TTY demuxer AVOptions: --chars_per_frame .D.... (from 1 to INT_MAX) --video_size .D.... A string describing frame size, such as 640x480 or hd720. --framerate .D.... - -vc1 demuxer AVOptions: --framerate .D.... - -WAV demuxer AVOptions: --ignore_length .D.... Ignore length (from 0 to 1) - -eXtended BINary text (XBIN) demuxer AVOptions: --linespeed .D.... set simulated line speed (bytes per second) (from 1 to INT_MAX) --video_size .D.... set video size, such as 640x480 or hd720. --framerate .D.... set framerate (frames per second) - -lavfi indev AVOptions: --graph .D.... set libavfilter graph --graph_file .D.... set libavfilter graph filename --dumpgraph .D.... dump graph to stderr - -AIFF muxer AVOptions: - -AST muxer AVOptions: - -f4v muxer AVOptions: - -GIF muxer AVOptions: - -hls muxer AVOptions: - -image2 muxer AVOptions: - -ipod muxer AVOptions: - -ismv muxer AVOptions: - -LATM/LOAS muxer AVOptions: - -mov muxer AVOptions: - -MP3 muxer AVOptions: - -mp4 muxer AVOptions: - -mpeg muxer AVOptions: - -vcd muxer AVOptions: - -dvd muxer AVOptions: - -svcd muxer AVOptions: - -vob muxer AVOptions: - -MPEGTS muxer AVOptions: - -Ogg muxer AVOptions: - -psp muxer AVOptions: - -RTP muxer AVOptions: - -RTSP muxer AVOptions: --initial_pause .D.... Don't start playing the stream immediately (from 0 to 1) --rtsp_transport ED.... RTSP transport protocols - udp ED.... UDP - tcp ED.... TCP - udp_multicast .D.... UDP multicast - http .D.... HTTP tunneling --rtsp_flags .D.... RTSP flags - filter_src .D.... Only receive packets from the negotiated peer IP - listen .D.... Wait for incoming connections --allowed_media_types .D.... Media types to accept from the server - video .D.... Video - audio .D.... Audio - data .D.... Data --min_port ED.... Minimum local UDP port (from 0 to 65535) --max_port ED.... Maximum local UDP port (from 0 to 65535) --timeout .D.... Maximum timeout (in seconds) to wait for incoming connections. -1 is infinite. Implies flag listen (from INT_MIN to INT_MAX) --reorder_queue_size .D.... Number of packets to buffer for handling of reordered packets (from -1 to INT_MAX) - -segment muxer AVOptions: - -stream_segment muxer AVOptions: - -smooth streaming muxer AVOptions: - -spdif AVOptions: - -tg2 muxer AVOptions: - -tgp muxer AVOptions: - -WAV muxer AVOptions: - -caca_outdev AVOptions: - diff --git a/tests/FFMpeg/fixtures/ffprobe/show_format.json b/tests/FFMpeg/fixtures/ffprobe/show_format.json deleted file mode 100644 index de962fa..0000000 --- a/tests/FFMpeg/fixtures/ffprobe/show_format.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "format": { - "filename": "Interview5mm4500.mp4", - "nb_streams": 2, - "format_name": "mov,mp4,m4a,3gp,3g2,mj2", - "format_long_name": "QuickTime / MOV", - "start_time": "0.000000", - "duration": "300.011000", - "size": "173833712", - "bit_rate": "4635395", - "tags": { - "major_brand": "isom", - "minor_version": "512", - "compatible_brands": "isomiso2avc1mp41", - "creation_time": "1970-01-01 00:00:00", - "title": "5mm 4500.mp4", - "encoder": "Lavf52.108.0" - } - } -} diff --git a/tests/FFMpeg/fixtures/ffprobe/show_format.raw b/tests/FFMpeg/fixtures/ffprobe/show_format.raw deleted file mode 100644 index 1e857e5..0000000 --- a/tests/FFMpeg/fixtures/ffprobe/show_format.raw +++ /dev/null @@ -1,16 +0,0 @@ -[FORMAT] -filename=Interview5mm4500.mp4 -nb_streams=2 -format_name=mov,mp4,m4a,3gp,3g2,mj2 -format_long_name=QuickTime / MOV -start_time=0.000000 -duration=300.011000 -size=173833712 -bit_rate=4635395 -TAG:major_brand=isom -TAG:minor_version=512 -TAG:compatible_brands=isomiso2avc1mp41 -TAG:creation_time=1970-01-01 00:00:00 -TAG:title=5mm 4500.mp4 -TAG:encoder=Lavf52.108.0 -[/FORMAT] diff --git a/tests/FFMpeg/fixtures/ffprobe/show_streams.json b/tests/FFMpeg/fixtures/ffprobe/show_streams.json deleted file mode 100644 index decdc36..0000000 --- a/tests/FFMpeg/fixtures/ffprobe/show_streams.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "streams": [ - { - "index": 0, - "codec_name": "h264", - "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", - "profile": "High", - "codec_type": "video", - "codec_time_base": "1/100", - "codec_tag_string": "avc1", - "codec_tag": "0x31637661", - "width": 960, - "height": 720, - "has_b_frames": 2, - "sample_aspect_ratio": "1:1", - "display_aspect_ratio": "4:3", - "pix_fmt": "yuv420p", - "level": 32, - "r_frame_rate": "50/1", - "avg_frame_rate": "50/1", - "time_base": "1/50000", - "start_pts": 0, - "start_time": "0.000000", - "duration_ts": 15000000, - "duration": "300.000000", - "bit_rate": "4499198", - "nb_frames": "15000", - "disposition": { - "default": 0, - "dub": 0, - "original": 0, - "comment": 0, - "lyrics": 0, - "karaoke": 0, - "forced": 0, - "hearing_impaired": 0, - "visual_impaired": 0, - "clean_effects": 0, - "attached_pic": 0 - }, - "tags": { - "creation_time": "1970-01-01 00:00:00", - "language": "und", - "handler_name": "VideoHandler" - } - }, - { - "index": 1, - "codec_name": "aac", - "codec_long_name": "AAC (Advanced Audio Coding)", - "codec_type": "audio", - "codec_time_base": "1/48000", - "codec_tag_string": "mp4a", - "codec_tag": "0x6134706d", - "sample_fmt": "fltp", - "sample_rate": "48000", - "channels": 2, - "bits_per_sample": 0, - "r_frame_rate": "0/0", - "avg_frame_rate": "0/0", - "time_base": "1/48000", - "start_pts": 0, - "start_time": "0.000000", - "duration_ts": 14400512, - "duration": "300.010667", - "bit_rate": "127973", - "nb_frames": "14063", - "disposition": { - "default": 0, - "dub": 0, - "original": 0, - "comment": 0, - "lyrics": 0, - "karaoke": 0, - "forced": 0, - "hearing_impaired": 0, - "visual_impaired": 0, - "clean_effects": 0, - "attached_pic": 0 - }, - "tags": { - "creation_time": "1970-01-01 00:00:00", - "language": "und", - "handler_name": "SoundHandler" - } - } - ] -} diff --git a/tests/FFMpeg/fixtures/ffprobe/show_streams.raw b/tests/FFMpeg/fixtures/ffprobe/show_streams.raw deleted file mode 100644 index 6ce06c9..0000000 --- a/tests/FFMpeg/fixtures/ffprobe/show_streams.raw +++ /dev/null @@ -1,84 +0,0 @@ -[STREAM] -index=0 -codec_name=h264 -codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 -profile=High -codec_type=video -codec_time_base=1/100 -codec_tag_string=avc1 -codec_tag=0x31637661 -width=960 -height=720 -has_b_frames=2 -sample_aspect_ratio=1:1 -display_aspect_ratio=4:3 -pix_fmt=yuv420p -level=32 -timecode=N/A -id=N/A -r_frame_rate=50/1 -avg_frame_rate=50/1 -time_base=1/50000 -start_pts=0 -start_time=0.000000 -duration_ts=15000000 -duration=300.000000 -bit_rate=4499198 -nb_frames=15000 -nb_read_frames=N/A -nb_read_packets=N/A -DISPOSITION:default=0 -DISPOSITION:dub=0 -DISPOSITION:original=0 -DISPOSITION:comment=0 -DISPOSITION:lyrics=0 -DISPOSITION:karaoke=0 -DISPOSITION:forced=0 -DISPOSITION:hearing_impaired=0 -DISPOSITION:visual_impaired=0 -DISPOSITION:clean_effects=0 -DISPOSITION:attached_pic=0 -TAG:creation_time=1970-01-01 00:00:00 -TAG:language=und -TAG:handler_name=VideoHandler -[/STREAM] -[STREAM] -index=1 -codec_name=aac -codec_long_name=AAC (Advanced Audio Coding) -profile=unknown -codec_type=audio -codec_time_base=1/48000 -codec_tag_string=mp4a -codec_tag=0x6134706d -sample_fmt=fltp -sample_rate=48000 -channels=2 -bits_per_sample=0 -id=N/A -r_frame_rate=0/0 -avg_frame_rate=0/0 -time_base=1/48000 -start_pts=0 -start_time=0.000000 -duration_ts=14400512 -duration=300.010667 -bit_rate=127973 -nb_frames=14063 -nb_read_frames=N/A -nb_read_packets=N/A -DISPOSITION:default=0 -DISPOSITION:dub=0 -DISPOSITION:original=0 -DISPOSITION:comment=0 -DISPOSITION:lyrics=0 -DISPOSITION:karaoke=0 -DISPOSITION:forced=0 -DISPOSITION:hearing_impaired=0 -DISPOSITION:visual_impaired=0 -DISPOSITION:clean_effects=0 -DISPOSITION:attached_pic=0 -TAG:creation_time=1970-01-01 00:00:00 -TAG:language=und -TAG:handler_name=SoundHandler -[/STREAM] diff --git a/tests/Functional/AudioImagingTest.php b/tests/Functional/AudioImagingTest.php deleted file mode 100644 index e7742b8..0000000 --- a/tests/Functional/AudioImagingTest.php +++ /dev/null @@ -1,30 +0,0 @@ -open(realpath(__DIR__ . '/../files/Audio.mp3')); - $spectrum = new Spectrum($audio, $ffmpeg->getFFMpegDriver(), $ffprobe, 1024, 1024); - $spectrum->setLegend(false) - ->setOrientation('horizontal') - ->setColor('fiery'); - $output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'spectrum.png'; - $spectrum->save($output); - $this->assertFileExists($output); - unlink($output); - } -} diff --git a/tests/Pest.php b/tests/Pest.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/tests/Pest.php @@ -0,0 +1 @@ +getFFMpegDriverMock(); - $ffprobe = $this->getFFProbeMock(); - - $pathfile = '/tests/files/Audio.mp3'; - - array_push($commands, $pathfile); - - $driver->expects($this->once()) - ->method('command') - ->with($commands); - - $spectrum = new Spectrum($this->getAudioMock(), $driver, $ffprobe, 640, 120); - $this->assertSame($spectrum, $spectrum->save($pathfile)); - } - - public function provideSaveOptions() - { - return array( - array( - array( - '-y', '-i', NULL, '-filter_complex', - 'showspectrumpic=s=640x120', - '-frames:v', '1', - ), - ), - ); - } -} diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index 4a337cc..0000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,9 +0,0 @@ -