I’m trying to get video upload going using FFMPEG to convert the video to .FLV format.
The file in question is in my /multimedia directory, which is where ffmpeg and all other video related files are stored.
The output directory is a subdirectory of /multimedia, and is /flvs.
Here is the code snippet:
[php]
$createDate=date(“Y-m-d”);
$error = “”;
$videSize=$_FILES[‘mpeg_file’][‘size’];
if($videSize < 41943041) {
$fn=time().".flv";
$ffmpeg_format="";
if(strstr($_SERVER[‘SERVER_SOFTWARE’],“Win32”)) {
$ffmpeg_format = “ffmpeg.exe -y -i %s %s”;
} else {
$ffmpeg_format = “LD_LIBRARY_PATH=. ./ffmpeg -y -i %s %s > /dev/null 2>&1”;
}
$download_file = ‘’;
// form was submited, check if file was uploaded without errors
if ($_FILES[‘mpeg_file’][‘error’] === UPLOAD_ERR_OK) {
$ret_value = 0;
// prepare ffmpeg command
$ffmpeg_command = sprintf($ffmpeg_format, $_FILES[‘mpeg_file’][‘tmp_name’], “flvs/”.$fn);
//echo $ffmpeg_command;
if (system($ffmpeg_command, $ret_value) === FALSE || $ret_value != 0) {
// ffmpeg was failed
$error .= “ffmpeg failure”;
} else {
// ffmpeg successfully generated output
$download_file = “flvs/”.$fn;
}
} else {
$error .= ‘File upload error: ‘.$_FILES[‘mpeg_file’][‘error’].’ ‘;
}
//---------------INSERT VIDEO---------------//
$videoIns="INSERT INTO tbl_video (id, uid, video, video_name, video_status, video_date) VALUES(’’, ‘".$_SESSION[‘userid’]."’, ‘$fn’, ‘".$_REQUEST[‘v_name’]."’, ‘New’, ‘$createDate’)";
$db->query($videoIns);
$error.=“Upload successful, Your video has been sent for approval please allow up to 48 hours.”;
} else {
$error.=“Video size is greater than 40 MB.”;
}
[/php]
When I tested the video upload, it didn’t work, so I went back and added the .= for the $error so that I could see all of the output commands, tracked down that initially there was an UPLOAD_ERR_OK error for exceeding the upload_max_filesize variable. I went into php.ini and altered that, and that error message has gone away. As soon as I fixed the max filesize variable and ran another test, I then got the output from $error of “ffmpeg failure”. As a note, this is on a Linux server, not Windows.
Any suggestions would be appreciated, thank you in advance.
Robert