Convert Video To Html5 Compatible Format (server Side)
Solution 1:
Yes, ffmpeg is the best solution, but you need to follow the next steps to make video working in all browsers:
1- Download the last version of ffmpeg from here ffmpeg download
2- Extract the content to a directory;
3- With PHP call the exe file to generate the mp4 and webm video format, like this:
exec(ffmpegdirectory/bin/ffmpeg.exe -i your_video_path -qscale 4 -vcodec libx264 -f mp4 your_new_video_path.mp4);
exec(ffmpegdirectory/bin/ffmpeg.exe -i your_video_path -b 1500k -vcodec libvpx -acodec libvorbis -ab 160000 -f webm -g 30 -s your_new_video_path.webm);
4- Allow in IIS(if it is your case) the Mime Types mp4 and webm
5- Use video.js to build the html5 video tag and call your two converted videos (mp4 and webm);
Note: if you don't use video.js, probably the video won't work in IE.
Solution 2:
Nice but your coding was a little off RED_ALERT user.
<?php
shell_exec("ffmpegdirectory/bin/ffmpeg.exe -i your_video_path -qscale 4 -vcodec libx264 -f mp4 your_new_video_path.mp4");
shell_exec("ffmpegdirectory/bin/ffmpeg.exe -i your_video_path -b 1500k -vcodec libvpx -acodec libvorbis -ab 160000 -f webm -g 30 -s your_new_video_path.webm");
?>
so basically your adding ffmpeg to a separate directory folder on your computer and not in wamp if you using wamp. You can than i'm assuming create a html document that srcs the video and shouldn't need video js. Of course you would need to know the path to the video and figure out a way to put the path from the msyql query into the php shell_exec command above.
Here is another example which converts a wmv video into a mp4 video.
<?php shell_exec("ffmpeg/bin/ffmpeg -i /myvideos/lionseatsham.wmv -s 500x400 -strict -2 /myvideo/lioneatshame.mp4 2>&1");
?>
Post a Comment for "Convert Video To Html5 Compatible Format (server Side)"