Sunday, 20 July 2014

Making a 4K video timelapse

The Lumix GH4 (my review) can be used to create 4K videos, but there are other ways as well. One way is to take normal resolution pictures with a camera that supports time lapses, and compose a video from them.

In this example, I used the Lumix GH4 to make the time lapse, but you could use any camera which supports it, for example the Lumix GM1 or the Lumix GX7.

I first set the camera on a tripod over my table, like this:



I'm using the Manfrotto 190XPROB tripod, which is useful since the column can be set horizontally. The ball head is Benro B-2, but most ball heads can be used here.



I used the Lumix G 14-42mm f/3.5-5.6 kit zoom lens at 14mm, and set the aperture to f/3.5. This was done mostly to avoid the aperture closing and opening for each shot, which is a somewhat annoying ticking sound. I prefocused, and then set the camera to manual focus (MF), to avoid the camera engaging the autofocus mechanism for each shot. I also used the electronic shutter mode to avoid the shutter noise.



To avoid having the images fill up too much space, I only used the "Basic JPEG" setting, see the symbol with the arrow pointing down into the three boxes on the centre top of the display. I also set ISO 400 to get about 1/60s exposure for each frame. In the example image you can see the focus peaking effect, the cyan outline of the box graphics to the lower left side.

I set the time lapse mode to take one picture every third second. I set the maximum image count to 3001. I don't need that many pictures, but I set a high figure just to get some slack, and I can stop the time lapse manually when I am done anyway.



Starting the timelapse and keeping it on while building gave me a total of 420 images, each taking about 2 megabytes. Each picture is a 16MP JPEG image in 4:3 aspect ratio. Here are some example frames:


Now, the pictures are in 4:3 aspect ratio, with a resolution of 4608x3456 pixels. For the 4K video, I need the 16:9 aspect ratio, with a resolution of 3840x2160 pixels. It would have been simpler if I had set the aspect ratio to 16:9 in the camera from the start. That way, I could have gotten away with just shrinking the pictures a bit.

However, I made sure to not use the upper part of the images, so I can just crop that off. Cropping and resizing can be done easily in the ImageMagick tool "convert", which I use in Linux. To get the right aspect ratio, I must crop off the upper 864 rows in each picture. Then, they should be resized to 3840x2160. I do all this with one command, like this, also adding a bit of sharpening. This command resizes all the images in a catalogue:

$ find . -name "*.JPG" -exec convert -crop 4608x2592+0+864 -resize 3840x2160 -unsharp 0.5x0.5+0.5+0.008 {} {}.PNG \;

Resizing all the 420 images took 3 hours, but then again, my computer is six years old.

The converted images are made into PNG images to avoid loss of quality in this process. To compose a video out of the still images, I used the program MEncoder, released together with MPlayer.

$ mencoder mf://*.PNG -mf fps=8:type=png -ovc x264 -x264encopts bitrate=24000:threads=2 -o video.mkv

Encoding the video file took about 10 minutes. I set 8 frames per second (FPS). And here is the output video:



In the time lapse, one can set a long delay between each shot, i.e., several minutes. If so, the camera enters a sleep mode between each shot. Setting manual focus still works, even if the lens focus is reset between each frame. Apparently, the camera has indexed the focus position.

1 comment: