Yodrak
in memoriam 1976 - 2020
Hi, i try to extend XFMG with an Addon. This is my code:
This are my options
And this is my Class Extension
But if i upload a video then the movie didn´t get scaled to 720p.
So anyone can help me and show me the proper way to do this?
PHP:
<?php
namespace Yodrak\xfmgVideoOptions\XFMG\Ffmpeg;
class Runner extends XFCP_Runner
{
public function transcode()
{
// Get options
$options = \XF::options();
// Get variables
$videoOptions = $options->YodrakXFMGVideoOptions;
if ($this->type == 'video')
{
if ($this->getEncoders('libvo_aacenc'))
{
$audioCodec = '-acodec libvo_aacenc';
}
else if ($this->getEncoders('aac'))
{
// some versions of FFmpeg have aac listed as experimental
// -strict -2 should ignore the warnings about that and still run
$audioCodec = '-acodec aac -strict -2';
}
else
{
throw new \LogicException(\XF::phrase('xfmg_ffmpeg_has_access_to_neither_libvo_aacenc_codec_or_aac_codec'));
}
$videoCodec = '-vcodec libx264';
$flags = '-ac 2 -movflags faststart -f mp4';
}
else
{
$audioCodec = '-acodec mp3';
$videoCodec = '';
$flags = '-f mp3';
}
$inputFile = $this->fileName;
$outputFile = \XF\Util\File::getTempFile();
$this->run("-i {input} {$videoCodec} {$videoOptions} {$audioCodec} -ar 48000 {$flags} -y {output}", [
'input' => $inputFile,
'output' => $outputFile
]);
return $outputFile;
}
}
This are my options
And this is my Class Extension
But if i upload a video then the movie didn´t get scaled to 720p.
So anyone can help me and show me the proper way to do this?