Friday, January 3, 2020

JPG Images to MP4 Videos How To

First, I needed to rename my images in a numeric series. The images are named 001.jpg to 523.jpg.

I used some random bash one-liner from stack overflow to rename them in series by date. ...Which I seem to have misplaced.

I eventually cobbled together a sort of working ffmpeg command which you won't need-- but ffmpeg doesn't respect whatever EXIF data there is regarding rotation. To make the actual image match the EXIF data orientation, I used the exiftran command.

exiftran -ai *.jpeg

After getting everything right side up, the video size became the geometry of the first image. My first image was in portrait and the landscape images were stretched to match, unfortunately. I was fortunate that my maximum width and height were 4,032 pixels. To solve this problem I made my images square. I did this with gimp to create a 4,032 x 4,032 black image-- because black bars around the pictures is all fine enough for me. I then used the composite command from the imagemagick library to overlay and center all my images on that black square background saving the new image to a subdirectory. You'll need a square background, you can do it! And then the composite command from imagemagick.

I was lazy and used the Calc spreadsheet.

I gave myself a vertical column with a filename on each line.

ls -1

I put the filenames in column A1.

=CONCAT("composite -gravity center ", A1, " black.jpg square/", A1)

That will yeild a vertical column of commands to cut and paste into the CLI.

composite -gravity center 001.jpg black.jpg square/001.jpg

Now I have a directory full of square images in numeric sequence. FFMPEG time. Change the present working directory to the directory with all your square images. In this case, the square directory.

cd square

ffmpeg -framerate 1/3 -i '%03d.jpg' -vf fps=5 -pix_fmt yuv420p out.mp4

And then I tried the OpenShot video editor which felt slower, but had results I liked better. So there was that. Also, I think it respects EXIF data-- but I had already flipped everything.

Followers