Model/FFprobeService.php
private function getMetainfoForEpisode($episode) {
        $uri = $this->bprs_asset_helper->getAbsoluteUrl(
            $episode->getVideo()
        );
        if (!$uri) { // can't create uri of episode video
            $this->logbook->error(
                'oktolab_media.episode_encode_no_streams',
                [],
                $episode->getUniqID()
            );
            return false;
        }

        $metainfo = json_decode(
            shell_exec(
                sprintf(
                    'ffprobe -v error -show_streams -print_format json %s',
                    $uri)
                ),
            true
        );
        $metadata = ['video' => false, 'audio' => false];

        // run through all streams to find the primary video and audio stream
        foreach ($metainfo['streams'] as $stream) {
            // found both streams, skip the rest
            if ($metadata['video'] && $metadata['audio']) {
                break;
            }

            // found an audio stream
            if ($stream['codec_type'] == "audio" && $metadata['audio'] == false) {
                $metadata['audio'] = $stream;
                if (
                    !array_key_exists('max_bit_rate', $metadata['audio']) &&
                    array_key_exists('tags', $metadata['audio'])
                ) {
                    $metadata['audio']['max_bit_rate'] = $metadata['tags']['BPS'];
                }
            }

            if ($stream['codec_type'] == "video") {
                $metadata['video'] = $stream;
                if (!array_key_exists('duration', $metadata['video'])) {
                    $metadata['video']['duration'] = 0;
                } else {
                    $episode->setDuration($metadata['video']['duration']);
                }
            }
        }

        return $metadata;
    }
private function getMetainfoForEpisode($episode) {
        $uri = $this->bprs_asset_helper->getAbsoluteUrl(
            $episode->getVideo()
        );
        if (!$uri) { // can't create uri of episode video
            $this->logbook->error(
                'oktolab_media.episode_encode_no_streams',
                [],
                $episode->getUniqID()
            );
            return false;
        }

        $metainfo = json_decode(
            shell_exec(
                sprintf(
                    'ffprobe -v error -show_streams -print_format json %s',
                    $uri)
                ),
            true
        );
        $metadata = ['video' => false, 'audio' => false];

        // run through all streams to find the primary video and audio stream
        foreach ($metainfo['streams'] as $stream) {
            // found both streams, skip the rest
            if ($metadata['video'] && $metadata['audio']) {
                break;
            }

            // found an audio stream
            if ($stream['codec_type'] == "audio" && $metadata['audio'] == false) {
                $metadata['audio'] = $stream;
                if (
                    !array_key_exists('max_bit_rate', $metadata['audio']) &&
                    array_key_exists('tags', $metadata['audio'])
                ) {
                    $metadata['audio']['max_bit_rate'] = $metadata['tags']['BPS'];
                }
            }

            if ($stream['codec_type'] == "video") {
                $metadata['video'] = $stream;
                if (!array_key_exists('duration', $metadata['video'])) {
                    $metadata['video']['duration'] = 0;
                } else {
                    $episode->setDuration($metadata['video']['duration']);
                }
            }
        }

        return $metadata;
    }
private function getMetainfoForEpisode ( $ episode ) { $ uri = $ this -> bprs_asset_helper -> getAbsoluteUrl ( $ episode -> getVideo ( ) ) ; if ( ! $ uri ) { // can't create uri of episode video $ this -> logbook -> error ( 'oktolab_media.episode_encode_no_streams' , [ ] , $ episode -> getUniqID ( ) ) ; return false ; } $ metainfo = json_decode ( shell_exec ( sprintf ( 'ffprobe -v error -show_streams -print_format json %s' , $ uri ) ) , true ) ; $ metadata = [ 'video' => false , 'audio' => false ] ; // run through all streams to find the primary video and audio stream foreach ( $ metainfo [ 'streams' ] as $ stream ) { // found both streams, skip the rest if ( $ metadata [ 'video' ] && $ metadata [ 'audio' ] ) { break ; } // found an audio stream if ( $ stream [ 'codec_type' ] == "audio" && $ metadata [ 'audio' ] == false ) { $ metadata [ 'audio' ] = $ stream ; if ( ! array_key_exists ( 'max_bit_rate' , $ metadata [ 'audio' ] ) && array_key_exists ( 'tags' , $ metadata [ 'audio' ] ) ) { $ metadata [ 'audio' ] [ 'max_bit_rate' ] = $ metadata [ 'tags' ] [ 'BPS' ] ; } } if ( $ stream [ 'codec_type' ] == "video" ) { $ metadata [ 'video' ] = $ stream ; if ( ! array_key_exists ( 'duration' , $ metadata [ 'video' ] ) ) { $ metadata [ 'video' ] [ 'duration' ] = 0 ; } else { $ episode -> setDuration ( $ metadata [ 'video' ] [ 'duration' ] ) ; } } } return $ metadata ; }
extracts streaminformations of an episode from its video.
@param object $episode Entity you want the stream infos from
@return false|array if informations can't be extracted,
array of video and audio info
extracts streaminformations of an episode from its video .