...">

PHP HTML5-compatible MP4 video using FFMPEG

Hi, I am using FFMPEG to convert downloaded video from PHP.

echo "conversion exercise started...<br/><br/>"; /* looping through all files in the directory */ if ($handle = opendir('assets/uploaded_videos')) { while (false !== ($entry = readdir($handle))) { /* filtering the desired extensions */ if ($entry != "." && $entry != ".." && in_array(substr($entry, strrpos($entry, '.')), array(".wmv", ".mpg", ".mpeg", ".flv", ".ogg", ".mp4"))) { $filename = substr($entry, 0, strrpos($entry, '.')); //$command = "ffmpeg -i assets/uploaded_videos/$entry -vcodec libx264 assetss/videos/$filename.mp4"; $command = "ffmpeg -i assets/uploaded_videos/$entry -vcodec mpeg4 -acodec libfaac files/videos/$filename.mp4"; echo $command."<br />"; shell_exec($command."> /dev/null 2>/dev/null &"); } } closedir($handle); } 

I included the player in a file like this:

 <video width="350" poster="<?php echo $first_video['thumb_path'];?>" controls> <source src="<?php echo $first_video['video_path']; ?>" /> <span id="silverlight_player_for_fallback"></span> </video> 

Now when I start IE10, the player gives me an invalid source error. I have a problem with libx264 and mpeg4 MP4 codecs.

Any ideas on what's going wrong?

Update

Following Ian's guidance, I finally earned it. I used a basic level3 profile with libx264 . You can provide additional options, but I believe that a profile is the key! I experimented with multiple profiles and noticed that all HTML5 videos on vimeo and youtube use this basic L3 profile.

Anyone struggling with MP4 can consider the following command for conversion:

 /* following command converted all my uploaded *.wmv files to mp4 */ $command = "ffmpeg -i files/uploaded_videos/$entry -vcodec libx264 -profile:v baseline -level 3 files/videos/$filename.mp4"; 
+4
source share
1 answer

Have you tested the generated MP4 file in other browsers (supporting MP4) such as Chrome and Safari? The first step is to make sure that the file is actually playing.

You can also save the generated MP4 and try dragging it in Chrome / Safari and then in IE10 (if another browser is working) to see if it can play. So you can try to figure out if this is the encoding that the problem is.

There are many different flavors (called profiles ) of MP4, not all can be played in browsers.

+4
source

All Articles