I have a page where it allows my users to upload their videos through an html5 file upload form and a PHP script that saves file in a folder on server. All works fine. But when it is displayed using video tag, it simply does not play ! I do get the player but file does not play.

Can this be a codec issue ? Because when I check the saved file with Gspot, it shows codec as mp4v. And I seem to have read somewhere that this needs to be something else. If my train of thought is right,then how do I ensure uploaded video files adhere to codec formats before being saved ?

I have furnished the code in the following question

http://stackoverflow.com/questions/24231108/uploaded-videos-do-not-play-with-video-tag

Been breaking my head for a long time. tried googling a lot. Ended nowhere. Any help at the earliest will be appreciated.

Well as you may know, HTML5 is still in progress and is not fully supported by by all the browsers. The same goes for the video tag and the formats of videos.
For Example:
FF >= 9, only WeBM and OGG are supported.
while,
Chrome >=17 supports Almost all formats(OGG, MP4, WebM)
Similar goes for other browsers as well.
Therefore the best solution today is to have flash as backup.
Or you can use this:

<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>

Hi guys, thank you for your answers. I am a newbie to media formats. But I seem to understand that in chrome only some h.264 MP4 works or something like that. My video MP4 file does not work in any browser and not even in Jwplayer ! Eitherways, do I understand correctly that I will need to convert the video to .ogg, .webm, flash and other formats and have them on standby for fallback in video tags every time a user uploads some video ?

Also could somebody check and tell me if anything is wrong with the video file itself here http://www.p4uentertainment.com/portfolios/Video4.mp4 ?

Hi guys, thank you for your answers. I am a newbie to media formats. But I seem to understand that in chrome only some h.264 MP4 works or something like that. My video MP4 file does not work in any browser and not even in Jwplayer ! Eitherways, do I understand correctly that I will need to convert the video to .ogg, .webm, flash and other formats and have them on standby for fallback in video tags every time a user uploads some video ?

Also could somebody check and tell me if anything is wrong with the video file itself here http://www.p4uentertainment.com/portfolios/Video4.mp4 ?

it says, video file is corrupt.

For now, stay away from those html5 player and use jwplayer or flow player. These are the standard player of the web. Both players are capable of flash fallback.

To be able to convert video files to ogg, webm, flash, h264, and others, you will need to have ffmpegPHP installed on your server. Tell your host you need ffmpegPHP, mencoder, flvtool2, mp4box installed on your server.

Thanks a ton for answering, veedeoo.

The file is playing in Windows Media Player on my laptop. I did try playing it with JW player too. Didnt work.

Does Jwplayer or flow player play all kinds of files ? Or will I have to convert user uploaded files to other formats for it to play on these players too ?

Also will I have to code my upload.php to automatically convert all videos uploaded by users into those formats ?

Thanks a ton again in advance.

I think it is the best option to encode them to either .h264/MP4 or flv files. If you have an ffmpegPHP, mencoder, flvtool2, mp4box installed on your server you are good to go.

Ok ..i think i am getting it...let me try. Thanks again :)

Vedeoo, could you possibly show few lines of php code that uses these to convert files ?

Hi,
Actually our designers use iframe tag for playing the video in the website. They consider the youtube links.

Hi Hemanth,

I too use iframe and show our videosalraedy uploaded to youtube.

I need to display user uploaded videos which I need to store on our server.

But I guess it is better to use youtube api to autopost to youtube and capture the link to display on our site via iframe instead of the headache of the various video type issues !

sure why not, but before doing that, we need to find out if you have the ffmpegPHP installed on your server.

There are other ways of testing the ffmpegPHP installation and one of them is like this.

<?php


    $video_file = 'uploads/yourvideo.extension';

    ## we create an instance of the ffmpeg movie object

    $veedeoo = new ffmpeg_movie($video_file);


    ## get the duration of the video. This is very important when creting thumbnails.

    echo 'Video Duration : '. $veedeoo->getDuration() .'<br/>';

    ## get the framerate which is the frame per seconds. There is no use of re-encoding a video at a higher fps than the actual fps of the source.
    echo 'Video FrameRate : '. $veedeoo->getFrameRate();

Define the video_file and direct your browser to this file. You should be viewing duration and framerate values.

Let me know...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.