How to trim a video by 4 fragments to 4 seconds using the PHP-FFMpeg?



PHP Snippet 1:

$ffmpeg = FFMpeg\FFMpeg::create();
$video = $ffmpeg->openAdvanced(['7207783801bb.mp4']);
$video->filters()
    ->custom('[0:v]', 'trim=start=10:end=11,setpts=PTS-STARTPTS', '[a]')
    ->custom('[0:v]', 'trim=start=20:end=21,setpts=PTS-STARTPTS', '[b]')
    ->custom('[a][b]', 'concat', '[c]')
    ->custom('[0:v]', 'trim=start=30:end=31,setpts=PTS-STARTPTS', '[d]')
    ->custom('[0:v]', 'trim=start=40:end=41,setpts=PTS-STARTPTS', '[f]')
    ->custom('[d][f]', 'concat', '[g]')
    ->custom('[c][g]', 'concat', '[out1]')
;
$video
    ->map(['[out1]'], new \FFMpeg\Format\Video\X264(), '7207783801bbout.mp4')
    ->save();

PHP Snippet 2:

$video->filters()->clip(FFMpeg\Coordinate\TimeCode::fromSeconds(10),
       FFMpeg\Coordinate\TimeCode::fromSeconds(1));