1

Taking my first steps in live video streaming, I'm trying to conjure an MP4 live stream out of a .avs script that is parameterized via a wrapping PHP script.

I'd like to consume a video stream from PHP like this:

consume_video.html

<html>
<body>
    <video width="320" height="240" controls>
      <source src="stream.php?frames=100" type="video/mp4">
    </video>
</body>
</html>

The problem I have is making PHP stream the content via FFMPEG.

Here's a simple example to outline the solution:

stream.php

<?php
$numFrames = $_GET['frames'];
$filename = tempnam( __DIR__, 'file' ) . '.avs';
file_put_contents($filename, "ColorBars()\nTrim(0, $numFrames)" );

header('Content-Type: video/mp4');
$cmd = "ffmpeg -i $filename -c:v libx264 -crf 22 -c:a libfaac -movflags faststart";
// ... now what?

Is there a way to make this concept work or do I need to follow a different path?

Thanks.

AVIDeveloper
  • 2,954
  • 1
  • 25
  • 32
  • What exactly doesn't work, what happens instead, how do you test/access it? What existing solutions have you tried and what didn't work? Have you tried the examples from [documentation on streaming](https://trac.ffmpeg.org/wiki/StreamingGuide)? – wOxxOm Nov 23 '15 at 23:02
  • I updated the question. I'm trying to embed the .php wrapper in an HTML5 video tag but I'm not sure how to echo the binary content from .php back to the video tag. I already saw the streaming page you referred be to, but couldn't figure out how to incorporate it into this solution. – AVIDeveloper Nov 23 '15 at 23:25
  • [Best approach to real time http streaming to HTML5 video client](http://stackoverflow.com/q/21921790) - doesn't look like there's an easy solution... – wOxxOm Nov 23 '15 at 23:27
  • Interesting reading. Looks like live streaming is a bit of an overkill, especially that I didn't give much thought to the distinction between Live Streaming and VOD. I'll give VOD a closer look, maybe that's what I'm after. Thank you! – AVIDeveloper Nov 23 '15 at 23:58

0 Answers0