kandi background
Explore Kits

PHP-FFmpeg-video-streaming | Package media content for online streaming | Video Utils library

 by   aminyazdanpanah PHP Version: v1.2.15 License: MIT

 by   aminyazdanpanah PHP Version: v1.2.15 License: MIT

Download this library from

kandi X-RAY | PHP-FFmpeg-video-streaming Summary

PHP-FFmpeg-video-streaming is a PHP library typically used in Video, Video Utils applications. PHP-FFmpeg-video-streaming has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.
This library is a wrapper around PHP-FFMpeg and packages media content for online streaming such as DASH and HLS. You can also use DRM for HLS packaging. There are several options to open a file from a cloud and save files to clouds as well.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • PHP-FFmpeg-video-streaming has a low active ecosystem.
  • It has 333 star(s) with 77 fork(s). There are 22 watchers for this library.
  • There were 1 major release(s) in the last 12 months.
  • There are 5 open issues and 90 have been closed. On average issues are closed in 66 days. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of PHP-FFmpeg-video-streaming is v1.2.15
This Library - Support
Best in #Video Utils
Average in #Video Utils
This Library - Support
Best in #Video Utils
Average in #Video Utils

quality kandi Quality

  • PHP-FFmpeg-video-streaming has 0 bugs and 0 code smells.
This Library - Quality
Best in #Video Utils
Average in #Video Utils
This Library - Quality
Best in #Video Utils
Average in #Video Utils

securitySecurity

  • PHP-FFmpeg-video-streaming has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • PHP-FFmpeg-video-streaming code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
This Library - Security
Best in #Video Utils
Average in #Video Utils
This Library - Security
Best in #Video Utils
Average in #Video Utils

license License

  • PHP-FFmpeg-video-streaming is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
This Library - License
Best in #Video Utils
Average in #Video Utils
This Library - License
Best in #Video Utils
Average in #Video Utils

buildReuse

  • PHP-FFmpeg-video-streaming releases are available to install and integrate.
  • Installation instructions, examples and code snippets are available.
  • PHP-FFmpeg-video-streaming saves you 1020 person hours of effort in developing the same functionality from scratch.
  • It has 2317 lines of code, 326 functions and 54 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
This Library - Reuse
Best in #Video Utils
Average in #Video Utils
This Library - Reuse
Best in #Video Utils
Average in #Video Utils
Top functions reviewed by kandi - BETA

kandi has reviewed PHP-FFmpeg-video-streaming and discovered the below as its top functions. This is intended to give you an instant insight into PHP-FFmpeg-video-streaming implemented functionality, and help decide if they suit your requirements.

  • Get stream metadata
    • Calculate the ko - bit rate array
      • Generate M3U file .
        • Initializes the dash .
          • Upload a directory .
            • Get init args
              • Create a temporary file .
                • Generate subtitle des
                  • Build video command
                    • Set the path to the image .

                      Get all kandi verified functions for this library.

                      Get all kandi verified functions for this library.

                      PHP-FFmpeg-video-streaming Key Features

                      You can easily use other advanced features in the PHP-FFMpeg library. In fact, when you open a file with the open method(or openFromCloud), it holds the Media object that belongs to the PHP-FFMpeg. You can extract a frame at any timecode using the FFMpeg\Media\Video::frame method. NOTE: You can use the image as a video's poster. A gif is an animated image extracted from a sequence of the video. You can save gif files using the FFMpeg\Media\Gif::save method. This method has a third optional boolean parameter, which is the duration of the animation. If you don't set it, you will get a fixed gif image. NOTE: You can use the gif as a video's thumbnail. To see more examples, visit the PHP-FFMpeg Documentation page.

                      Installation

                      copy iconCopydownload iconDownload
                      composer require aminyazdanpanah/php-ffmpeg-video-streaming
                      

                      Quickstart

                      copy iconCopydownload iconDownload
                      require 'vendor/autoload.php'; // path to the autoload file
                      

                      Configuration

                      copy iconCopydownload iconDownload
                      use Monolog\Handler\StreamHandler;
                      use Monolog\Logger;
                      
                      $config = [
                          'ffmpeg.binaries'  => '/usr/bin/ffmpeg',
                          'ffprobe.binaries' => '/usr/bin/ffprobe',
                          'timeout'          => 3600, // The timeout for the underlying process
                          'ffmpeg.threads'   => 12,   // The number of threads that FFmpeg should use
                      ];
                      
                      $log = new Logger('FFmpeg_Streaming');
                      $log->pushHandler(new StreamHandler('/var/log/ffmpeg-streaming.log')); // path to log file
                          
                      $ffmpeg = Streaming\FFMpeg::create($config, $log);
                      

                      Opening a Resource

                      copy iconCopydownload iconDownload
                      $video = $ffmpeg->open('/var/media/video.mp4');
                      

                      DASH

                      copy iconCopydownload iconDownload
                      $video->dash()
                          ->x264() // Format of the video. Alternatives: hevc() and vp9()
                          ->autoGenerateRepresentations() // Auto generate representations
                          ->save(); // It can be passed a path to the method or it can be null
                      

                      HLS

                      copy iconCopydownload iconDownload
                      $video->hls()
                          ->x264()
                          ->autoGenerateRepresentations([720, 360]) // You can limit the number of representatons
                          ->save();
                      

                      Transcoding

                      copy iconCopydownload iconDownload
                      $format = new Streaming\Format\X264();
                      $format->on('progress', function ($video, $format, $percentage){
                          // You can update a field in your database or can log it to a file
                          // You can also create a socket connection and show a progress bar to users
                          echo sprintf("\rTranscoding...(%s%%) [%s%s]", $percentage, str_repeat('#', $percentage), str_repeat('-', (100 - $percentage)));
                      });
                      
                      $video->dash()
                          ->setFormat($format)
                          ->autoGenerateRepresentations()
                          ->save();
                      

                      Saving Files

                      copy iconCopydownload iconDownload
                      $dash = $video->dash()
                                  ->x264()
                                  ->autoGenerateRepresentations()
                                  
                      $dash->save('/var/media/dash-stream.mpd');
                      

                      Metadata

                      copy iconCopydownload iconDownload
                      $hls = $hls->save();
                      $metadata = $hls->metadata()->export();
                      
                      print_r($metadata);
                      

                      Conversion

                      copy iconCopydownload iconDownload
                      $stream = $ffmpeg->open('https://www.aminyazdanpanah.com/?PATH/TO/HLS-MANIFEST.M3U8');
                      
                      $stream->dash()
                          ->x264()
                          ->addRepresentations([$r_360p, $r_480p]) 
                          ->save('/var/media/dash-stream.mpd');
                      

                      Other Advanced Features

                      copy iconCopydownload iconDownload
                      $ffmpeg = Streaming\FFMpeg::create();
                      $video = $ffmpeg->openFromCloud($from_cloud, '/var/media/new/video.mp4');
                      

                      Laravel Job throwing Symfony\Component\Process\Exception\ProcessTimedOutException

                      copy iconCopydownload iconDownload
                       'redis' => [
                                  'driver' => 'redis',
                                  'connection' => 'default',
                                  'queue' => env('REDIS_QUEUE', 'default'),
                                  'retry_after' => 90,
                                  'block_for' => null,
                                  'after_commit' => false,
                              ],
                      
                      use Streaming\FFMpeg;
                      
                      $ffmpeg =  FFMpeg::create([
                                  'timeout'          => 3600,
                              ]);
                      
                       'redis' => [
                                  'driver' => 'redis',
                                  'connection' => 'default',
                                  'queue' => env('REDIS_QUEUE', 'default'),
                                  'retry_after' => 90,
                                  'block_for' => null,
                                  'after_commit' => false,
                              ],
                      
                      use Streaming\FFMpeg;
                      
                      $ffmpeg =  FFMpeg::create([
                                  'timeout'          => 3600,
                              ]);
                      

                      Community Discussions

                      Trending Discussions on PHP-FFmpeg-video-streaming
                      • Laravel Job throwing Symfony\Component\Process\Exception\ProcessTimedOutException
                      Trending Discussions on PHP-FFmpeg-video-streaming

                      QUESTION

                      Laravel Job throwing Symfony\Component\Process\Exception\ProcessTimedOutException

                      Asked 2021-Dec-12 at 14:43

                      I have web application that runs a job to convert videos into HLS using the aminyazdanpanah/php-ffmpeg-video-streaming package. However, after about 2 minutes, the job fails and throws the error:

                      Symfony\Component\Process\Exception\ProcessTimedOutException: The process '/usr/bin/ffmpeg -y -i...'
                      exceeded the timeout of 300 seconds. in /var/www/vendor/symfony/process/Process.php:1206
                      

                      The Laravel job has it's time out set to 7200s. My supervisor setup also specifies a timeout of 7200s:

                      [program:app_worker]
                      process_name=%(program_name)s_%(process_num)02d
                      command=php /var/www/artisan queue:work --tries=1 --timeout=7200 --memory=2000
                      autostart=true
                      autorestart=true
                      

                      I have also set my php max_execution_time to 7200s in the ini file. In the job handle() function I also call set_time_limit(7200); to set the time limit.

                      I have restarted the queue worker and cleared my cache but that doesn't seem to solve the issue.

                      It seems Symfony just ignores the timeout specification from Laravel.

                      ANSWER

                      Answered 2021-Dec-12 at 13:18

                      I noticed that it failed after about 2 minutes because in my config/queue.php file redis retry_after was set to 90.

                       'redis' => [
                                  'driver' => 'redis',
                                  'connection' => 'default',
                                  'queue' => env('REDIS_QUEUE', 'default'),
                                  'retry_after' => 90,
                                  'block_for' => null,
                                  'after_commit' => false,
                              ],
                      

                      I increased that to 3600 so the job stopped failing after 2 minutes but kept failing after 300s.

                      I later traced down the timeout to be coming from aminyazdanpanah/php-ffmpeg-video-streaming FFmpeg::create(). By default, the function sets a timeout of 300s. So I had to pass a config to the function to increase the time out:

                      use Streaming\FFMpeg;
                      
                      $ffmpeg =  FFMpeg::create([
                                  'timeout'          => 3600,
                              ]);
                      

                      And this solved the timeout issue.

                      Source https://stackoverflow.com/questions/70320689

                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                      Vulnerabilities

                      No vulnerabilities reported

                      Install PHP-FFmpeg-video-streaming

                      Install the package via composer:.
                      First of all, you need to include the package in your code:.

                      Support

                      I'd love your help in improving, correcting, adding to the specification. Please file an issue or submit a pull request.

                      DOWNLOAD this Library from

                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      Explore Related Topics

                      Share this Page

                      share link
                      Reuse Pre-built Kits with PHP-FFmpeg-video-streaming
                      Consider Popular Video Utils Libraries
                      Try Top Libraries by aminyazdanpanah
                      Compare Video Utils Libraries with Highest Support
                      Compare Video Utils Libraries with Highest Quality
                      Compare Video Utils Libraries with Highest Security
                      Compare Video Utils Libraries with Permissive License
                      Compare Video Utils Libraries with Highest Reuse
                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      • © 2022 Open Weaver Inc.