Convert PNG sequence to MP4 from directory - windows

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

Related

Batch process audio files and image files to create movie files by matching multiple wildcard values

I'm attempting to batch-process audio and image files to create video files using a Shell script with FFmpeg.
The ffmpeg script works in Terminal:
ffmpeg -loop 1 -i image.png -i audio.wav -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest output.mp4
A nested for loop with wildcards works as a batch script:
#!/bin/sh
for img in *.png; do
for wav in *.wav; do
ffmpeg -loop 1 -i $img -i $wav -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest ../mb/$img.mp4
done
done
The only problem here is that it creates more combinations than I need. I'd like to be able to match wildcard values and only mix those together. I'd like to be able to prepare the filenames to match in advance to make this easier: For example, only match 1.png with 1.wav to make 1.mp4, 2.png with 2.wav to make 2.mp4 and so on. I'm able to modify the script to match the wildcards in a Regex, but I'm not sure if there is a way to then execute the logic above. Here is what I am attempting:
#!/bin/sh
img=*.png
wav=*.wav
if [[ ${img%.*} == ${wav%.*} ]];
then
ffmpeg -loop 1 -i $img -i $wav -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest $img.mp4;
else
echo "Failure"
fi
This begins by overwriting the image files, so it does not appear to work as planned. Is there a simpler way to do this? Perhaps looping through images {1..5} in one folder and audio files {1..5} in another?
Thanks for any insights, and happy to provide more context (very new to this, so still learning).
You can loop through *.png and derive *.wav from them like this:
for img in *.png; do
ffmpeg -loop 1 -i "$img" -i "${img%.*}.wav" -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest "${img%.*}.mp4"
done

create mp4 slide show on raspbian

I have RPi running raspbian.
I want a solution to convert a folder of image files to an mp4 slide show video that can be played with omxplayer.
I did it with ffmpeg and following command:
ffmpeg -y -framerate .1 -pattern_type glob -i '*.jpg' -c:v libx264 -pix_fmt yuv420p out.mp4
It works with mpv media player but playing it with the flowing command with omx player does not do anything.
omxplayer --loop --no-osd --win 0,0,128,224 --orientation 90 out.mp4
I must use omx player to output on exact window and be compatible with older programs.
Not sure what would be the right way to do this. I have already a node js server running on Pi that I can use if needed.
Thanks
So the problem was I should have force both input and output rates(r .2 and -r 30)
Here is my final command:
ffmpeg -y -r .2 -pattern_type glob -i '*.jpg' -vcodec libx264 -pix_fmt yuv420p -preset fast -crf 18 -b-pyramid none -acodec ac3 -ab 1536k -scodec copy -r 30 out.mp4
Thank you Gyan for your comments.

ffmpeg sorting order issue while creating video

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

Recording Screen with FFmpeg

I recently used the FFmpeg bash commands below to capture a screen recording.
Are there any improvements that I could make to streamline this process?
Or perhaps some settings to reduce the size of the output files?
Ideally, I'd like to capture to mp4 directly. Is this possible?
Any advice generally about FFmpeg screen recording would be most appreciated.
ffmpeg -f x11grab -y -r 30 -s 1920x1080 -i :0.0 -vcodec huffyuv out.avi
# Then convert it to .mp4
ffmpeg -y -i out.avi -s 1920x1080 -f mp4 -vcodec libx264 -preset slow -crf 18 -b:v 3000k -maxrate 4000k -bufsize 512k -c:a aac -b:a 128k -strict -2 out.mp4
# and remove the .avi
rm out.avi
In general, for FFmpeg, input formats and output formats aren't tied to one another, so you can save in any format as long as the codecs are acceptable in the output format.
So, this will do,
ffmpeg -f x11grab -y -framerate 30 -s 1920x1080 -i :0.0 -c:v libx264 -preset superfast -crf 18 out.mp4
You may need to add -pix_fmt yuv420p after -i :0.0 for player compatibility.

Create MP4 video from multiple images + musics using FFMPEG command

I have created video with multiple images and single music file. It's working fine
ffmpeg -y -framerate 1/5 -start_number 1 -i /<<dir path>>/photo3-%04d.jpg -i /<<dir path>>/music3-000.mp3 -c:v libx264 -r 30 -pix_fmt yuv420p -c:a aac -strict experimental -shortest /<<dir path>>/video/output.mp4;
But when I tried with multiple music files it throws and error in terminal.
Command:
ffmpeg -y -framerate 1/5 -start_number 1 -i /<<dir path>>/photo3-%04d.jpg -i /<<dir path>>/music3-%03d.mp3 -c:v libx264 -r 30 -pix_fmt yuv420p -c:a aac -strict experimental -shortest /<<dir path>>/video/output.mp4;
Error:
/<<dir path>>/music3-%03d.mp3: No such file or directory
There's no audio sequence demuxer. To combine multiple audio files in your command, you'll have to use the concat demuxer.
First, create a text file with the list of files
file 'music3-000.mp3'
file 'music3-001.mp3'
file 'music3-002.mp3'
...
Then run
ffmpeg -y -framerate 1/5 -start_number 1 -i /<<dir path>>/photo3-%04d.jpg \
-f concat -i list.txt \
-c:v libx264 -r 30 -pix_fmt yuv420p -c:a aac -strict experimental
-shortest /<<dir path>>/video/output.mp4

Resources