Skip to content
Snippets Groups Projects
Commit 0bdb3cd5 authored by Sascha Grossenbacher's avatar Sascha Grossenbacher
Browse files

Issue #2777531 by Berdir: Added missing probe service, update and improve README

parent 1a9320b8
Branches
Tags 8.x-1.0 8.x-1.0-rc1
No related merge requests found
......@@ -4,26 +4,25 @@ This project is an API module that integrate with the [PHP FFmpeg library](admin
This module doesn't do anything by itself and is usually extended by other projects that do something useful with
FFmpeg.
[![Build Status](https://travis-ci.org/FloeDesignTechnologies/drupal-php-ffmpeg.svg?branch=7.x-1.x)](https://travis-ci.org/FloeDesignTechnologies/drupal-php-ffmpeg)
[![Build Status](https://travis-ci.org/FloeDesignTechnologies/drupal-php-ffmpeg.svg?branch=8.x-1.x)](https://travis-ci.org/FloeDesignTechnologies/drupal-php-ffmpeg)
## Installation
Follow the standard module installation guide (http://drupal.org/documentation/install/modules-themes/modules-7)
to install PHP FFmpeg. This module depends on the Composer Manager module (http://drupal.org/project/composer_manager),
so follow the instructions on its project page to install the third-party libraries that this module requires.
Follow the standard module installation guide (https://www.drupal.org/docs/8/extending-drupal/installing-contributed-modules)
to install PHP FFmpeg. This module has a composer dependency (php-ffmpeg/php-ffmpeg), see https://www.drupal.org/node/2404989 for more information.
After installation, visit the setting page at `admin/config/development/php-ffmpeg` to set the path to
## Usage
The module provides an administrative UI for the various configuration options exposed by PHP FFmpeg library. To
instantiate the PHP FFmpeg classes populated with the configuration options, call `$ffmpeg = php_ffmpeg();` or
`$ffprobe = php_ffmpeg_probe` in your module. Refer to the PHP FFmpeg library's documentation for details on how to use
instantiate the PHP FFmpeg classes populated with the configuration options, call `$ffmpeg = Drupal::service('php_ffmpeg');` or
`$ffprobe = Drupal::service('php_ffmpeg_probe');` in your module. Refer to the PHP FFmpeg library's documentation for details on how to use
the library.
Adapters are provided so the PHP FFmpeg library will uses Drupal for logging and caching. The [Monolog module](https://drupal.org/project/monolog)
is also supported as an alternative logging solution.
Adapters are provided so the PHP FFmpeg library will use Drupal for caching. The logger adapter that was part of Drupal 7
was removed, as Drupal 8 natively supports the PSR LoggerInterface.
The PHP FFMpeg library uses `ffmpeg` and `ffprobe` CLI executable, all its method accepting file paths expect paths
usable are arguments for these executables. When using the library to process Drupal managed, developer have to ensure
usage of local files paths or URL supported by `ffmpeg` and `ffprobe` as sources, and local file paths as destinations.
\ No newline at end of file
usable are arguments for these executables. When using the library to process Drupal managed files, developer have to ensure
usage of local files paths or URL supported by `ffmpeg` and `ffprobe` as sources, and local file paths as destinations.
......@@ -2,6 +2,9 @@ services:
php_ffmpeg:
class: \FFMpeg\FFMpeg
factory: php_ffmpeg.factory:getFFMpeg
php_ffmpeg_probe:
class: \FFMpeg\FFMpeg
factory: php_ffmpeg.factory:getFFMpegProbe
php_ffmpeg.factory:
class: Drupal\php_ffmpeg\PHPFFMpegFactory
arguments: ['@php_ffmpeg.cache', '@logger.channel.php_ffmpeg', '@config.factory']
......
......@@ -5,6 +5,8 @@ namespace Drupal\php_ffmpeg;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Logger\LoggerChannelInterface;
use Doctrine\Common\Cache\Cache;
use FFMpeg\FFMpeg;
use FFMpeg\FFProbe;
/**
* Factory class that provides a wrapper for the FFMpeg PHP extension.
......@@ -21,7 +23,7 @@ class PHPFFMpegFactory {
/**
* Logger channel that logs execution within FFMpeg extension to watchdog.
*
* @var Drupal\Core\Logger\LoggerChannelInterface
* @var \Drupal\Core\Logger\LoggerChannelInterface
* The registered logger for this channel.
*/
protected $logger;
......@@ -38,7 +40,7 @@ class PHPFFMpegFactory {
*
* @param \Doctrine\Common\Cache\Cache $cache
* The cache backend.
* @param Drupal\Core\Logger\LoggerChannelInterface $logger
* @param \Drupal\Core\Logger\LoggerChannelInterface $logger
* Prefix used for appending to cached item identifiers.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* A configuration factory instance.
......@@ -55,15 +57,11 @@ class PHPFFMpegFactory {
* @return \FFMpeg\FFMpeg
*/
public function getFFMpeg() {
static $ffmpeg = NULL;
if (!$ffmpeg) {
$ffmpeg = \FFMpeg\FFMpeg::create(
$this->getFFMpegConfig(),
$this->logger,
$this->getFFMpegProbe()
);
}
return $ffmpeg;
return FFMpeg::create(
$this->getFFMpegConfig(),
$this->logger,
$this->getFFMpegProbe()
);
}
/**
......@@ -72,15 +70,11 @@ class PHPFFMpegFactory {
* @return \FFMpeg\FFProbe
*/
public function getFFMpegProbe() {
static $ffprobe = NULL;
if (!$ffprobe) {
$ffprobe = \FFMpeg\FFProbe::create(
$this->getFFMpegConfig(),
$this->logger,
$this->cache
);
}
return $ffprobe;
return FFProbe::create(
$this->getFFMpegConfig(),
$this->logger,
$this->cache
);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment