i'm trying to convert a image into video with the use of FFMpeg in laravel. it generates the video but the the video duration is 0 second....
Here is my code...
$filename = $_FILES['video']['name'];
$tempname = $_FILES['video']['tmp_name'];
move_uploaded_file($tempname, storage_path('app/public/image2video/').$filename);
FFMpeg::fromDisk('image2video')
->open($filename)
->addFilter('-loop', 3)
// ->addFilter('-c:v', 'libx264')
->addFilter('-t', 3000)
->addFilter('-s', '1920x1080')
// ->addFilter('-pix_fmt', 'yuv420p')
->export()
->toDisk('image2videoConverted')
// ->dd('output.mp4');
->save('output.mp4');
here is my FFMpeg Command which is generating
ffmpeg -y -i C:/xampp/htdocs/laravel/textToSpeech2/storage/app/public/image2video/a.jpg -loop 3 -t 3000 -s 1920x1080 -threads 12 C:/xampp/htdocs/laravel/textToSpeech2/storage/app/image2videoConverted/output.mp4
it converted the image into mp4 format and stored at my given location but the video length is 0 second.
CodePudding user response:
Here is my FFMpeg Command which is generating
ffmpeg -y -i C:/xampp/htdocs/laravel/textToSpeech2/storage/app/public/image2video/a.jpg -loop 3 -t 3000 -s 1920x1080 -threads 12 C:/xampp/htdocs/laravel/textToSpeech2/storage/app/image2videoConverted/output.mp4
It converted the image into mp4 format and stored at my given location but the video length is 0 second.
You need to set the -loop
part first, then it's followed by the input -i
A working command looks like this example:
(for testing it sets duration -t
to 60 seconds, later you can try encoding your 3000 seconds video).
ffmpeg -y -loop 1 -i C:/xampp/htdocs/laravel/textToSpeech2/storage/app/public/image2video/a.jpg -r 30 -s 1920x1080 -c:v libx264 -movflags faststart -pix_fmt yuv420p -t 60 -threads 12 C:/xampp/htdocs/laravel/textToSpeech2/storage/app/image2videoConverted/output.mp4