PHP通过ffmpeg给视频增加字幕显示

WBOY
풀어 주다: 2016-07-25 08:42:36
원래의
840명이 탐색했습니다.
  1. $dir = './'; // set to current folder
  2. if ($handle = opendir($dir)) {
  3. while(false!== ($file = readdir($handle))) {
  4. if ( is_file($dir.$file) ){
  5. if (preg_match("'\.(avi)$'", $file) ){
  6. $sub_file = str_ireplace(".avi", ".srt", $dir.$file);
  7. $idx_file = str_ireplace(".avi", ".idx", $dir.$file);
  8. $thumb_file = str_ireplace(".avi", ".jpg", $dir.$file);
  9. $out_file = str_ireplace(".avi", ".mp4", $dir.$file);
  10. flv_convert_get_thumb($dir.$file, $sub_file, $idx_file, $thumb_file, $out_file);
  11. }
  12. else{
  13. continue;
  14. }
  15. }
  16. }
  17. closedir($handle);
  18. }
  19. //flv_convert_get_thumb('input.avi', 'input.srt', 'output.jpg', 'output.ogm');
  20. // code provided and updated by steve of phpsnaps ! thanks
  21. // accepts:
  22. // 1: the input video file
  23. // 2: path to thumb jpg
  24. // 3: path to transcoded mpeg?
  25. function flv_convert_get_thumb($in, $in_sub, $in_idx, $out_thumb, $out_vid){
  26. // get thumbnail
  27. $cmd = 'ffmpeg -v 0 -y -i '.$in.' -vframes 1 -ss 250 -vcodec mjpeg -f rawvideo -s 286x160 -aspect 16:9 '.$out_thumb;
  28. $res = shell_exec($cmd);
  29. // $res is the output of the command
  30. // transcode video
  31. $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$
  32. $res = shell_exec($cmd);
  33. }
  34. ?>
复制代码

PHP, ffmpeg


원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!