PHP使用ffmpeg给视频增加字幕显示的方法
发布时间:2020-12-13 02:28:03 所属栏目:PHP教程 来源:网络整理
导读:《PHP实例:PHP使用ffmpeg给视频增加字幕显示的方法》要点: 本文介绍了PHP实例:PHP使用ffmpeg给视频增加字幕显示的方法,希望对您有用。如果有疑问,可以联系我们。 PHP实战 本篇章节讲解PHP使用ffmpeg给视频增加字幕显示的办法.供大家参考研究.具
《PHP实例:PHP使用ffmpeg给视频增加字幕显示的方法》要点: PHP实战本篇章节讲解PHP使用ffmpeg给视频增加字幕显示的办法.分享给大家供大家参考.具体实现办法如下:
代码如下:
<?php $dir = './'; // set to current folder if ($handle = opendir($dir)) { ?while(false!== ($file = readdir($handle))) { ?if ( is_file($dir.$file) ){ ?if (preg_match("'.(avi)$'",$file) ){ ?$sub_file = str_ireplace(".avi",".srt",$dir.$file); ?$idx_file = str_ireplace(".avi",".idx",$dir.$file); ?$thumb_file = str_ireplace(".avi",".jpg",$dir.$file); ?$out_file = str_ireplace(".avi",".mp4",$dir.$file); ?flv_convert_get_thumb($dir.$file,$sub_file,$idx_file,$thumb_file,$out_file); ?} ?else{ ?continue; ?} ?} ?} ?closedir($handle); } //flv_convert_get_thumb('input.avi','input.srt','output.jpg','output.ogm'); // code provided and updated by steve of phpsnaps ! thanks // accepts: // 1: the input video file // 2: path to thumb jpg // 3: path to transcoded mpeg? function flv_convert_get_thumb($in,$in_sub,$in_idx,$out_thumb,$out_vid){ ?// get thumbnail ?$cmd = 'ffmpeg -v 0 -y -i '.$in.' -vframes 1 -ss 250 -vcodec mjpeg -f rawvideo -s 286x160 -aspect 16:9 '.$out_thumb; ?$res = shell_exec($cmd); ?// $res is the output of the command ?// transcode video $cmd = 'mencoder '.$in.' -o '.$out_vid.' -sub '.$in_sub.' -subfont-text-scale 3.0 -subpos 99 -af volume=10 -aspect 16:9 -of avi -noodml -ovc x264 -x264encop$ ?$res = shell_exec($cmd); } ?> PHP实战希望本文所述对大家的php程序设计有所赞助. 欢迎参与《PHP实例:PHP使用ffmpeg给视频增加字幕显示的方法》讨论,分享您的想法,编程之家 52php.cn为您提供专业教程。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |