[FFmpeg-user] Create slideshow with ffmpeg from still images
Paul B Mahol
onemda at gmail.com
Mon Jul 29 11:15:52 CEST 2013
Have you some questions?
If you are still not aware this list is not for propagating your
view of world but for user questions.
On 7/28/13, thljcl <jiachielee at live.com> wrote:
> Create slide show from still images is not exactly as simple as I originally
> anticipated. After knowing that ffmpeg is able to convert still images into
> video of lossless compression using encoders such as x264, I have a basic
> idea of how to create a slide show from a bunch of still images. In a way,
> creating slide show is exactly the opposite of creating the illusion of
> moving pictures. Human eyes perceive motion when the similar images are
> being displayed in sequence rapidly. For a slide show, however, each image
> or slide is being displayed for a couple of seconds instead of 1/24 seconds.
> Let's start from the very beginning.
> The basic command to convert a couple of still images to H.264 lossless
> video is:
> ffmpeg -r "24" -i "f_%%1d.png" -vcodec "libx264" -crf "0" "output.mkv"
> The input frames are being set to the frame rate of 24 FPS.
> f_%%1d.png represents images with the file name starting with f_1.png,
> f_2.png, f_3.png ...
> In Windows 8, you select a couple of images with whatever file names, when
> you rename those files together, they would be renamed to filename (1).png,
> filename (2).png...
> Each frame would be displayed for 1/24 second.
> On ffmpeg wiki at http://bit.ly/14YRtSv, there is a guide for creating a
> video slideshow with ffmpeg. If that guide works perfectly for me, I would
> not bother to write here.
So instead of modifying that wiki, you posted your way how things should
be done here.
> Say if you want to create a slide show with each slide to be displayed for 5
> seconds, one way that would work, though not practical, is to manually
> duplicate the same image. You would need 120 copies of the same image for
> the same slide to be displayed for 5 seconds at 24 frame per second.
> The problem with the ffmpeg wiki's guide is that ffmpeg drops frames,
> especially at the beginning or ending of the videos. Dropping frames causes
> the dropped slide or changed length. What I want to do is to dictate how
> ffmpeg duplicate frames automatically as I want.
> Here I have 135 images at http://sdrv.ms/11onHnh. Among them, 9 of them have
> the resolution of 3456 * 1080 pixels; the rest of them have the resolution
> of 1920 * 1080 pixels. To create a slideshow of 1280 * 720 pixels, I need to
> resize all of them to have the same resolution.
>
> ffmpeg -r "1" -i "wallpapers\sources\1_%%1d.jpg" -pix_fmt "yuv444p" -vcodec
> "libx264" -crf "0" "wallpapers\1.mkv"
> ffmpeg -r "1" -i "wallpapers\sources\2_%%1d.jpg" -pix_fmt "yuv444p" -vf
> "scale=1920:600,pad=1920:1080:0:240" -vcodec "libx264" -crf "0"
> "wallpapers\2.mkv"
> ffmpeg -r "1" -i "wallpapers\sources\3_%%1d.jpg" -pix_fmt "yuv444p" -vcodec
> "libx264" -crf "0" "wallpapers\3.mkv"
Using -pix_fmt should only be required if some jpgs are yuv444p but
others are not.
Otherwise you are doing extra conversion for no real benefit.
>
> I merge the three videos using mkvtoolnix. I extract frames from the
> combined video.
If you use mkvtoolnix that is really bad, because this mailing list is not
about mkvtoolnix. So your way is not better in any way.
Above 3 videos could be merged with ffmpeg too, get learn that first
before posting next time.
>
> mkdir "wallpapers\frames"
> ffmpeg -i "wallpapers\t.mkv" -vf "scale=1280:720" "wallpapers\frames\f
> (%%1d).png"
>
> From individual frames, I wrote a batch file to duplicate frames and create
> a slideshow (H.264 lossless). Each slide is to be displayed for 10 seconds.
>
> cd /d "wallpapers\frames"
> copy "f (135).png" "f (136).png"
> cd /d "%programfiles%\ffmpeg\bin"
> ffmpeg -r "1" -i "wallpapers\frames\f (%%1d).png" -vcodec "libx264" -crf "0"
> -vf "fps=10" "wallpapers\1.mkv"
> cd /d "wallpapers\frames"
> del "f (136).png"
> cd /d "%programfiles%\ffmpeg\bin"
> ffmpeg -r "1" -i "wallpapers\1.mkv" -vf "fps=24" -vcodec "libx264" -crf "0"
> "wallpapers\2.mkv"
> cd /d "wallpapers"
> del "1.mkv"
> ren "2.mkv" "slideshow.mkv"
> cd /d "%programfiles%\ffmpeg\bin"
>
> In duplicating the frames, ffmpeg will ignore the last frame. That's why I
> duplicate the last frame. Likewise, I can extract all the frames from the
> last show. Ffmpeg will duplicate the first frame. Similarly, I delete the
> first frame. Below is the lines I wrote to extract the frames from the
> slideshow:
This sounds like bug, you give extremly good practice: never ever report bug
just find workarounds: slower, complicated, using non-ffmpeg tools are
better ....
>
> ffmpeg -i "wallpapers\slideshow.mkv" -vf "fps=1" -vcodec "libx264" -crf "0"
> "wallpapers\1.mkv"
> ffmpeg -r "10" -i "wallpapers\1.mkv" -vf "fps=1" -vcodec "libx264" -crf "0"
> "wallpapers\2.mkv"
> cd /d "wallpapers"
> del "1.mkv"
> ren "2.mkv" "1.mkv"
> cd /d "%programfiles%\ffmpeg\bin"
> mkdir "wallpapers\frames_1"
> ffmpeg -i "wallpapers\1.mkv" "wallpapers\frames_1\f_%%1d.png"
> cd /d "wallpapers\frames_1"
> del "f_1.png"
> cd /d "%programfiles%\ffmpeg\bin\wallpapers"
> del "1.mkv"
> cd /d "%programfiles%\ffmpeg\bin"
> ffmpeg -r "1" -i "wallpapers\frames_1\f_%%1d.png" -vcodec "libx264" -crf "0"
> "wallpapers\1.mkv"
> rmdir /s /q "wallpapers\frames_1"
> mkdir "wallpapers\frames_1"
> ffmpeg -i "wallpapers\1.mkv" "wallpapers\frames_1\f_%%1d.png"
> cd /d "wallpapers"
> del "1.mkv"
> cd /d "%programfiles%\ffmpeg\bin"
>
> The slideshow I created is at http://sdrv.ms/15Xa2TU.
In short this is perfect explanation how things should not be done.
More information about the ffmpeg-user
mailing list