PHP code example of turbo / turbo-m3u8

1. Go to this page and download the library: Download turbo/turbo-m3u8 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/ */

    

turbo / turbo-m3u8 example snippets


use TurboM3u8\M3u8;

$obj = M3u8::input($m3u8FilePath);

$obj->getInfo();


$fromTime = 10;
$duration = 20;
$obj->clip($fromTime, $duration);
$obj->save($newFileName);

$obj->download($saveDir, function($process){
    echo "下载进度:{$process}%\n";
});

$fromTime = 10;
$duration = 20;
$obj->insert( $fromTime, $adFileName, $duration);
$obj->save($newFileName);

$file1 = '/clip_60_d43ccd5edc1b5f2c67eaae3760b7aaf2.m3u8';
$file2 = '/uploads/20200412/9bd2664d3e9df07f777acd1c0b8ae625.m3u8';
$obj = M3u8::input($file1);
$obj->merge($file2);
$obj->save('download/merge.m3u8','');