quasarstream / PHP-FFmpeg-video-streaming

📼 Package media content for online streaming(DASH and HLS) using FFmpeg
https://www.quasarstream.com/op/php/ffmpeg-streaming?u=php-ff
MIT License
514 stars 117 forks source link

mp4 file converted to hls is not done and throw this error. #73

Closed kashifansari786 closed 4 years ago

kashifansari786 commented 4 years ago

i was using core PHP not using any larawel or any Codeigniter and my os is AWS ubuntu server.

here is my code: require 'video_editor/vendor/autoload.php'; use Streaming\Representation; //thsi also throw error and code is not run $ffmpeg = FFMpeg\FFMpeg::create(array( 'ffmpeg.binaries' => ffmpeg_lib, 'ffprobe.binaries' => ffprobe_lib, 'timeout' => 3600, // The timeout for the underlying process 'ffmpeg.threads' => 12, // The number of threads that FFMpeg should use ), null); $ffmpeg_string = ffmpeg_lib; $ffprobe_lib = ffprobe_lib;

$orignalVideoPath = "tmp/1599388321915191545.mp4"; //this is a hardcoded string but in my code the video file is dynamic

$cmd ="$ffprobe_lib -i $orignalVideoPath -show_streams -select_streams a -loglevel error"; exec($cmd,$output); if(count($output)>0) { $video = $ffmpeg->open($orignalVideoPath); $genrateGif = "tmp/".$fileName.".m3u8";

   $video->hls()
->x264()
->autoGenerateRepresentations([720, 360]) // You can limit the number of representatons
->save();
    $ffmpeg="<span class='label label-success'>ffmpeg is inside</span>";

}else { $ffmpeg="ffmpeg is shown error"; }

and error is thrown when I run this code.

Fatal error: Uncaught Error: Call to undefined method FFMpeg\Media\Video::hls() in /path/debugmode_file.php:712 Stack trace: #0 /path/debugmode_file.php(306): ServerStatus() #1 {main} thrown in /path/debugmode_file.php on line 712

aminyazdanpanah commented 4 years ago

Use Streaming\FFMpeg::create() class instead of FFMpeg\FFMpeg::create(). Read the documentation.