PHP uses FFmpeg to add text captions to the video,
This article mainly introduces the use of PHP ffmpeg video to increase the caption display method, an example of the PHP operation FFmpeg to the video to increase the letter of the skills, with a certain reference value, the need for friends can refer to.
The example in this paper describes how PHP uses FFmpeg to add captions to video. Share to everyone for your reference. The implementation method is as follows:
<?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. '-subfon T-text-scale 3.0-subpos 99-af volume=10-aspect 16:9-of avi-noodml-ovc x264-x264encop$ $res = shell_exec ($cmd); }?>
Above this PHP use FFmpeg to add text subtitles to the video is the small part of the whole content to share to everyone, I hope to give you a reference, but also hope that we have a lot of support to help guests home.
http://www.bkjia.com/PHPjc/1133096.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133096.html techarticle PHP using FFmpeg to add text captions to the video implementation method, this article mainly introduces the use of PHP ffmpeg to video to increase the caption display method, example analysis of PHP operation FFmpeg to video ...