EDIT: There's a better way! It's over there!
Gather round, children, as I describe how I fell down a rabbit hole trying to fake Superview, and how it worked, and why I don't use it.
Some background, then. GoPro's Superview is a non-linear horizontal stretch effect. For more details, have a look here (https://gopro.com/help/articles/question...-SuperView), but the short version is that it takes a 4:3 image and stretches it to fit a 16:9 frame. But it leaves the middle alone so it's not too distorted, and increases the stretch at the edges. This means you keep the full field-of-view instead of having to crop it, and as a side bonus the action looks a little quicker
I use ffmpeg (https://www.ffmpeg.org/) to do a bunch of video pre-processing which I may talk about in another thread (let me know if people are interested), but I was curious if I could achieve the Superview effect using ffmpeg as well. I initially wanted to use the displace filter, but couldn't find a way of displacing more than 128 pixels (if anyone has any ideas in that direction, let me know - maybe some pixel format hackery?), so I finally settled on the remap filter. That requires some additional input files to work, so I whacked together a quick Python script to generate those for me:
You can use it like this:
For 1440x1080 video, you will want the following settings:
This will output two files, xmap.pgm and ymap.pgm, which contain a bunch of values. We pass these into ffpmeg with our video file like so:
Which turns this:
into this:
As you can see, the middle stays roughly the same, but the edges are stretched out. Here's another example with a frame from an actual flying video.
Yes, there are a lot of artefacts at the edges. Turns out ffmpeg's remap filter doesn't do any kind of interpolation. Anyway, let's soldier on.
Applying this to video works exactly the same way. Below are a couple of videos illustrating the results. The first is the unmolested video, and the second one has the fake superview effect. This was shot on a Runcam 3S, and the first video has already been through my usual editing pipeline, which increases the colour temperature and removes most of the lens distortion.
Original
Fake Superview
So, success!
Well, kind of. The Runcam 3S doesn't support 4:3. So now what we need to do is take the 16:9 video, crop it down to 4:3 and then 'superview' it back out to 16:9. The end result is that we're sacrificing field of view for the illusion of speed. Honestly, I'm not sure it is worth the trade off. Also, the lack of image interpolation hurts the end result. Not that you can really see this in the video once the various compression algorithms have taken their pound of flesh, but it's pretty obvious in the static images. A smarter filter would do some kind of bicubic interpolation or something, but ffmpeg's remap doesn't.
In short, I don't use it. If the Runcam 3S did full-sensor 4:3 then it would make perfect sense. If ffmpeg did smoother work with remap then I would at least consider it. But they don't, so I don't.
Pyrrhic victory, baby.
Gather round, children, as I describe how I fell down a rabbit hole trying to fake Superview, and how it worked, and why I don't use it.
Some background, then. GoPro's Superview is a non-linear horizontal stretch effect. For more details, have a look here (https://gopro.com/help/articles/question...-SuperView), but the short version is that it takes a 4:3 image and stretches it to fit a 16:9 frame. But it leaves the middle alone so it's not too distorted, and increases the stretch at the edges. This means you keep the full field-of-view instead of having to crop it, and as a side bonus the action looks a little quicker
I use ffmpeg (https://www.ffmpeg.org/) to do a bunch of video pre-processing which I may talk about in another thread (let me know if people are interested), but I was curious if I could achieve the Superview effect using ffmpeg as well. I initially wanted to use the displace filter, but couldn't find a way of displacing more than 128 pixels (if anyone has any ideas in that direction, let me know - maybe some pixel format hackery?), so I finally settled on the remap filter. That requires some additional input files to work, so I whacked together a quick Python script to generate those for me:
Code:
import sys
import math
def derp_it(tx, target_width, src_width):
x = (float(tx) / target_width - 0.5) * 2 # -1 -> 1
sx = tx - (target_width - src_width) / 2
offset = math.pow(x, 2) * (-1 if x < 0 else 1) * ((target_width - src_width) / 2)
return sx - offset
def go():
target_width = int(sys.argv[1])
height = int(sys.argv[2])
src_width = int(sys.argv[3])
xmap = open('xmap.pgm', 'w')
xmap.write('P2 {0} {1} 65535\n'.format(target_width, height))
for y in range(height):
for x in range(target_width):
fudgeit = derp_it(x, target_width, src_width)
xmap.write('{0} '.format(int(fudgeit)))
xmap.write('\n')
xmap.close()
ymap = open('ymap.pgm', 'w')
ymap.write('P2 {0} {1} 65535\n'.format(target_width, height))
for y in range(height):
for x in range(target_width):
ymap.write('{0} '.format(y))
ymap.write('\n')
ymap.close()
if __name__ == '__main__':
go()
You can use it like this:
Code:
python remap_gen.py [TARGET_WIDTH] [HEIGHT] [SOURCE_WIDTH]
For 1440x1080 video, you will want the following settings:
Code:
python remap_gen.py 1920 1080 1440
This will output two files, xmap.pgm and ymap.pgm, which contain a bunch of values. We pass these into ffpmeg with our video file like so:
Code:
ffmpeg -i [INPUT_FILE] -i xmap.pgm -i ymap.pgm -lavfi remap [OUTPUT_FILE]
Which turns this:
into this:
As you can see, the middle stays roughly the same, but the edges are stretched out. Here's another example with a frame from an actual flying video.
Yes, there are a lot of artefacts at the edges. Turns out ffmpeg's remap filter doesn't do any kind of interpolation. Anyway, let's soldier on.
Applying this to video works exactly the same way. Below are a couple of videos illustrating the results. The first is the unmolested video, and the second one has the fake superview effect. This was shot on a Runcam 3S, and the first video has already been through my usual editing pipeline, which increases the colour temperature and removes most of the lens distortion.
Original
Fake Superview
So, success!
Well, kind of. The Runcam 3S doesn't support 4:3. So now what we need to do is take the 16:9 video, crop it down to 4:3 and then 'superview' it back out to 16:9. The end result is that we're sacrificing field of view for the illusion of speed. Honestly, I'm not sure it is worth the trade off. Also, the lack of image interpolation hurts the end result. Not that you can really see this in the video once the various compression algorithms have taken their pound of flesh, but it's pretty obvious in the static images. A smarter filter would do some kind of bicubic interpolation or something, but ffmpeg's remap doesn't.
In short, I don't use it. If the Runcam 3S did full-sensor 4:3 then it would make perfect sense. If ffmpeg did smoother work with remap then I would at least consider it. But they don't, so I don't.
Pyrrhic victory, baby.
The ground is for dead people.