Is there any library of videos in PHP? To get data like time the video was watched, paused, etc.
Is there any library of videos in PHP? To get data like time the video was watched, paused, etc.
You can try getID3
, download it at link
require_once '<pasta aonde salvou o getid3>/getid3/getid3.php';
$filename = '<pasta aonde esta o video>/video.mp4';
$getID3 = new getID3;
$file = $getID3->analyze($filename);
echo 'Duração: ', $file['playtime_string'], PHP_EOL,
'Resolução: ', $file['video']['resolution_x'], 'x', $file['video']['resolution_y'], PHP_EOL,
'Bytes: ', $file['filesize'];
Or install ffmpeg and use combined with shell_exec()
of PHP, example based on this response link :
function getDuration($path) {
$response = shell_exec('ffmpeg -i ' . escapeshellarg($path) . ' 2>&1', $output);
$parseduration = '/duration.*?([0-9]{1,})/';
if (preg_match($parseduration, $response, $matches, PREG_OFFSET_CAPTURE, 3) > 0) {
return $matches[1][0];
}
}
echo 'Duração: ', getDuration('pasta/video.flv');