phphtmlvideoupload

get video and image dimension's on upload


is it possible to get the video dimensions from a video file? Im uploading mp4s and wmvs as well as some image files. I would like to grab the dimensions and make it part of the new filename. I know you can use getImageSize() for pictures, but how would I do the same for video? Is there a way to do this?


Solution

  • <?php require_once('getid3/getid3.php');
    $filename='uploads/4thofJuly_184.mp4';
    $getID3 = new getID3;
    $file = $getID3->analyze($filename);
    echo("Duration: ".$file['playtime_string'].
    " / Dimensions: ".$file['video']['resolution_x']." wide by ".$file['video']['resolution_y']." tall".
    " / Filesize: ".$file['filesize']." bytes<br />");
    $getID3 = new getID3;
    $filename='uploads/25PercentOff_710.wmv';
    $file = $getID3->analyze($filename);
    echo("Duration: ".$file['playtime_string'].
    " / Dimensions: ".$file['video']['resolution_x']." wide by ".$file['video']['resolution_y']." tall".
    " / Filesize: ".$file['filesize']." bytes<br />");
    
    // Calling getimagesize() function 
    $filename="uploads/25PercentOff_960.jpg";
    list($width, $height) = getimagesize($filename); 
    
    // Displaying dimensions of the image 
    echo "Width of image : " . $width . "<br>"; 
    
    echo "Height of image : " . $height . "<br>"; 
    ?>