PHP code example of maplesnow / php-ffmpeg

1. Go to this page and download the library: Download maplesnow/php-ffmpeg library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

maplesnow / php-ffmpeg example snippets


$qiniu = new \Streaming\Qiniu($accessKey,$secretKey);
$video = $ffmpeg->fromQiniu($qiniu,$url);

$video->MP4()->X264()->save('mp4/demo.mp4');
 php
$video = $ffmpeg->open('/var/www/media/videos/test.mp4');
 php
$video->HLS()
    ->X264()
    ->autoGenerateRepresentations([720, 360]) // You can limit the numbers of representatons
    ->save();
 php
$dash = $video->DASH()
            ->HEVC()
            ->autoGenerateRepresentations()
            ->setAdaption('id=0,streams=v id=1,streams=a');
            
$dash->save('dash/test.mpd');
 php
$hls = $video->HLS()
            ->X264()
            ->autoGenerateRepresentations();
            
$hls->save();
 php
$mp4 = $video->MP4()->X264();
$qiniu = new \Streaming\Qiniu($accessKey,$secretKey);
$mp4->save2qiniu($qiniu,'bucket-name')