phpvideotoolkit-v2
phpvideotoolkit-v2 copied to clipboard
Undefined offset: 2 in FfmpegParserAbstract.php:819
My users got this issue. It seems happens to some specific format only:
#0 /library/PHPVideoToolkit/FfmpegParserAbstract.php(819): XenForo_Application::handlePhpError(8, 'Undefined offse...', '/...', 819, Array)
#1 [internal function]: PHPVideoToolkit\FfmpegParserAbstract->getCommands()
#2 //library/PHPVideoToolkit/FfmpegParser.php(83): call_user_func_array(Array, Array)
#3 /library/PHPVideoToolkit/Format.php(122): PHPVideoToolkit\FfmpegParser->__call('getCommands', Array)
#4 /library/PHPVideoToolkit/Format.php(122): PHPVideoToolkit\FfmpegParser->getCommands()
#5 /library/PHPVideoToolkit/AudioFormat.php(52): PHPVideoToolkit\Format->__construct('input', Object(PHPVideoToolkit\Config))
#6 b/library/PHPVideoToolkit/VideoFormat.php(61): PHPVideoToolkit\AudioFormat->__construct('input', Object(PHPVideoToolkit\Config))
#7 /library/PHPVideoToolkit/Media.php(226): PHPVideoToolkit\VideoFormat->__construct('input', Object(PHPVideoToolkit\Config))
#8 /library/PHPVideoToolkit/Media.php(188): PHPVideoToolkit\Media->_getDefaultFormat('input', 'VideoFormat', NULL)
#9 /library/PHPVideoToolkit/Media.php(150): PHPVideoToolkit\Media->getDefaultFormat('input', NULL)
#10 /library/PHPVideoToolkit/Media.php(78): PHPVideoToolkit\Media->setInputFormat(NULL)
#11 /library/PHPVideoToolkit/Video.php(35): PHPVideoToolkit\Media->__construct('/tmp/phpuIYSkD', Object(PHPVideoToolkit\Config), NULL)
It happens if the command contains the data type, for instance this command:
[241] => Array ( [0] => -color_trc <int> EDV.. [1] => color_trc [2] => <int> [3] => EDV.. )
Therefore, below code will detect the int type:
if(preg_match_all('/(?:\s+<(int|string|binary|flags|int64|float|rational)>)/', $match[2], $data_type_matches) > 0) { $data_type = trim($data_type_matches[2]); }
but $data_type_matches should include 1 element only which is the type of data. I suppose it should be $data_type_matches[0] instead of $data_type_matches[2]?
I have created a pull request here: https://github.com/buggedcom/phpvideotoolkit-v2/pull/60
I was wrong in above pull request, since this is preg_match_all, it should be $data_type_matches[1][0]. I have created another pull request https://github.com/buggedcom/phpvideotoolkit-v2/pull/62
Just for reference, this is an example of return data for above preg:
Array
(
[0] => Array
(
[0] => <int>
)
[1] => Array
(
[0] => int
)
)