Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert video to html5 compatible format (server side)

Tags:

html

video

I want to create a website that plays videos uploaded by the users in html5 video.

How can I convert any video type on server side to WebM, OGG or MP4?

Is FFmpeg the best solution? So far this is what I think, but I'd much rather find a simpler way.

like image 326
coiso Avatar asked Jan 03 '12 00:01

coiso


1 Answers

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.

like image 111
red_alert Avatar answered Oct 21 '22 05:10

red_alert