XF 2.1 XFMG extend class

Yodrak

Active member
Hi, i try to extend XFMG with an Addon. This is my code:

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

Bildschirmfoto 2020-05-26 um 21.27.21.png

And this is my Class Extension

Bildschirmfoto 2020-05-26 um 21.31.25.png
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?
 

Yodrak

Active member
My code is working if i hack the same code in /XFMG/Ffmpeg/Runner if i take a look in PhpStorm it's Show me that the function get override from my new function. But it happen nothing.

If i try to xdebug this then my breakpoint doesn't show up.

Maybe some one can explain me how to xdebug xenforo?
 

asprin

Active member
On a slightly different note, and pardon my ignorance as I'm still new to the world of XF development, isn't there a typo in your extension class name?

What you currently have:
PHP:
Yodrak/xfmgVideoOptions\XFMG\Ffmpeg\Runner

What it should it be: (notice the \ after Yodrak instead of /)
Code:
Yodrak\xfmgVideoOptions\XFMG\Ffmpeg\Runner
 
Top