Jump to content

Convert video file to flv


chanchelkumar

Recommended Posts

Hi all,

 

i want to convert the video files to flv..

ie upload any type of files it converts this to flv...

 

i search a lot and find out that this happen only with support FFmpeg..

 

and i got it...

 

i got a code tooo.

 

the problem is now this code is converting files.. but it gives me empty file ..

 

there is no problem with images or audio files... only video files are having this problem

 

this is my code...

 

please help me.. it wil be grateful if any body give me a solution...

 

<?php ini_set( "max_execution_time", "3600" ); // sets the maximum execution time of this script to 1 hour. 
$fileName = $_FILES['message']['name']; // get client side file name 
if( $fileName ) { // Check File Type 
$fileNameParts = explode( ".", $fileName ); // seperate the name from the ext 
$fileExtension = end( $fileNameParts ); // part behind last dot 
$fileExtension = strtolower( $fileExtension ); // reduce to lower case 
if( !$fileExtension == "mp3" ) { die( "$fileName is not an mp3 file." ); } // Check File Size 
$fileSize = $_FILES['message']['size']; // size of uploaded file 
if( $fileSize == 0 ) { die( "Sorry. The upload of $fileName has failed. The file size is 0." ); } else if( $fileSize > 10240000 ) { //10 MB 
die( "Sorry. The file $fileName is larger than 10MB. Advice: reduce the file quality and upload again." ); } else { $uploadDir = '/home/yourdomain.com/httpdocs/audio/audio_to_encode/'; // Where the temp file will go 
$uploadFile = str_replace( " ", "", $uploadDir . $_FILES['message']['name'] ); // Get rid of spaces in the filename 
$finalDir = '/home/yourdomain.com/httpdocs/audio/flv_files/'; // Where the final file will go 
$finalFile = str_replace( " ", "", $finalDir . $fileNameParts[0] . ".flv" ); // Get rid of spaces in the filename 
if ( !move_uploaded_file( $_FILES['message']['tmp_name'], $uploadFile ) ) { echo "Possible file upload attack! Here's some debugging info:\n"; echo( $_FILES ); } $encode_cmd = "/usr/bin/ffmpeg -i $uploadFile -f flv -acodec mp3 -ab 64 -ac 1 -title \"Clip Title\" -author \"Clip Author\" -copyright \"Clip Copyright\" $finalFile"; exec( $encode_cmd ); unlink( $uploadFile ); chmod( $finalFile, 0644 ); } } ?>	

 

Thanks in advance!!!!!!!

 

Link to comment
https://forums.phpfreaks.com/topic/94900-convert-video-file-to-flv/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.