goheadtry
11-25-2007, 09:09 PM
I am having trouble figuring out what is wrong with my script I can't figure it out because it does not give me an error. but the script does not work correctly
The paths I use are
/home/forbushj/ which is the root of my hosting account
/home/forbushj/public_html/ which is the root of my website
/home/forbushj/www/ which is the same as public_html
<?php
if(count($_POST) <1){
//show the form
if(isset($_GET['error'])){
if($_GET['error'] == "nofile"){
$if_error="Please choose a file to upload.";
}elseif($_GET['error'] == "notvid"){
$if_error="The file you selected is not a video.";
}elseif($_GET['error'] == "couldnotupload"){
$if_error="Your file could not be uploaded.";
}elseif($_GET['error'] == "noconvert"){
$if_error="We're sorry, but your video could not be converted for some reason.";
}
}else{
$if_error="";
}
echo "";
}else{
//do the processing
function is_video( $f ){
$result = trim ( exec ('file -bi ' . escapeshellarg ( $f ) ) ) ;
$TYPE = explode("/", $result);
if($TYPE[0] == "video"){
return TRUE;
}
else{
return FALSE;
}
if($_FILES['ufile']['name'] == ""){
header("location: {$_SERVER['PHP_SELF']}?error=nofile");
exit();
}
if(!is_video($_FILES['ufile']['name'])){
header("location: {$_SERVER['PHP_SELF']}?error=notvid");
exit();
}
if(!move_uploaded_file($_FILES['ufile']['tmp_name'],$_SERVER['DOCUMENT_ROOT']."/uploadvidd/".$_FILES['ufile']['name'])){
header("location: {$_SERVER['PHP_SELF']}?error=couldnotupload");
exit();
}
$ffmpeg = '/usr/bin/ffmpeg';//location of ffmpeg binary
$bitrate = '32';//bitrate for audio options are 16,32,64
$ext = '.flv';//Extension of output video files
$extb = '.jpg';//Extension of image
$vidsize = '320x240'; //video size
$imgsize = '150x100';//image size for menu
$force = 'flv';//Force video format to
$sstime = '00:00:35';//time to take screenshot
$samprate ='22050'; // Sample rate choices are as follows 11025, 22050, 44100)
//Converts uploaded video with FFmpeg binary
if(!exec('$ffmpeg -i /home/forbushj/public_html/uploadvidd/'.$vidIN.' -ar $samprate -ab $bitrate -f flv -s $vidsize /home/forbushj/public_html/vidd/'.$vidout.'.$ext.') || !exec('$ffmpeg -i /home/forbushj/public_html/vidd/'.$vidout.''.$ext.' -s $imgsize -an -ss $sstime -an -r 1 -vframes 1 -y -f image2 /home/forbushj/public_html/pic/video/'.$vidout.'.$extb.')){
header("location: {$_SERVER['PHP_SELF']}?error=noconvert");
exit();
}
//write to mysql
$linkID = @mysql_connect("localhost","dsf_sdf","jdfsdf") or die("Could not connect to MySQL server");
@mysql_select_db("forbushj_onetest") or die("Could not select database");
// Retrieve the posted product information.
$titlev = stripslashes($_POST['vidname']);
$descrv = stripslashes($_POST['viddes']);
$srcv = stripslashes($_POST['srcof']);
if($query=mysql_query("INSERT INTO video(`title`,`descr`,`pic`,`locat`,`src`) VALUES ('" . mysql_real_escape_string($titlev) . "','" . mysql_real_escape_string($descrv) . "','" . mysql_real_escape_string($output) . ".jpg','" . mysql_real_escape_string($output) . ".flv','" . mysql_real_escape_string($srcv) . "')")){
echo "Successfully uploaded and converted your file."
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="http://www.technologyforever.com/zzupload.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<label>
<input name="vidname" type="text" id="textfield" tabindex="1" />
</label>
vidname
<p>
<label>
<input type="text" name="srcof" id="srcof" tabindex="2" />
</label>
srcof</p>
<p>
<label>
<textarea name="viddes" id="viddes" cols="45" rows="5" tabindex="3"></textarea>
</label>
viddes</p>
<p>
<label>
<input name="ufile" type="file" id="ufile" tabindex="4" />
</label>
ufile</p>
<p>
<input name="button" type="submit" id="button" tabindex="5" value="Submit" />
</p>
</form>
</body>
</html>
This script makes use of ffmpeg
here is the documentation
http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
The paths I use are
/home/forbushj/ which is the root of my hosting account
/home/forbushj/public_html/ which is the root of my website
/home/forbushj/www/ which is the same as public_html
<?php
if(count($_POST) <1){
//show the form
if(isset($_GET['error'])){
if($_GET['error'] == "nofile"){
$if_error="Please choose a file to upload.";
}elseif($_GET['error'] == "notvid"){
$if_error="The file you selected is not a video.";
}elseif($_GET['error'] == "couldnotupload"){
$if_error="Your file could not be uploaded.";
}elseif($_GET['error'] == "noconvert"){
$if_error="We're sorry, but your video could not be converted for some reason.";
}
}else{
$if_error="";
}
echo "";
}else{
//do the processing
function is_video( $f ){
$result = trim ( exec ('file -bi ' . escapeshellarg ( $f ) ) ) ;
$TYPE = explode("/", $result);
if($TYPE[0] == "video"){
return TRUE;
}
else{
return FALSE;
}
if($_FILES['ufile']['name'] == ""){
header("location: {$_SERVER['PHP_SELF']}?error=nofile");
exit();
}
if(!is_video($_FILES['ufile']['name'])){
header("location: {$_SERVER['PHP_SELF']}?error=notvid");
exit();
}
if(!move_uploaded_file($_FILES['ufile']['tmp_name'],$_SERVER['DOCUMENT_ROOT']."/uploadvidd/".$_FILES['ufile']['name'])){
header("location: {$_SERVER['PHP_SELF']}?error=couldnotupload");
exit();
}
$ffmpeg = '/usr/bin/ffmpeg';//location of ffmpeg binary
$bitrate = '32';//bitrate for audio options are 16,32,64
$ext = '.flv';//Extension of output video files
$extb = '.jpg';//Extension of image
$vidsize = '320x240'; //video size
$imgsize = '150x100';//image size for menu
$force = 'flv';//Force video format to
$sstime = '00:00:35';//time to take screenshot
$samprate ='22050'; // Sample rate choices are as follows 11025, 22050, 44100)
//Converts uploaded video with FFmpeg binary
if(!exec('$ffmpeg -i /home/forbushj/public_html/uploadvidd/'.$vidIN.' -ar $samprate -ab $bitrate -f flv -s $vidsize /home/forbushj/public_html/vidd/'.$vidout.'.$ext.') || !exec('$ffmpeg -i /home/forbushj/public_html/vidd/'.$vidout.''.$ext.' -s $imgsize -an -ss $sstime -an -r 1 -vframes 1 -y -f image2 /home/forbushj/public_html/pic/video/'.$vidout.'.$extb.')){
header("location: {$_SERVER['PHP_SELF']}?error=noconvert");
exit();
}
//write to mysql
$linkID = @mysql_connect("localhost","dsf_sdf","jdfsdf") or die("Could not connect to MySQL server");
@mysql_select_db("forbushj_onetest") or die("Could not select database");
// Retrieve the posted product information.
$titlev = stripslashes($_POST['vidname']);
$descrv = stripslashes($_POST['viddes']);
$srcv = stripslashes($_POST['srcof']);
if($query=mysql_query("INSERT INTO video(`title`,`descr`,`pic`,`locat`,`src`) VALUES ('" . mysql_real_escape_string($titlev) . "','" . mysql_real_escape_string($descrv) . "','" . mysql_real_escape_string($output) . ".jpg','" . mysql_real_escape_string($output) . ".flv','" . mysql_real_escape_string($srcv) . "')")){
echo "Successfully uploaded and converted your file."
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="http://www.technologyforever.com/zzupload.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<label>
<input name="vidname" type="text" id="textfield" tabindex="1" />
</label>
vidname
<p>
<label>
<input type="text" name="srcof" id="srcof" tabindex="2" />
</label>
srcof</p>
<p>
<label>
<textarea name="viddes" id="viddes" cols="45" rows="5" tabindex="3"></textarea>
</label>
viddes</p>
<p>
<label>
<input name="ufile" type="file" id="ufile" tabindex="4" />
</label>
ufile</p>
<p>
<input name="button" type="submit" id="button" tabindex="5" value="Submit" />
</p>
</form>
</body>
</html>
This script makes use of ffmpeg
here is the documentation
http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html