我的脚本使用旧代码来运行 ffmpeg,但是当我将 ffmpeg 更新为 ffmpeg 版本 N-94168 时,它停止了转换。我需要做哪些更改才能使这条线再次工作?
"$ffmpeg -y -i $input -acodec libfdk_aac -ar 44100 -ab 96k -coder ac $add_fmeful -me_range 16 -subq 5 -sc_threshold 40 -vcodec libx264 -s 1280x544 -b 1600k -cmp $chroma -partitions +parti4x4+partp8x8+partb8x8 -i_qfactor 0.71 -keyint_min 25 -b_strategy 1 -g 250 -r 20 $addpre $hdoutput"
更新这里有更完整的代码来提供更好的上下文。
include("include/config.php");
include("include/functions/import.php");
$original = $_SERVER['argv'][1];
$videoid = $_SERVER['argv'][2];
$videor = $_SERVER['argv'][3];
if (($original != "") && ($videoid != "") && ($videor != ""))
{
$mencoder = $config['mencoder'];
$ffmpeg = $config['ffmpeg'];
$input = $config['originalvdir']."/".$original;
$output = $config['videodir']."/".$videoid."x.flv";
$bitrate = $config['vbitrate'];
$mencoder_bitrate = $config['mencoder_bitrate'];
$vwidth = $config['vresize_x'];
$vheight = $config['vresize_y'];
$vwidthheight = $vwidth."x".$vheight;
$srate = $config['sbitrate'];
$resize_video = $config['resize_video'];
$reconvert_flv = $config['reconvert_flv'];
$save_mp4 = $config['save_mp4'];
$save_mov = $config['save_mov'];
$save_name = $config['videodir']."/".$original;
if($resize_video == "1")
{
$fresize = "-s $vwidthheight";
}
exec($mencoder, $mversion);
$mv = $mversion['0'];
if(strstr($mv, 'MEncoder 1.0rc1'))
{
$mver = "rc1";
}
elseif(!strstr($mv, 'MEncoder 1.0rc1'))
{
$mver = "rc2";
}
if ($mver == "rc1")
{
$lavfopts = "-lavfopts i_certify_that_my_video_stream_does_not_use_b_frames";
}
$vidext = strtolower(substr($original, strrpos($original, '.') + 1));
$vidext2 = substr($original, strrpos($original, '.') + 1);
$converted = "0";
$ofps = "";
if ($vidext == "wmv")
{
$runinbg = "$ffmpeg -i $input -ar 44100 -ab 128 -aspect 4:3 -b $bitrate -r 12 -f flv $fresize -acodec libmp3lame -ac 1 $output";
$runconvert = exec("$runinbg");
if (filesize($output) > 0 && file_exists($output))
{
$converted = "1";
}
else
{
$ofps = "-ofps 25000/1001";
}
}
elseif($vidext == "avi" || $vidext == "mpeg")
{
$runinbg = "$ffmpeg -i $input -ar 44100 -ab 128 -aspect 4:3 -b $bitrate -r 12 -f flv $fresize -acodec libmp3lame -ac 1 $output";
$runconvert = exec("$runinbg");
if (filesize($output) > 0 && file_exists($output))
{
$converted = "1";
}
}
elseif($vidext == "flv" && $reconvert_flv == "0")
{
copy ($input , $output);
if (filesize($output) > 0 && file_exists($output))
{
$converted = "1";
}
}
elseif($vidext == "flv" && $reconvert_flv == "1")
{
$runinbg = "$ffmpeg -i $input -ar 44100 -ab 128 -aspect 4:3 -b $bitrate -r 12 -f flv $fresize -acodec libmp3lame -ac 1 $output";
$runconvert = exec("$runinbg");
if (filesize($output) > 0 && file_exists($output))
{
$converted = "1";
}
}
else
{
$runinbg = "$ffmpeg -i $input -ar 44100 -ab 128 -aspect 4:3 -b $bitrate -r 12 -f flv $fresize -acodec libmp3lame -ac 1 $output";
$runconvert = exec("$runinbg");
if (filesize($output) > 0 && file_exists($output))
{
$converted = "1";
}
}
if ($converted == "0")
{
$fcbp = intval($config['cbp']);
if($fcbp == "0")
{
$cbp = "cbp";
}
elseif($fcbp == "1")
{
$cbp = "o=mpv_flags=+cbp_rd";
}
if($vidext != "avi")
{
$runinbg = "$mencoder $input -o $output -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=$mencoder_bitrate:mbd=2:mv0:trell:v4mv:".$cbp.":last_pred=3 $lavfopts -vf scale=$vwidth:$vheight -srate $srate $ofps";
$runconvert = exec("$runinbg /dev/null 2>&1");
if (filesize($output) > 0 && file_exists($output))
{
$converted = "1";
}
}
if (filesize($output) <= 0 || !file_exists($output))
{
$runinbg = "$mencoder $input -o $output -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=$mencoder_bitrate:mbd=2:mv0:trell:v4mv:".$cbp.":last_pred=3 $lavfopts -vop scale=$vwidth:$vheight -srate $srate $ofps";
$runconvert = exec("$runinbg /dev/null 2>&1");
if (filesize($output) > 0 && file_exists($output))
{
$converted = "1";
}
}
if (filesize($output) <= 0 || !file_exists($output))
{
$runinbg = "$mencoder $input -o $output -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=$mencoder_bitrate:mbd=2:mv0:trell:v4mv:".$cbp.":last_pred=3 -vf scale=$vwidth:$vheight -srate $srate $ofps";
$runconvert = exec("$runinbg /dev/null 2>&1");
if (filesize($output) > 0 && file_exists($output))
{
$converted = "1";
}
}
}
if ($converted == "1")
{
$scriptolutioninject = $config['scriptolutioninject'];
if($scriptolutioninject == "scriptolutionyamdi")
{
exec("$config[scriptolution_yamdi] -i $config[videodir]/".$videoid."x.flv -o $config[videodir]/".$videoid.".flv");
}
else
{
exec("$config[metainject] -Uv $config[videodir]/".$videoid."x.flv $config[videodir]/".$videoid.".flv");
}
@unlink("$config[videodir]/".$videoid."x.flv");
$flvff = "$config[videodir]/".$videoid.".flv";
rotation_video_to_frame($flvff, $videoid);
$HD = "0";
if(($vidext == "mp4" && $save_mp4 == "1") || ($vidext == "mov" && $save_mov == "1"))
{
copy ($input , $save_name);
if (filesize($save_name) > 0 && file_exists($save_name))
{
$query = "UPDATE videos SET HD='".mysql_real_escape_string($vidext2)."' WHERE VIDEOID='".mysql_real_escape_string($videoid)."'";
$conn->execute($query);
$HD = "1";
exec("$mp4box -inter 500 $save_name");
}
}
if($config['convert_hd'] == "1" && $HD == "0")
{
$hdoutput = $config['videodir']."/".$videoid.".mp4";
$preset = intval($config['preset']);
if($preset == "1")
{
$addpre = "-vpre normal";
}
elseif($preset == "2")
{
$addpre = "-vpre medium";
}
elseif($preset == "3")
{
$addpre = "-vpre hq";
}
$fchroma = intval($config['chroma']);
if($fchroma == "0")
{
$chroma = "+chroma";
}
elseif($fchroma == "1")
{
$chroma = "chroma";
}
if($config['ffmpeg_me_full'] == "1")
{
$add_fmeful = "-me full";
}
$runinbg = "$ffmpeg -y -i $input -acodec libfdk_aac -ar 44100 -ab 96k -coder ac $add_fmeful -me_range 16 -subq 5 -sc_threshold 40 -vcodec libx264 -s 1280x544 -b 1600k -cmp $chroma -partitions +parti4x4+partp8x8+partb8x8 -i_qfactor 0.71 -keyint_min 25 -b_strategy 1 -g 250 -r 20 $addpre $hdoutput";
$runconvert = exec("$runinbg");
if (filesize($hdoutput) > 0 && file_exists($hdoutput))
{
exec("$mp4box -inter 500 $hdoutput");
$query = "UPDATE videos SET HD='mp4' WHERE VIDEOID='".mysql_real_escape_string($videoid)."'";
$conn->execute($query);
}
}
if ($config['keep_original_video'] == "0")
{
if (filesize($config['videodir']."/".$videoid.".flv") > 0 && file_exists($config['videodir']."/".$videoid.".flv"))
{
$deletetempvideo = $config['originalvdir']."/".$original;
@chmod($deletetempvideo, 0777);
@unlink($deletetempvideo);
}
for($tt=1;$tt<11;$tt++)
{
$tempthumb = $config['tmpimgpath']."/".$videoid."/0000000".$tt.".jpg";
if(file_exists($tempthumb))
{
@unlink($tempthumb);
}
}
@rmdir($config['tmpimgpath']."/".$videoid);
}
$sendername = stripslashes(stripslashes($config['site_name']));
$from = $config['site_email'];
$query = "SELECT A.email,A.username,A.mail_vc,B.title FROM members A, videos B WHERE B.VIDEOID='".mysql_real_escape_string($videoid)."' AND B.USERID=A.USERID";
$executequery = $conn->execute($query);
$mail_vc = $executequery->fields['mail_vc'];
if($mail_vc == "1")
{
$sendtotemp = $executequery->fields['email'];
$tempusername = $executequery->fields['username'];
$temptitle = $executequery->fields['title'];
$subject = "$lang[99]";
$tempseotitle = seo_clean_titles_sendmail($temptitle);
$videolink = $config['baseurl']."/video/".$videoid."/".$tempseotitle;
$sendmailbody = "<html>";
$sendmailbody .= $tempusername.", <br><br>$lang[100]:<br>";
$sendmailbody .= "<a href=$videolink>$videolink</a><br><br>";
$sendmailbody .= "$lang[101],<br>";
$sendmailbody .= "$sendername";
$sendmailbody .= "</html>";
mailme($sendtotemp,$sendername,$from,$subject,$sendmailbody,$bcc="");
}
exec("$config[phppath] $config[basedir]/bgconversion_iphone.php $original $videoid $videor> /dev/null &");
}
//Multi-Server Module Begin
if($config['multiserver'] == "1")
{
if($config['multiactive'] != "1")
{
if($config['multiactive'] == "0")
{
$query="SELECT SID FROM servers WHERE accept='1' AND enabled='1' order by rand() limit 1";
$executequery=$conn->execute($query);
$SID = $executequery->fields['SID'];
}
else
{
$SID = $config['multiactive'];
}
if(is_numeric($SID) && $SID!="1" && $videoid!="" && is_numeric($videoid))
{
$query = "UPDATE videos SET TSID='".mysql_real_escape_string($SID)."' WHERE VIDEOID='".mysql_real_escape_string($videoid)."'";
$conn->execute($query);
$query = $conn->execute("select * from servers where SID='".mysql_real_escape_string($SID)."' limit 1");
$server = $query->getrows();
$fhost = $server[0]['host'];
$k = $server[0]['skey'];
$surl = $server[0]['url'];
$fusr = $server[0]['login'];
$fpwd = $server[0]['pass'];
$fport = $server[0]['port'];
$fpassive = $server[0]['passive'];
$fpath = $server[0]['path'];
$local_file = $videoid.".flv";
$s = base64_encode($videoid);
$skey = md5($k);
$last = $surl[strlen($surl)-1];
if($last == "/")
{
$surl = substr($surl, 0, -1);
}
$data = @file_get_contents("$surl/vdata/ms.php?m=$skey&s=$s");
if($vidext == "mp4" && $save_mp4 == "1")
{
$data = @file_get_contents("$surl/vdata/ms.php?m=$skey&s=$s&$mp4=$vidext2");
}
elseif($vidext == "mov" && $save_mov == "1")
{
$data = @file_get_contents("$surl/vdata/ms.php?m=$skey&s=$s&$mov=$vidext2");
}
}
}
}
//Multi-Server Module End
}