PHP Library of Videos

Asked

Viewed 128 times

0

Is there a video library in PHP? To get data like time the video was watched, when paused, etc

1 answer

0

You can experience the getID3, download him into https://sourceforge.net/projects/getid3/files/getID3%28%29%201.x/

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 the ffmpeg and use combined with the shell_exec() PHP, example based on this answer https://stackoverflow.com/a/6251209/1518921:

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');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.