ILIAS  release_8 Revision v8.24
ilFFmpeg Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilFFmpeg:

Static Public Member Functions

static enabled ()
 Checks, whether FFmpeg support is enabled (path is set in the setup) More...
 
static getTargetMimeTypes ()
 Get desired target mime types. More...
 
static getSourceMimeTypes ()
 
static supportsImageExtraction (string $a_mime)
 Check if mime type supports image extraction. More...
 
static exec (string $args)
 Execute ffmpeg. More...
 
static getLastReturnValues ()
 Get last return values. More...
 
static extractImage (string $a_file, string $a_target_filename, string $a_target_dir="", int $a_sec=1)
 Extract image from video file. More...
 

Static Public Attributes

static array $last_return = array()
 
static array $formats
 

Static Private Member Functions

static getCmd ()
 Get ffmpeg command. More...
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning FFmpeg wrapper

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 23 of file class.ilFFmpeg.php.

Member Function Documentation

◆ enabled()

static ilFFmpeg::enabled ( )
static

Checks, whether FFmpeg support is enabled (path is set in the setup)

Definition at line 61 of file class.ilFFmpeg.php.

61 : bool
62 {
63 if (defined("PATH_TO_FFMPEG") && PATH_TO_FFMPEG != "") {
64 return true;
65 }
66 return false;
67 }

Referenced by ilObjMediaCastGUI\editCastItemObject(), and ilDclMobRecordFieldModel\parseValue().

+ Here is the caller graph for this function:

◆ exec()

static ilFFmpeg::exec ( string  $args)
static

Execute ffmpeg.

Definition at line 121 of file class.ilFFmpeg.php.

121 : array
122 {
123 return ilShellUtil::execQuoted(self::getCmd(), $args);
124 }
static execQuoted(string $cmd, ?string $args=null)

References ilShellUtil\execQuoted().

+ Here is the call graph for this function:

◆ extractImage()

static ilFFmpeg::extractImage ( string  $a_file,
string  $a_target_filename,
string  $a_target_dir = "",
int  $a_sec = 1 
)
static

Extract image from video file.

Parameters
string$a_filesource file (full path included)
string$a_target_dirtarget directory (no trailing "/")
string$a_target_filenametarget file name (no path!)
int$a_sec
Returns
string new file (full path)
Exceptions
ilFFmpegException

Definition at line 144 of file class.ilFFmpeg.php.

149 : string {
150 $spi = pathinfo($a_file);
151
152 // use source directory if no target directory is passed
153 $target_dir = ($a_target_dir != "")
154 ? $a_target_dir
155 : $spi['dirname'];
156
157 $target_file = $target_dir . "/" . $a_target_filename;
158
159 $sec = $a_sec;
160 $cmd = "-y -i " . ilShellUtil::escapeShellArg(
161 $a_file
162 ) . " -r 1 -f image2 -vframes 1 -ss " . $sec . " " . ilShellUtil::escapeShellArg($target_file);
163 $ret = self::exec($cmd . " 2>&1");
164 self::$last_return = $ret;
165
166 if (is_file($target_file)) {
167 return $target_file;
168 } else {
169 throw new ilFFmpegException("It was not possible to extract an image from " . basename($a_file) . ".");
170 }
171 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static exec(string $args)
Execute ffmpeg.
static escapeShellArg(string $a_arg)

Referenced by ilDclMobRecordFieldModel\parseValue().

+ Here is the caller graph for this function:

◆ getCmd()

static ilFFmpeg::getCmd ( )
staticprivate

Get ffmpeg command.

Definition at line 113 of file class.ilFFmpeg.php.

113 : string
114 {
115 return PATH_TO_FFMPEG;
116 }

◆ getLastReturnValues()

static ilFFmpeg::getLastReturnValues ( )
static

Get last return values.

Definition at line 129 of file class.ilFFmpeg.php.

129 : ?array
130 {
131 return self::$last_return;
132 }
static array $last_return

Referenced by ilObjMediaCastGUI\extractPreviewImageObject().

+ Here is the caller graph for this function:

◆ getSourceMimeTypes()

static ilFFmpeg::getSourceMimeTypes ( )
static
Returns
string[]

Definition at line 86 of file class.ilFFmpeg.php.

86 : array
87 {
88 $ttypes = array();
89 foreach (self::$formats as $k => $f) {
90 if ($f["source"] == true) {
91 $ttypes[] = $k;
92 }
93 }
94 return $ttypes;
95 }
$formats
Definition: date.php:77

References Vendor\Package\$f, and $formats.

◆ getTargetMimeTypes()

static ilFFmpeg::getTargetMimeTypes ( )
static

Get desired target mime types.

Definition at line 72 of file class.ilFFmpeg.php.

72 : array
73 {
74 $ttypes = array();
75 foreach (self::$formats as $k => $f) {
76 if ($f["target"] == true) {
77 $ttypes[] = $k;
78 }
79 }
80 return $ttypes;
81 }

References Vendor\Package\$f, and $formats.

◆ supportsImageExtraction()

static ilFFmpeg::supportsImageExtraction ( string  $a_mime)
static

Check if mime type supports image extraction.

Definition at line 100 of file class.ilFFmpeg.php.

102 : bool {
103 if (in_array($a_mime, self::getSourceMimeTypes(), true)) {
104 return true;
105 }
106 return false;
107 }

Referenced by ilObjMediaCastGUI\editCastItemObject(), and ilDclMobRecordFieldModel\parseValue().

+ Here is the caller graph for this function:

Field Documentation

◆ $formats

array ilFFmpeg::$formats
static
Initial value:
= array(
"video/3pgg" => array(
"source" => true,
"target" => false
),
"video/x-flv" => array(
"source" => true,
"target" => false
),
"video/mp4" => array(
"source" => true,
"target" => true,
"parameters" => "-vcodec libx264 -strict experimental -acodec aac -sameq -ab 56k -ar 48000",
"suffix" => "mp4"
),
"video/webm" => array(
"source" => true,
"target" => true,
"parameters" => "-strict experimental -vcodec libvpx -acodec vorbis -ac 2 -sameq -ab 56k -ar 48000",
"suffix" => "webm"
)
)

Definition at line 34 of file class.ilFFmpeg.php.

◆ $last_return

array ilFFmpeg::$last_return = array()
static

Definition at line 25 of file class.ilFFmpeg.php.


The documentation for this class was generated from the following file: