1

Good morning, I am trying to figure out how to use the PHP FFmpeg Video streaming library (found here: https://video.aminyazdanpanah.com/start). So far I have the below in place from looking at the examples, and when I load this page directly it just spins and spins - so it's obviously doing something conversion-wise.

transcode.php

// Include the libraries
require $_SERVER['DOCUMENT_ROOT'].'/includes/phpffmpeg_stream/autoload.php';

use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Streaming\Representation;

$config = [
    'ffmpeg.binaries'  => 'C:/ffmpeg/bin/ffmpeg.exe',
    'ffprobe.binaries' => 'C:/ffmpeg/bin/ffprobe.exe',
    'timeout'          => 3600, // The timeout for the underlying process
    'ffmpeg.threads'   => 12,   // The number of threads that FFmpeg should use
];

$ffmpeg = Streaming\FFMpeg::create($config, NULL);

$video = $ffmpeg->open('D:/sampleVideo.avi');

$video->hls()
    ->fragmentedMP4()
    ->x264()
    ->autoGenerateRepresentations([720, 360]) // You can limit the numbers of representatons
    ->save();

However I am not sure how I play the output from this. I thought maybe I needed to set the source of my HTML video tag to http://myserver/transcode.php, but that does not work.

<video width="352" height="198" controls>
        <source src="http://192.168.10.1/transcode.php" type="application/x-mpegURL">
    </video>

What am I missing here? I want to load and convert/stream the video and play it back in a video tag and eventually in Android Exoplayer.

Thank you for all your help!

Phil
  • 4,029
  • 9
  • 62
  • 107

0 Answers0