使用ffmpeg将视频集变量$ process转换为1

时间:2017-09-20 10:43:35

标签: php ffmpeg codeigniter-3

在此视频中转换并上传到服务器和DB,转换过程中我想将一个变量“$ process”设置为1.我想上传到DB并在转换完成后$ success变量变为1.如何这样做。

conversion.php

echo "I am in conversion process -----";
exec("/usr/bin/ffmpeg -i ".$path." -vcodec libx264 ".$path_str."> /dev/null 2>&1 &");  
$convertedFile = basename($path_str);

echo "I am in conversion process2 -----";

exec('/usr/bin/ffmpeg -i '.$path.' 2>&1', $path_str,$return);

$sql = "INSERT INTO upload (convertedFile,uploadedFile,videoLength,thumbnail,userId,status)   VALUES('$convertedFile','$filename','$length','$thumb','$userId','$return')";
mysql_query($sql) or die("Error in Query: " . mysql_error());
$sql = "select * from conversion where uploadedFile='$convertedFile'";
$result = mysql_query($sql);
$success = ($return == 1)?1:0;
$error   = ($return == 0)?1:0;
if(!$result){ 
    $q = "UPDATE conversion  SET success = '$success' , error = '$error' WHERE uploadedFile = '$convertedFile'"; 
}
else {
 $q = "INSERT INTO conversion (uploadedFile,process,error,success)   VALUES('$convertedFile','0','$error','$success')";
}
mysql_query($q) or die("Error in Query: " . mysql_error());

1 个答案:

答案 0 :(得分:1)

回声"我正处于转换过程中-----&#34 ;;

//在流程开始之前插入

$q = "INSERT INTO conversion (process) VALUES ('0')";

//执行插入查询

 $lastid = mysqli_insert_id($q);

删除其他部分并更改更新查询

//在流程完成后更新值

$q = "UPDATE conversion  SET success = '$success' , error = '$error', uploadedFile = '$convertedFile' where id='$lastid'";