I have installed FFmpeg video converter in XAMMP server, when i upload the video the video is not changed.it is not changed to webm format. check my code and guide me write way. the video is moving to video directory but it is not changing to webm.
<html>
<head>
<title>Video Uploader</title>
<link rel="stylesheet" type="text/css" href="../css/fluid_grid.css" />
</head>
<body>
<div class="container_12">
<div> </div>
<div class="grid_12"><h1>Upload Videos</h1></div>
<div> </div>
<div class="grid_3"><a href="display.php">Display Video</a></div>
<div class="grid_6">
<?php
if(isset($file_uploaded))
{
if($done)
{
echo '<font color="green">'.$done.'</font>';
}
else if($error)
{
echo '<font color="red">'.$error.'</font>';
}
echo '<br /><br />';
}
?>
<form name="form1" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onSubmit="return submitForm();">
<input name="uploadedfile" type="file" />
<input type="submit" name="submit" value="Submit">
</form></div>
<div class="grid_3"> </div>
</div>
</body>
</html>
<?php
function checkfile($input)
{
$ext = array('mpg', 'wma', 'mov', 'flv', 'mp4', 'avi', 'qt', 'wmv', 'rm');
$extfile = substr($input['name'],-4);
$extfile = explode('.',$extfile);
$good = array();
$extfile = $extfile[1];
if(in_array($extfile, $ext))
{
$good['safe'] = true;
$good['ext'] = $extfile;
}
else
{
$good['safe'] = false;
}
return $good;
}
if($_POST && array_key_exists("uploadedfile", $_FILES))
{
$error = '';
$upload_dir = "uploads/videos/";
$img_dir = "uploads/images/";
$webm_dir = "uploads/webm_files/";
$target=basename($_FILES['uploadedfile']['name']);
$target_path = $upload_dir . $target;
$safe_file = checkfile($_FILES['uploadedfile']);
if($safe_file['safe'] == 1)
{
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
{
$base = basename($target_path, $safe_file['ext']);
$new_webm=$base.'webm';
$new_webm=$webm_dir.$new_webm;
$new_image = $base.'jpg';
$new_image_path = $img_dir.$new_image;
exec('ffmpeg -i '.$target_path.' -acodec libvorbis -ac 2 -ab 96k -ar 44100 -b 345k -s 640x360 '.$new_webm.'');
exec('ffmpeg -i '.$target_path.' -f mjpeg -vframes 1 -s 150x150 -an '.$new_image_path.'');
$done = 'File uploaded successfully';
}
else
{
$error.= "Possible file upload attack!\n";
$error.=print_r($_FILES);
}
}
else
{
$error.= 'Invalid File Type Please Try Again. You file must be of type .mpg, .wma, .mov, .flv, .mp4, .avi, .qt, .wmv, .rm';
}
$file_uploaded = true;
}
?>
Here is display.php
<html>
<head>
<title>Video Uploader</title>
<link rel="stylesheet" type="text/css" href="../css/fluid_grid.css" />
</head>
<body>
<div class="container_12">
<div> </div>
<div class="grid_12"><h1>Upload Videos</h1></div>
<div> </div>
<div class="grid_3"><a href="index.php">Upload Video</a></div>
<div class="grid_6">
<?php
$directory = "uploads/webm_files/";
get all image files with a .jpg extension.
$webm = glob($directory . "*.webm");
foreach($webm as $webm)
{
?>
<video width="320" height="240" controls>
<source src="<?php echo $webm;?>" type="video/webm" />
</video>
<div> </div>
<?php
}
?>
</div>
<div class="grid_3"> </div>
</div>
</body>
</html>