view.php

<html>
<head>
<title>Video Upload</title>
<link rel="stylesheet" href="styles.css" />
<link href="http://vjs.zencdn.net/4.0/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.0/video.js"></script>


</head>

<body>

<?php 
    include 'connect.php';
?>

<div id="box">
    <?php
        $video = $_GET['video'];
    ?>  

    <video id="my_video_1" class="video-js vjs-default-skin"
  controls preload="auto" width="500" height="264"
  poster="my_video_poster.png"
  data-setup="{}">
 <source src="videos/<?php echo $video; ?>" type='video/mp4' />

</video>

</div>


</body>
</html>

Hi,

This

<?php echo $video; ?>

Should have a value of file location and extension e.g. video.mp4.

Some Concerns about your codes..
Where is your .ogg video for firefox, opera and chrome browser support?

If you don't have enough space to spare for the remaining video format, I think it is more feasible to use flowplayer or jwplayer to make everyone happy. Otherwise, you can write your codes with fallback function html5 to flash if needed.

Hi ,this is the index.php where i get the $video = $_GET['video']; but not playing just keep in loading

index.php

<html>
<head>
<title>Video Upload</title>
<link rel="stylesheet" href="styles.css" />
</head>

<body>

<?php 
    include 'connect.php';
?>

<div id="box">
    <form method='post' enctype='multipart/form-data'>
        <?php
            if(isset($_FILES['video'])){

                $name = $_FILES['video']['name'];   
                $type = explode('.', $name);
                $type = end($type);
                $size = $_FILES['video']['size'];
                $random_name = rand();
                $tmp = $_FILES['video']['tmp_name'];

                if ($type !='mp4' && $type !='MP4' && $type !='flv') {
                    $message = "Video format not supported !"; 
                } else {
                    move_uploaded_file($tmp,'videos/'.$random_name.'.'.$type);
                    mysql_query("INSERT INTO videos VALUES ('','$name','$random_name.$type')");
                    $message = "Successfully uploaded!" ;
                }

                echo "$message <br /> <br />";
            }
        ?>
        Select Video :<br />
        <input type='file' name='video' />
        <br /> <br />
        <input type='submit' value='Upload' />
    </form>
</div>

<div id="box">
    <?php
        $query = mysql_query("SELECT * FROM videos");
        while ($run = mysql_fetch_array($query)) {
            $video_id = $run['id'];
            $video_name = $run['name'];
            $video_url = $run['url'];
    ?>
        <a href='view.php?video=<?php echo $video_url; ?>'>
            <div id="url">
                <?php echo $video_name; ?>
            </div>
        </a>
    <?php        
        }
    ?>
</div>

</body>


</html>

View the source of the page and look for the value of your video url from this

<source src="videos/somefilename" type='video/mp4' />

Browse and locate the somefilename in videos directory. If the video is not there, the upload is not successful, because of either the script timed out or the setting in your php.ini file has been exhausted..

OR, if the video is huge in size, the browser needs to download the entire video place it in the temp directory, before it can start to play. This is one of the disadvantages of using html5 player over the conventional flash player.

ADDITIONAL Info.

Unlike the flowplayer or jwplayer, html5 player do not support pseudo-streaming. Pseudo-streaming is the ability of the player to read the metadata of the video. In flv files, these metadata are injected by an application called flvtool2, while in mp4 videos encoded in h264 codec, metadata are injected by an application called mp4box, and yes it is all run from the php backend.

Both mp4 and flv videos that are not injected with metadata will not pseudo-stream. In the case of MP4 videos, the process is different because the moov atom is located in the back OR at the end of the video file. The MP4Box can move this moov atom in the fron of the file, so that flash players can pseudo-stream it,, meaning the browser or the player does not need to download the full video, before it can start playing.

If you will be developing a video content management system, you will need to know the ins-and-outs of the video delivery and conversion with PHP. Most importantly, the browser compatibilities, codecs both for the audio and the video, all types of extensions that exists, and the implementation of ffmpegphp. It is extremely complex than writing an e-commerce, forum, or blog application.

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.