Hi Geeks,
This Article is based on
Images to Video making php script using FFMPEG
, So I am providing you the complete steps to setup the FFMPEG in windows and linux environment.
FFMPEG is very good Extension for php where we can process many type of operations on audio and video like
Images to video convert ,images and audio to video ,Generate Thumbnail file from video. So I have tried it on my windows system .
Steps to install FFMPEG on windows or localhost:
Step 1: Download the Static build for windows from following page
http://ffmpeg.zeranoe.com/builds/
there will be a button for download as in the screenshot
Step 2: Install prerequisite extensions
Before making any php script please make available the GD2 Library from your php.ini by just uncommenting following lines(removing semicolons from start of these lines
;extension=php_gd.dll
;extension=php_gd2.dll
Step 3: Extract the downloaded zip and Inside Bin folder you will find ffmpeg.exe
Copy that file in your project folder in htdocs Eg: slideshow_project
Now we have all images which we need to convert into video are in any folder of this projects like Images:
there should be pattern of images name like pic1.jpg,pic2.jpg as so on…
Step 4: write and execute a command for images to video conversion, following is the command
$command1="ffmpeg -f image2 -r 1/1 -i images/pic%d.jpg -vf fps=25 test1.mp4"; //command for every 1 second image change in video exec($command1);
above command is useful with creating a slideshow video where 2 second images will change and if you want to increase slide change duration for 3 second then you need to replace 1/1 to 1/3 from above command.
Now if you want to mix audio along with images then following command will work
$command2="ffmpeg -f image2 -r 1/5 -i images/pic%d.jpg -i audio/my_recording.mp3 -vf fps=25 test2.mp4"; //command for every 5 second image change in video along with my_recording.mp3 playing in background exec($command2);
Assuming you have my_recording.mp3 in audio folder of project
Installing FFMPEG in linux servers by following command
sudo apt-get install ffmpeg
In that case you don’t need to follow Step 1 and Step 3
If you are having any problem then please put your comments below , I would love to help you