Uploading, Grabbing Thumbnail and Displaying Videos in real time using PHP.

wats the Best For Uploading, Grabbing Thumbnail and Displaying Videos in real time using PHP ?

Once a User Uploads a Video to a Forum or Site say Something Like Youtube,Want the Thumbnail to Captured & Displayed Once the Video is Uploaded by the User

Any Help on this ?
 
Sorry cant find my old code, here are the snippets you could use. you need few other things as well...I've listed it below.

make a form

PHP:
<form action="uploadvid.php" method="post" name="form1"><label>File</label><input name="file1" type="file" /><input name="upload" type="submit" value="Upload" />

</form><body>

Upload the file

PHP:
//uploadvid.php

$yourfolder = 'some/folder';

$yourfile = $yourfolder . basename($_FILES['file1']['name']);

if(move_uploaded_file($_FILES['file1']['tmp_name'], $yourfile)) {

    echo "Upload Successful...";

    

     $extn = explode(".", $_FILES['file1']['name']);

     $filename = extn[0];

     //convert uploaded vid to flv

    exec(/usr/local/bin/ffmpeg -i " . $yourfile . " -acodec mp3 -ar 22050 -ab 32 -f flv -s 320×240 -y " . $yourfolder  . $filename . ".flv");

    //200x150 screenshot

    exec("/usr/local/bin/ffmpeg -y -i " . $yourfolder  . $filename . ".flv" . " -f mjpeg -ss 2 -vframes 1 -s " . "200" ."x". "150" . " -an " . $yourfolder. $filename . ".jpg";);

    //code to display your screenshot and flv video using some video player

} 

else{

    die("Upload Failed");

}

You need to install ffmpeg and lame encoder. you can test basic things with ffmpeg, but there will be no audio without lame.

p.s. : ended up writing it all over again. its from the manual and am on windows right now so cant test. let me know if anything doesnt work.
 
heh, glad to be of help. I'm just a small fry :p

btw Geshi didnt do it right.

This...

PHP:
    exec(/usr/local/bin/ffmpeg -i " . $yourfile . " -acodec mp3 -ar 22050 -ab 32 -f flv -s 320x240 -y " . $yourfolder  . $filename . ".flv");

should be

exec(/usr/local/bin/ffmpeg -i " . $yourfile . " -acodec mp3 -ar 22050 -ab 32 -f flv -s 320x240 -y " . $yourfolder . $filename . ".flv");
 
Back
Top