Skip to content
Advertisement

VideoStream external URL mp4 file in PHP

Please help me with this VideoStream because its not working.

I have video link http://91.121.207.115/downloads/American.Traitor.The.Trial.of.Axis.Sally.007.BR.mp4

But its not playing in normal html5 video

Then I came up here and its working fine. https://codesamplez.com/programming/php-html5-video-streaming-tutorial

I already tried as I can but still not working.

index.php

<video width="320" height="240" controls>
    <source src="stream.php" type="video/mp4">
</video>

stream.php

include "VideoStream.php";
$stream = new VideoStream("http://91.121.207.115/downloads/American.Traitor.The.Trial.of.Axis.Sally.007.BR.mp4");
$stream->start();exit;

VideoStream.php file

Please help me to work that video stream in html5 video. thank you.

Advertisement

Answer

If you just want to use PHP to provide video file bytes into HTML5 <video> then try as:

(1) index.php: (can be index.html)…

<video width="640" height="400" controls>
<source src="stream.php" type="video/mp4">
</video>

(2) stream.php:

<?php
    
    $file = "http://91.121.207.115/downloads/American.Traitor.The.Trial.of.Axis.Sally.007.BR.mp4";
    
    $contents = readfile( $file );
    echo $contents; //# send back to HTML...
    exit;
?>
User contributions licensed under: CC BY-SA
11 People found this is helpful
Advertisement