![]() Note however that despite the name, -glob this is not as general as shell Glob patters, e.g.: -i '*' fails: (apparently because filetype is deduced from extension). Generally speaking though, you will ideally be able to select images with the same or similar aspect ratios to avoid those problems in the first place. Mogrify -path black -thumbnail 640x480 -background black -gravity center -extent 640x480 png/*.pngįfmpeg -framerate 1 -pattern_type glob -i 'black/*.png' -i orig/audio.ogg -c:v libx264 -c:a copy -shortest -r 30 -pix_fmt yuv420p black.mp4 The other option is to pad with black background to have the same aspect ratio as shown at: Resize to fit in a box and set background to black on "empty" part mkdir -p black ![]() ![]() So now, the aspect ratio is good, but inevitably some cropping had to be done, which kind of cut up interesting parts of the images. Mogrify -path auto -geometry 640x480^ -gravity center -crop 640x480 0 0 png/*.pngįfmpeg -framerate 1 -pattern_type glob -i 'auto/*.png' -i orig/audio.ogg -c:v libx264 -c:a copy -shortest -r 30 -pix_fmt yuv420p auto.mp4 Now let's convert the images to the target 480p aspect ratio automatically by cropping as per ImageMagick: how to minimally crop an image to a certain aspect ratio? mkdir -p auto This produces terrible output, because as seen from: ffprobe raw.mp4įfmpeg just takes the size of the first image, 556x494, and then converts all others to that exact size, breaking their aspect ratio. Ln -P png/2.png png/3.png png/4.png png/5.png rawįfmpeg -framerate 1 -pattern_type glob -i 'raw/*.png' -i orig/audio.ogg -c:v libx264 -c:a copy -shortest -r 30 -pix_fmt yuv420p raw.mp4 So the classic 480p (640x480 = 4/3) aspect ratio seems appropriate.ĭo one conversion with minimal resizing to make widths even (TODOĪutomate for any width, here I just manually looked at identify output and reduced width and height by one): mkdir -p rawĬonvert png/1.png -resize 556x494 raw/1.png Now we have a quick look at all image sizes to decide on the final aspect ratio: identify png/* # Hardlink the ones that are already PNG. There's a bit more to creating slideshows than running a single ffmpeg command, so here goes a more interesting detailed example inspired by this timeline. In particular, the width has to be divisible by 2, otherwise conversion fails with: "width not divisible by 2".įull realistic slideshow case study setup step by step I would also first ensure that all images to be used have the same aspect ratio, possibly by cropping them with imagemagick or nomacs beforehand, so that ffmpeg will not have to make hard decisions. Your images should of course be sorted alphabetically, typically as: 0001-first-thing.jpg c:a copy -shortest -c:v libtheora -r 30 -pix_fmt yuv420p out.ogv c:a copy -shortest -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4īe a hippie and use the Theora patent-unencumbered video format in an OGG container: ffmpeg -framerate 1 -pattern_type glob -i '*.png' -i audio.ogg \ c:v libx264 -r 30 -pix_fmt yuv420p out.mp4Īdd some music to it, cutoff when the presumably longer audio when the images end: ffmpeg -framerate 1 -pattern_type glob -i '*.png' -i audio.ogg \ ![]() Slideshow video with one image per second ffmpeg -framerate 1 -pattern_type glob -i '*.png' \ It is cool to observe how much the video compresses the image sequence way better than ZIP as it is able to compress across frames with specialized algorithms:Ĭonvert one music file to a video with a fixed image for YouTube upload Images generated with: How to use GLUT/OpenGL to render to a file? These are the test media I've used: wget -O opengl-rotating-triangle.zip i audio.ogg -c:a copy -shortest -c:v libx264 -pix_fmt yuv420p out.mp4 Normal speed video with one image per frame at 30 FPS ffmpeg -framerate 30 -pattern_type glob -i '*.png' \Īdd some audio to it: ffmpeg -framerate 30 -pattern_type glob -i '*.png' \ This great option makes it easier to select the images in many cases.
0 Comments
Leave a Reply. |