ffmpeg add or embed text into image on iis or xampp server

June 18, 2015
  1. Download video_processing.zip and dejavu-fonts-ttf.tar.bz2 and extract it.Note- copy both the files in your project directory.
  2. We are going to use php exec() function to execute commands related to image processing.
  3. C:\>ffmpeg -i inputimage.png -vf drawtext="fontfile=ttf\DejaVuSerif.ttf:
    text='Dinesh Belakare':fontsize=70:fontcolor=red:x=700:y=925" outputimage.png
  4. In the above code replace “ffmpeg” with absolute path (i.e C:\directory\ffmpeg).Also replace inputimage.png and outputimage.png with their absolute path.Note- outputimage.png is not present and will be generated after successful execution of the command,but we have to put it’s path in the command.
  5. Your command will look like this
    C:\>C:\directory\ffmpeg -i C:\directory\inputimage.png -vf drawtext="fontfile=
    C:\directory\ttf\DejaVuSerif.ttf: text='Dinesh Belakare':fontsize=70:
    fontcolor=red:x=700:y=925" C:\directory\outputimage.png
  6. Once you you run above command in windows cmd,you will get your outputimage.png with text added to it.
  7. If you want to do this in PHP, you just have to put it in exec() function.i.e.
    exec(C:\>C:\directory\ffmpeg -i C:\directory\inputimage.png -vf drawtext="fontfile=
    C:\directory\ttf\DejaVuSerif.ttf: text='Dinesh Belakare':fontsize=70:
    fontcolor=red:x=700:y=925" C:\directory\outputimage.png)

    Note- Please place quotes properly in the above command string while using for php.

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *