protonemedia / laravel-ffmpeg

This package provides an integration with FFmpeg for Laravel. Laravel's Filesystem handles the storage of the files.
https://protone.media/en/blog/how-to-use-ffmpeg-in-your-laravel-projects
MIT License
1.63k stars 194 forks source link

Audio to HLS Problem #460

Closed aronquiray closed 1 year ago

aronquiray commented 1 year ago

Hi! I recently ran into an issue, Basically this is I wanted to run this works.

ffmpeg -y -i "storage/audio.mp3" -c:a aac -b:a 320k -muxdelay 0 -f segment -sc_threshold 0 -segment_time 10 -segment_list "storage/audio.m3u8" -segment_format mpegts "storage/audio%d.m4a

Tried this,

FFMpeg::fromDisk(config('filesystems.default'))
            ->open($storageLocation) // MP3 file
            ->exportForHLS()
            ->save($location); //m3u8

Throws error ProtoneMedia\LaravelFFMpeg\Exporters\NoFormatException

I tried adding a format (take note, it's only audio that I am converting)

$lowBitrate = (new X264)->setKiloBitrate(250);

        FFMpeg::fromDisk(config('filesystems.default'))
            ->open($storageLocation) // MP3 file
            ->exportForHLS()
            ->addFormat($lowBitrate)
            ->save($location); //m3u8

Throws another error. ProtoneMedia\LaravelFFMpeg\Support\StreamParser::new(): Argument #1 ($stream) must be of type FFMpeg\FFProbe\DataMapping\Stream, null given

I tried $audioFormat = (new Aac)->setAudioCodec('libfdk_aac'); ->addFormat($audioFormat)

ProtoneMedia\LaravelFFMpeg\Exporters\HLSExporter::getSegmentPatternAndFormatPlaylistPath(): Argument #2 ($format) must be of type FFMpeg\Format\VideoInterface, FFMpeg\Format\Audio\Aac given,

I'm quite confused. normally, thru normal execution via cli, it does work. how can I achieve that, or is there something I am missing?

aronquiray commented 1 year ago

nvm this. already solved it. updated something and created a pr to resolved my issue.