How can I turn a side-window driving video into one long horizontal background image?

Asked 2/3/2022

4 views

2 answers

0

I recorded a 2-minute video from a phone mounted against my car’s side window, and I’d like to convert the journey into one very wide image to use as a side-scrolling 2D game background. Simply grabbing frames and placing them next to each other in Photoshop gives distorted results, with buildings appearing squeezed. Is there software or a technique that can extract frames and combine them into a long horizontal image more accurately?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

4y ago

2 Answers

3

I have not done this myself, but here is how I would approach it roughly.

Assuming that:

  • the video has a constant framerate of 30 frames per second (f/s)
  • there are 30 [f] * 120 [s] = 3600 frames in total
  • the vehicle travelled between 2000 [m] / 120 [s] = 17 m/s and 3000 [m] / 120 [s] = 25 meters per second
  • each frame is shifted at most by 25 [m/s] / 30 [f/s] = 0.8 meters each frame

For a (mosaic1) panorama you don't need a photo every 0.8 meters. I think a photo every 16 meter should be sufficient, i.e. every 20th frame.

ffmpeg is the tool I would use to extract from a video, this Stackoverflow question deals with that.

After I would have the frames (about 180) I would start stitching batches of +/-10 images in Hugin. I guess Photoshop might work, but Hugin provides far more control over the stitching process. Stitching all the 180 frames in one go sounds like something my computer (and sanity) would not be able to handle.

Once the batches are stitched, I would stitch them into the final image.

Instead of only taking every 20th frame, another clever way to reduce the number of overlapping pixels (suggested by xenoid in the comments) is to take a narrow column of pixels from each frame (e.g. 10% of the width of the whole frame) and stitch that.

Not sure how I would display the result though, as the final image would have an approximate aspect ratio of 1:240 (height:width).

Good luck, and don't forget to keep us updated on the outcome.

1) I think that's what it's called when you move the camera and take photos to stitch together.

Originally by user9161. Source · Licensed CC BY-SA 4.0

user9161

4y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Yes — this is possible, but the best method depends on the look you want.

For a panorama-style result, extract selected frames from the video with a tool like ffmpeg, then stitch overlapping batches in panorama software such as Hugin. You usually do not need every frame; sampling fewer frames can work better.

For a true continuous “distance over time” strip, use a slit-scan approach: take the center vertical column (or a slightly wider strip) from each frame and place those strips side by side. That creates one long image representing the whole trip. Depending on speed and frame rate, you may want to use a wider strip or sample fewer frames.

The main problem is likely your phone video’s rolling shutter, which can distort buildings and make stitching look squeezed. Reducing or correcting rolling-shutter issues before stitching may improve results, but phone footage can still be challenging.

So: use ffmpeg to extract frames, Hugin for panorama stitching, or a slit-scan workflow if you want a long continuous strip from the video.

UniqueBot

AI

4y ago

Your Answer