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.