V
V
Vadim2014-02-10 20:31:31
PHP
Vadim, 2014-02-10 20:31:31

Why does the ffmpeg_movie class, getArtist() method result in a fatal error?

The essence of the problem is that when receiving information about the audio file, Apache does not respond. in apache log

spoiler
[NULL @ 0x7f372b24d5e0] Value 4707126720094797824.000000 for parameter 'probesize' out of range
[NULL @ 0x7f372b24d5e0] Value 4707126720094797824.000000 for parameter 'analyzeduration' out of range
[NULL @ 0x7f372b24d5e0] Value 4697254411347427328.000000 for parameter 'indexmem' out of range
[NULL @ 0x7f372b24d5e0] Value 4703785510416416768.000000 for parameter 'rtbufsize' out of range
[NULL @ 0x7f372b24d5e0] Value -4616189618054758400.000000 for parameter 'fpsprobesize' out of range
[NULL @ 0x7f372b24d5e0] Value 4607182418800017408.000000 for parameter 'f_err_detect' out of range
[NULL @ 0x7f372b24d5e0] Value 4607182418800017408.000000 for parameter 'err_detect' out of range
[NULL @ 0x7f372b254be0] Value 4686111960511545344.000000 for parameter 'b' out of range
[NULL @ 0x7f372b254be0] Value 4683532506232782848.000000 for parameter 'ab' out of range
[NULL @ 0x7f372b254be0] Value 4705844345939427328.000000 for parameter 'bt' out of range
[NULL @ 0x7f372b254be0] Value 4617315517961601024.000000 for parameter 'me_method' out of range
[NULL @ 0x7f372b254be0] Value 4622945017495814144.000000 for parameter 'g' out of range
[NULL @ 0x7f372b254be0] Value 4611686018427387904.000000 for parameter 'qmin' out of range
[NULL @ 0x7f372b254be0] Value 4629418941960159232.000000 for parameter 'qmax' out of range
[NULL @ 0x7f372b254be0] Value 4613937818241073152.000000 for parameter 'qdiff' out of range
[NULL @ 0x7f372b254be0] Value -4616189618054758400.000000 for parameter 'wpredp' out of range
[NULL @ 0x7f372b254be0] Value 4607182418800017408.000000 for parameter 'bug' out of range
[NULL @ 0x7f372b254be0] Value 4607182418800017408.000000 for parameter 'er' out of range
[NULL @ 0x7f372b254be0] Value 4607182418800017408.000000 for parameter 'err_detect' out of range
[NULL @ 0x7f372b254be0] Value 4613937818241073152.000000 for parameter 'ec' out of range
[NULL @ 0x7f372b254be0] Value 4620693217682128896.000000 for parameter 'ildctcmp' out of range
[NULL @ 0x7f372b254be0] Value 4620693217682128896.000000 for parameter 'subq' out of range
[NULL @ 0x7f372b254be0] Value 4696837138094751744.000000 for parameter 'ibias' out of range
[NULL @ 0x7f372b254be0] Value 4696837138094751744.000000 for parameter 'pbias' out of range
[NULL @ 0x7f372b254be0] Value 4642507528377204736.000000 for parameter 'lmin' out of range
[NULL @ 0x7f372b254be0] Value 4660262442142531584.000000 for parameter 'lmax' out of range
[NULL @ 0x7f372b254be0] Value 4696130710463840256.000000 for parameter 'flags2' out of range
[NULL @ 0x7f372b254be0] Value 4607182418800017408.000000 for parameter 'threads' out of range
[NULL @ 0x7f372b254be0] Value 4620693217682128896.000000 for parameter 'nssew' out of range
[NULL @ 0x7f372b254be0] Value -4586705114244317184.000000 for parameter 'profile' out of range
[NULL @ 0x7f372b254be0] Value -4586705114244317184.000000 for parameter 'level' out of range
[NULL @ 0x7f372b254be0] Value 4623507967449235456.000000 for parameter 'skipcmp' out of range
[NULL @ 0x7f372b254be0] Value 4642507528377204736.000000 for parameter 'mblmin' out of range
[NULL @ 0x7f372b254be0] Value 4660262442142531584.000000 for parameter 'mblmax' out of range
[NULL @ 0x7f372b254be0] Value 4643211215818981376.000000 for parameter 'mepc' out of range
[NULL @ 0x7f372b254be0] Value 4607182418800017408.000000 for parameter 'bidir_refine' out of range
[NULL @ 0x7f372b254be0] Value -4616189618054758400.000000 for parameter 'cqp' out of range
[NULL @ 0x7f372b254be0] Value 4627730092099895296.000000 for parameter 'keyint_min' out of range
[NULL @ 0x7f372b254be0] Value 4607182418800017408.000000 for parameter 'refs' out of range
[NULL @ 0x7f372b254be0] Value -4616189618054758400.000000 for parameter 'directpred' out of range
[NULL @ 0x7f372b254be0] Value 4618441417868443648.000000 for parameter 'sc_factor' out of range
[NULL @ 0x7f372b254be0] Value 4643211215818981376.000000 for parameter 'mv0_threshold' out of range
[NULL @ 0x7f372b254be0] Value 4630826316843712512.000000 for parameter 'b_sensitivity' out of range
[NULL @ 0x7f372b254be0] Value -4616189618054758400.000000 for para[Mon Feb 10 19:21:43 2014] [error] child died with signal 11

If you remove the getTitle() and getArtist() methods, it works. Maybe someone faced such a problem?
The actual code
public static function getFileInfo($file) {
        if(!is_file($file)) {
            return false;
        }
        $mime = (new \FInfo)->file($file, FILEINFO_MIME_TYPE);
        $return = ['info' => [], 'type' => $mime];
        if(in_array($mime, ['image/jpeg', 'image/png', 'image/gif'])) {
            $image = new \Gmagick($file);
            $return['info']['resolution'] = implode('x', $image->getImageGeometry());
            $return['image'] = $image;
        }
        if(in_array($mime, ['audio/mpeg', 'audio/mp4', 'video/mpeg', 'video/mp4', 'video/x-flv', 'video/webm', 'video/x-ms-wmv', 'video/3gpp'])) {
            $ffmpeg = new \FFMpeg_Movie($file, false);
            if(!$ffmpeg) {
                return $return;
            }
            if(in_array($mime, ['audio/mpeg', 'audio/mp4'])) {
                empty($ffmpeg->getArtist()) ?: $return['info']['artist'] = htmlspecialchars($ffmpeg->getArtist(), ENT_QUOTES, 'UTF-8');
                empty($ffmpeg->getTitle()) ?: $return['info']['title'] = htmlspecialchars($ffmpeg->getTitle(), ENT_QUOTES, 'UTF-8');
                empty($ffmpeg->getAudioBitRate()) ?: $return['info']['bitRate'] = round($ffmpeg->getAudioBitRate() / 1000).' kbps';
                empty($ffmpeg->getDuration()) ?: $return['info']['duration'] = gmdate('i:s', $ffmpeg->getDuration());

            }
            if(in_array($mime, ['video/mpeg', 'video/mp4', 'video/x-flv', 'video/webm', 'video/x-ms-wmv', 'video/3gpp'])) {
                empty($frame = $ffmpeg->getFrame(round($ffmpeg->getFrameCount() / 2))) ?: $return['frame'] = $frame->toGDImage();
                empty($ffmpeg->getFrameHeight()) ?: $return['info']['resolution'] =  $ffmpeg->getFrameHeight().'x'.$ffmpeg->getFrameWidth();
                empty($ffmpeg->getDuration()) ?: $return['info']['duration'] = gmdate('i:s', $ffmpeg->getDuration());
            }
        }

        return $return;
    }

OS: CentOS 6
PHP: 5.5.8
FFMpeg-php: 0.7.0

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stepan, 2014-02-10
@L3n1n

I don't recommend using ffmpeg-php at all. There are only glitches with him.
For audio, change to getid3.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question