2015-11-10 46 views
-1

我有視頻模板,我想動態改變視頻內容。試圖用ffmpeg做,但我不知道如何做到這一點。這可以做到嗎?如果是的話,它可以做什麼?用ffmepg動態改變視頻文本/內容

我試着添加文本形式的文本文件,但無法弄清楚誰在某些特定的時間/幀添加文本。

回答

0

我找到了問題的答案,它是一個php解決方案。

function videoConversion($videoId, $batchId){ 
$font_path = "/var/www/html/james/LeagueGothic-Regular.otf";//path of the fonts 
$ffmpeg_path = "/usr/local/bin/ffmpeg";//path of the ffmpeg 
$this->input_video = "/home/ec2-user/crmvid/original_videos/sept.mp4";//path of the sample video file 
$this->output_video = "/var/www/html/james/final/test.mp4";//path of final output video 
/* ---------code for write file -----------*/ 
$commandFile = '/var/www/html/james/newvideo/command/test.cmd';//path of the command file, where we write commands of video writing. 
$fo = fopen($commandFile, "w"); 
fwrite($fo,"0.7-1.5 [enter] drawtext reinit 'fontfile=$font_path:text='Parineet':fontsize=117:fontcolor=indigo:x=480:y=315', 
[leave] drawtext reinit 'fontfile=Cousine-Bold.ttf:text=';\n"); 
fwrite($fo,"9.5-14.2 [enter] drawtext reinit 'fontfile=$font_path:text='Chauhan':fontsize=56:fontcolor=black:x='300':y=280', 
[leave] drawtext reinit 'fontfile=Cousine-Bold.ttf:text=';\n"); 
fwrite($fo,"14.5-17.8 [enter] drawtext reinit 'fontfile=$font_path:text='Chauhan':fontsize=72:fontcolor=indigo:x='150':y=330', 
[leave] drawtext reinit 'fontfile=Cousine-Bold.ttf:text=';\n"); 
fclose($fo); 
chmod($commandFile, 0755); 
/* ---------end code for write file -------*/ 
$p = $commandFile; 
shell_exec("$ffmpeg_path -y -i $this->input_video -vf sendcmd=f=$p,drawtext=fontfile=$font_path:text='' -vcodec h264 -acodec aac -strict -2 $this->output_video"); 
chmod($this->output_video, 0755); 
return $this->output_video; 
}