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

WBOY
Freigeben: 2016-07-25 08:42:36
Original
841 Leute haben es durchsucht
  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


Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!