| Q | A
| -------------- | ---
| Bug? | no
| New Feature? | no
| FFmpeg Version | 3.0.7
| OS | Linux
Hi,
Is there any way to implement HLS with a key using PHP-FFMPEG?
My ffmpeg command is here:
ffmpeg -y -i demo.mp4 -hls_time 9 -hls_key_info_file enc.keyinfo -hls_segment_filename "segmentedfile%d.ts" video.m3u8
I am also trying to figure out what is the best way to create custom ffmpeg commands. It would be nice to get some documentation on creating custom commands in the mean time. I am interested in running some hls commands such as:
ffmpeg -y -i video.mp4 -g 60 -hls_time 10 -hls_list_size 0 video.m3u8
I solved the problem by using SimpleFilter class like this:
...
$video = $ffmpeg->open(public_path('video.mp4'))
->addFilter(new SimpleFilter(['-g','60','-hls_time', '10' , '-hls_list_size', '0' , ...]));
...
or you can use setAdditionalParameters when you set format of video
...
$format = new X264();
$format->setAdditionalParameters(['-g','60','-hls_time', '10' , '-hls_list_size', '0' , ...]);
...
but if you use Laravel framework for development, you can use this library to create HLS videos:
https://github.com/pascalbaljetmedia/laravel-ffmpeg
that also uses the PHP-FFmpeg library.
Closing because there is a valid solution... (and personally, I want to keep an overview of the issues)
I was able to add my own "hls" method to FFmpeg/Media/Video.php which instantiated a new Hls Class which I defined in FFmpeg/Media/Hls.php . It followed the methodology of the "frame" method in Video.php .
I didn't want to hack away at the thing but i didn't see another elegant option.
@adriangoris Maybe you want to do a pull request?
Any news about this issue?
Most helpful comment
I solved the problem by using
SimpleFilterclass like this:...$video = $ffmpeg->open(public_path('video.mp4'))->addFilter(new SimpleFilter(['-g','60','-hls_time', '10' , '-hls_list_size', '0' , ...]));...or you can use
setAdditionalParameterswhen you set format of video...$format = new X264();$format->setAdditionalParameters(['-g','60','-hls_time', '10' , '-hls_list_size', '0' , ...]);...but if you use Laravel framework for development, you can use this library to create HLS videos:
https://github.com/pascalbaljetmedia/laravel-ffmpeg
that also uses the PHP-FFmpeg library.