ffmpeg add or embed image into video using php on xampp or iis

April 14, 2015 No Comments Uncategorized Dinesh Belkare
  1. Download video_processing.zip 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 video processing.
  3. C:\>ffmpeg -i input.mp4 -i input.png -filter_complex "[0:v][1:v] overlay=100:100:enable='between(t,1,2)'"
  4. In the above code replace “ffmpeg” with absolute path (i.e C:\directory\ffmpeg).Also replace input.mp4,input.png and output.mp4 with their absolute path.Note- output.mp4 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\input.mp4 -i C:\directory\input.png -filter_complex "[0:v][1:v]
    overlay=100:100:enable='between(t,1,2)'" C:\directory\output.mp4
  6. Once you you run above command in windows cmd,you will get your output.mp4 with image added to it.
  7. In above code “overlay=100:100:enable=’between(t,1,2)” means image will be added at x=100px,y=100px and during time frame of 1 and 2 seconds of the original video.
  8. If you want to do this in PHP, you just have to put it in exec() function.i.e.
    exec(C:\directory\ffmpeg -i C:\directory\input.mp4 -i C:\directory\input.png -filter_complex "[0:v][1:v]
    overlay=100:100:enable='between(t,1,2)'" C:\directory\output.mp4)

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

Leave a reply

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