'Convert Image to Video Laravel-FFMPEG

I'm trying to convert an image to a video with a specific time (for example, a single image to a 3 second video with the same frame).

On using FFmpeg.

ffmpeg -loop 1 -i aa.png -c:v libx264 -t 3 -pix_fmt yuv420p output.mp4

It works fine turning a single image to a 3 second video.

And using laravel-ffmpeg:

// $temp_file is aa.png
FFMpeg::fromDisk('temp_media')
    ->open($temp_file)
    ->addFilter('-loop', 1)
    ->addFilter('-c:v', 'libx264')
    ->addFilter('-t', 3)
    ->addFilter('-pix_fmt', 'yuv420p')
    ->export()
    ->toDisk('temp_media')
    ->save('output.mp4');

It's converted into MP4 format, but the video length is only 0 seconds.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source