我已经尝试了几周,以便在ffmpeg
上传视频时,弄清楚如何使用php
从视频中获取缩略图。
这是我的代码,我不会在哪里出错,请帮忙。
<?php
if (logged_in() === true) {
if (isset($_POST['up'], $_FILES['file'])) {
$file_name = $_FILES['file']['name'];
$file_type = explode('.', $file_name);
$file_type = strtolower(end($file_type));
$random = rand();
$file_tmp = $_FILES['file']['tmp_name'];
$file_dir = "jobalertme/includes/video_uploads/$random.$file_type";
if ($file_type == 'mp4' || $file_type == 'avi' || $file_type == 'wmv' || $file_type == 'mov' || $file_type == 'flv') {
if (move_uploaded_file($file_tmp, "$file_dir")) {
$ffmpeg = "C:\\ffmpeg\\bin\\ffmpeg";
$img_name = "1.jpg";
$img_size = "120x90";
$getimgsec = 5;
$cmd = "$ffmpeg -i $file_tmp -an -ss $getimgsec -s $img_size www/jobalertme/includes/img_thumnail/$img_name <br>";
if (shell_exec($cmd)) {
echo "ok";
} else {
echo "not";
}
$updat = "UPDATE registration SET video='$file_dir' WHERE uname='$username'";
$qry = mysqli_query($con, $updat);
if ($qry) {
echo "<script> alert('your file has been successfully uploaded ')</script>";
echo "<script>window.open('upload_vid.php','_self')</script>";
exit();
} else {
echo "<script> alert('we ran into some problems')</script>";
echo "<script>window.open('upload_vid.php','_self')</script>";
exit();
}
} else {
echo "<script> alert('we ran into some problems')</script>";
echo "<script>window.open('upload_vid.php','_self')</script>";
exit();
}
} else {
echo "<script>alert('please this file extension is not allowed, it must be an mp4 file format')</script>";
echo "<script>window.open('upload_vid.php','_self')</script>";
exit();
}
}
} else {
echo "<script>alert('please you need login before you can upload resume.')</scrpt>";
echo "<script>window.open('upload_vid.php','_self')</script>";
exit();
}
?>
我在google youtube和其他人上搜索过但仍然没有得到解决方案。