Skip to the content.

PS: Photo SlideShow 🚧

In this post, we’ll look at generating a slideshow (video) out of a bunch of images & a background audio.

$Files = ""
(Get-ChildItem .\images\ -File | sort {($_.Name) -replace '\D+' -as [int]}).Name | forEach {$Files += "file 'images/"+$_+"`n"}
$Files | Out-File -Encoding ascii MERGE.txt
ffmpeg -y -r 1/5 -f concat -safe 0 -i MERGE.txt -stream_loop 2 -i audio.mp3 -shortest -vcodec libx264 -crf 25 -pix_fmt yuv420p slideshow.mp4

As a bonus, we’ll set a background audio for a fully edited video. This is useful for setting background audio to video tutorials, vlogs, etc.
Assuming that the video is “720p.mp4”, the steps to do so are fairly simple:

ffmpeg -i 720p.mp4 -vcodec copy -an 720p-nosound.mp4
youtube-dl --no-cache-dir --extract-audio --audio-format mp3 -o "audio.%(ext)s" <URL>
ffmpeg -i 720p-nosound.mp4 -i audio.mp3 -shortest -c copy 720p.mp4

Update: 01-03-2021 (01:40 AM)

In yet another example, we’ll create a wedding slideshow using a PDF containing old pictures. Here are the steps that we’ll follow:

pdftopng -r 300 .\test.pdf .
(ls .*png -File | sort {($_.Name) -replace '\D+' -as [int]}).Name | forEach {$Files += "file "+$_+"`n"; mspaint $_}
magick mogrify -resize 1280x720 *.png
youtube-dl --no-cache-dir --extract-audio --audio-format mp3 -o "audio.%(ext)s" <URL>
ffmpeg -y -r 1/10 -f concat -safe 0 -i MERGE.txt -stream_loop 2 -i audio.mp3 -shortest -vcodec libx264 -crf 25 -pix_fmt yuv420p slideshow.mp4

Update: 04-03-2021 (02:16 PM)