我正在开发一个让用户将视频文件上传到服务器的学校项目。服务器将使用ffmpeg压缩视频并将文件存储在上传文件夹中。其他用户将能够流式传输上传的视频。PHP将视频文件上传到数据库
我的问题是我如何检索ffmpeg生成的视频并将链接存储在数据库中?
我使用此代码,但它只检索原始视频的路径。 upload.php的的
$filePath = dirname(__FILE__);
部分代码
$target_dir = "upload/"; //where you want to upload the files to
$target_file = $target_dir.basename($_FILES['file']['name']);
$fileType = pathinfo($target_file, PATHINFO_EXTENSION);
$newFileName = $target_dir.sha1(pathinfo(basename($_FILES['file']['name']), PATHINFO_FILENAME)).'-'.time().'.'.$fileType;
move_uploaded_file($_FILES['file']['tmp_name'], $newFileName);
$unique_id = rand(1000000,9999999);
shell_exec("C:\\ffmpeg\\bin\\ffmpeg.exe -i ".$newFileName." -vcodec libx264 -crf 20 \"upload\\{$newFileName}\" > logfile.txt 2>&1");
/// save information into database
$username = "root";
$password = "";
$hostname = "localhost";
$dbname = "test_database";
//connect to the database
$dbc = mysqli_connect($hostname, $username, $password, $dbname) or die ("could not connect to the database");
//execute the SQL query and return records
$result = mysqli_query($dbc, "INSERT INTO `viewvideo` (`vID`, 'video_id`, `video_link`) VALUES ('', '".$unique_id."', '".$newFileName."')");
if(!$result){echo mysqli_error($dbc); }
echo $result;
/*
declare in the order variable
$result = mysqli_query($dbc, $sql); //order executes
if($result){
echo("
Input data is succeed");
} else{
echo("
Input data is fail");
}
*/
//close the connection
mysqli_close($dbc);
输出
+0
看看这里的错误***它告诉你一切的起点,你***有失踪蜱'\''的' video_id'列。 –