classes/Video.php
private function getAvconvProcess(
        $audioBitrate,
        $filetype = 'mp3',
        $audioOnly = true,
        $from = null,
        $to = null
    ) {
        if (!$this->checkCommand([$this->config->avconv, '-version'])) {
            throw new Exception(_('Can\'t find avconv or ffmpeg at ').$this->config->avconv.'.');
        }

        $durationRegex = '/(\d+:)?(\d+:)?(\d+)/';

        $afterArguments = [];

        if ($audioOnly) {
            $afterArguments[] = '-vn';
        }

        if (!empty($from)) {
            if (!preg_match($durationRegex, $from)) {
                throw new Exception(_('Invalid start time: ').$from.'.');
            }
            $afterArguments[] = '-ss';
            $afterArguments[] = $from;
        }
        if (!empty($to)) {
            if (!preg_match($durationRegex, $to)) {
                throw new Exception(_('Invalid end time: ').$to.'.');
            }
            $afterArguments[] = '-to';
            $afterArguments[] = $to;
        }

        $urls = $this->getUrl();

        $arguments = array_merge(
            [
                $this->config->avconv,
                '-v', $this->config->avconvVerbosity,
            ],
            $this->getRtmpArguments(),
            [
                '-i', $urls[0],
                '-f', $filetype,
                '-b:a', $audioBitrate.'k',
            ],
            $afterArguments,
            [
                'pipe:1',
            ]
        );

        //Vimeo needs a correct user-agent
        $arguments[] = '-user_agent';
        $arguments[] = $this->getProp('dump-user-agent');

        return new Process($arguments);
    }
private function getAvconvProcess(
        $audioBitrate,
        $filetype = 'mp3',
        $audioOnly = true,
        $from = null,
        $to = null
    ) {
        if (!$this->checkCommand([$this->config->avconv, '-version'])) {
            throw new Exception(_('Can\'t find avconv or ffmpeg at ').$this->config->avconv.'.');
        }

        $durationRegex = '/(\d+:)?(\d+:)?(\d+)/';

        $afterArguments = [];

        if ($audioOnly) {
            $afterArguments[] = '-vn';
        }

        if (!empty($from)) {
            if (!preg_match($durationRegex, $from)) {
                throw new Exception(_('Invalid start time: ').$from.'.');
            }
            $afterArguments[] = '-ss';
            $afterArguments[] = $from;
        }
        if (!empty($to)) {
            if (!preg_match($durationRegex, $to)) {
                throw new Exception(_('Invalid end time: ').$to.'.');
            }
            $afterArguments[] = '-to';
            $afterArguments[] = $to;
        }

        $urls = $this->getUrl();

        $arguments = array_merge(
            [
                $this->config->avconv,
                '-v', $this->config->avconvVerbosity,
            ],
            $this->getRtmpArguments(),
            [
                '-i', $urls[0],
                '-f', $filetype,
                '-b:a', $audioBitrate.'k',
            ],
            $afterArguments,
            [
                'pipe:1',
            ]
        );

        //Vimeo needs a correct user-agent
        $arguments[] = '-user_agent';
        $arguments[] = $this->getProp('dump-user-agent');

        return new Process($arguments);
    }
private function getAvconvProcess ( $ audioBitrate , $ filetype = 'mp3' , $ audioOnly = true , $ from = null , $ to = null ) { if ( ! $ this -> checkCommand ( [ $ this -> config -> avconv , '-version' ] ) ) { throw new Exception ( _ ( 'Can\'t find avconv or ffmpeg at ' ) . $ this -> config -> avconv . '.' ) ; } $ durationRegex = '/(\d+:)?(\d+:)?(\d+)/' ; $ afterArguments = [ ] ; if ( $ audioOnly ) { $ afterArguments [ ] = '-vn' ; } if ( ! empty ( $ from ) ) { if ( ! preg_match ( $ durationRegex , $ from ) ) { throw new Exception ( _ ( 'Invalid start time: ' ) . $ from . '.' ) ; } $ afterArguments [ ] = '-ss' ; $ afterArguments [ ] = $ from ; } if ( ! empty ( $ to ) ) { if ( ! preg_match ( $ durationRegex , $ to ) ) { throw new Exception ( _ ( 'Invalid end time: ' ) . $ to . '.' ) ; } $ afterArguments [ ] = '-to' ; $ afterArguments [ ] = $ to ; } $ urls = $ this -> getUrl ( ) ; $ arguments = array_merge ( [ $ this -> config -> avconv , '-v' , $ this -> config -> avconvVerbosity , ] , $ this -> getRtmpArguments ( ) , [ '-i' , $ urls [ 0 ] , '-f' , $ filetype , '-b:a' , $ audioBitrate . 'k' , ] , $ afterArguments , [ 'pipe:1' , ] ) ; //Vimeo needs a correct user-agent $ arguments [ ] = '-user_agent' ; $ arguments [ ] = $ this -> getProp ( 'dump-user-agent' ) ; return new Process ( $ arguments ) ; }
Get a process that runs avconv in order to convert a video.

@param int    $audioBitrate Audio bitrate of the converted file
@param string $filetype     Filetype of the converted file
@param bool   $audioOnly    True to return an audio-only file
@param string $from         Start the conversion at this time
@param string $to           End the conversion at this time

@throws Exception If avconv/ffmpeg is missing

@return Process Process
Get a process that runs avconv in order to convert a video .