I am able to successfully able to convert images to video using below command where all photos of
out directory is used.
$command1 = "ffmpeg -r 1/1 -framerate 25 -pattern_type glob -i 'out/*.jpg' -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p -vf 'pad=ceil(iw/2)*2:ceil(ih/2)*2' out/1.mp4";
exec($command1);
However the photos are getting picked randomly and I want to pick them using sort order example.
Pic1.jpg, Pic2.jpg, Pic2.jpg ......
Please suggest what to do here?
You could try using a prefix start_number instead of -pattern_type glob.
As explained here, the * glob does not work as expected.
If your images are in these order:
Pic1.jpg, Pic2.jpg, Pic3.jpg and so on...
Use -start_number instead, the updated ffmpeg:
ffmpeg -r 1/1 -framerate 25 -start_number 1 -i 'out/Pic%d.jpg' -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p -vf 'pad=ceil(iw/2)*2:ceil(ih/2)*2' out/1.mp4
Related
This commands works perfectly:
ffmpeg -loop 1 -i flyer.jpg -c:v libx264 -t 15 -pix_fmt yuv420p -vf scale=1080:720 out.mp4
Trying to do the same with Laravel FFMPEG
FFMpeg::fromDisk('images')
->open('flyer.jpg')
->export()
->addFilter('-loop', 1)
->addFilter('-c:v', 'libx264')
->addFilter('-t', '15')
->addFilter('-pix_fmt', 'yuv420p')
->addFilter('-vf', 'scale=1080:720')
->save('timelapse.mp4');
Seems that all filters are correctly applied but "-t 15" is not.
The problem is that in order to work, the -loop parameter should be specified before the -i parameter.
This works:
ffmpeg -loop 1 -i flyer.jpg -c:v libx264 -t 15 -pix_fmt yuv420p -threads 12 -vf [in]scale=1080:720 out.mp4
This doesn't work:
ffmpeg -i flyer.jpg -loop 1 -c:v libx264 -t 15 -pix_fmt yuv420p -threads 12 -vf [in]scale=1080:720 out.mp4
So I should I proceed with FFMPEG Laravel?
This topic was brought up in github:
https://github.com/protonemedia/laravel-ffmpeg/issues/349
But no answers.
Thanks.
You need to set input options not filters (or output options). Not knowing anything about PHP/Laravel, I suspect you need to use either openWithInputOptions() to open the input file or setInputOptions() to set -loop 1 input option.
I'm trying to set when the drawtext of this FFmpeg command starts, I've tried with start_number but looks like it will not do the trick.
ffmpeg -i 1.mp4 -acodec aac -keyint_min 20 -r 20 -vcodec libx264 -crf 22 -b 1000k -bt 1000k -y -v 0 -bf 16 -threads 0 -vf drawtext="start_number=20:fontfile=/home/admin/script/impact.ttf:text='My Text':fontsize=15:fontcolor=white:x=w-30*t:y=10" output.mp4
I've tried different approaches, but nothing seems to work
start_number is a parameter for used for an input image sequence/pattern.
If you want to draw a text on a video starting from the 3rd second you could use:
ffmpeg -i 1.mp4 -vf drawtext="text='My Text':enable=gt(t\,3)" output.mp4
Please notice that encoding parameters were omitted and you should add them to meet your requirements.
On a mac I would normally convert a folder of pngs to mp4 using the following:
ffmpeg -framerate 25 -i -pattern_type glob -i "*" -c:v libx264 -pix_fmt yuv420p -b:v 10M output.mp4
Now I'm trying to accomplish the same using windows 10, but globbing is not supported.
Not knowing what the filenames might be, is there a decent way of getting a complete file list of the directory and implementing it with ffmpeg?
Have u tried the % operator ?
ffmpeg -r 30 -i %.png -vcodec libx264 -crf 25 -pix_fmt yuv420p test.mp4
I am trying to encode a video to webm for playing through a HTML5 video tag. I have these settings...
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:a 128k -b:v 1M -c:a libopus output.webm
The results aren't great, video has lost lot's of it's sharpness. Looking at the original file I can see the bitrate is 1694kb/s.
Are there any settings I can add or change to improve the output? Would maybe a 2 pass encode improve things?
Try with
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -b:a 128k -c:a libopus output.webm
Adjust the CRF value till the quality/size tradeoff is ok. Lower values produce bigger but better files.
Try to run two passes:
ffmpeg -i file.mp4 -b:v 0 -crf 30 -pass 1 -an -f webm -y /dev/null
ffmpeg -i file.mp4 -b:v 0 -crf 30 -pass 2 output.webm
From - https://trac.ffmpeg.org/wiki/Encode/VP9
I would like with ffmpeg to slow down a movie I am creating using the flag:
-filter:v "setpts=2.0*PTS"
However the height of my still images is not divisible by 2, so to avoid the error: height not divisible by 2 (1238x833), I am using the flag:
-vf scale="trunc(iw/2)*2:trunc(ih/2)*2"
(I also tried -vf scale=1238:-2).
When I do this the film is generated but it isn't slowed down, like if the -filter:v "setpts=2.0*PTS" wasn't there.
Is there something particular to do in order to have both option working at the same time?
Here is the complete command I am using:
ffmpeg -an -i ./movie/cphmd1.%05d.ppm -vcodec libx264 -pix_fmt yuv420p -b:v 5000k -r 24 -crf 18 -filter:v "setpts=2.0*PTS" -vf scale="trunc(iw/2)*2:trunc(ih/2)*2" -preset slow -f mp4 cphmd1_slower.mp4
Many thanks in advance!
Multiple filters acting on the same input, in series, have to be chained together. So,
ffmpeg -an -i ./movie/cphmd1.%05d.ppm -vcodec libx264 -pix_fmt yuv420p -b:v 5000k -r 24 -crf 18 -vf "setpts=2.0*PTS,scale=trunc(iw/2)*2:trunc(ih/2)*2" -preset slow -f mp4 cphmd1_slower.mp4