Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Write text on video

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 672
    Comment on it

    Here is the function that tells how to write text on any sample video:-

    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;
            }
    

    Also I attached two video file: 1) for sample video 2) output video

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: