back

normal video enclosed in a synthetic panorama

For an introduction to this see my: cubemap, cube faces and equirectangulars "mono"

The reason for making this was a man who had ambisonic sound files and only a flat HD video, he needed more space for the audio.

Make one tif/png/jpg in the needed size, for HD: 1920x1920. To test, download the tif 480x480 and the tmix.mov in: "dir.zip"

ffmpeg loop filter
Convert the tif (cube face) separately to six videos with a duration of 20 sec at 25 (or what fps the enclosed video has):
ffmpeg -loop 1 -i dir/1.tif -c:v libx264 -crf 18 -t 20 -r 25 -pix_fmt yuv420p dir/1.mov
ffmpeg -loop 1 -i dir/1.tif -c:v libx264 -crf 18 -t 20 -r 25 -pix_fmt yuv420p dir/2.mov
etc. up to 6.mov.

An alternative is using lavfi, you don't need a still image to start from (color=0x000000 is Black, name or hex can be used):
ffmpeg color syntax
ffmpeg -f lavfi -i "color=0x000000:s=480x480" -r 25 -c:v libx264 -crf 18 -t 20 -pix_fmt yuv420p dir/1.mov
ffmpeg -f lavfi -i "color=Black:s=480x480" -r 25 -c:v libx264 -crf 18 -t 20 -pix_fmt yuv420p dir/2.mov
etc. up to 6.mov.
You can color code some (all) cube faces "color code cube faces"

It is essential for all files to have the same length. If you are cutting compressed files, you might get small differences in duration, see:
cutting small sections, ffmpg wiki
and
"info on compression, I-, P-, B-frames"

Check the duration by just opening the movie in ffmpeg  ffmpeg -i tmix.mov to see the duration
 Duration: 00:00:20.00, start: 0.000000, bitrate: etc.

FFmpeg overlay filter uses presentation timestamps instead of frames. If start is not: 0.000000 you need to reset presentation timestamps setpts="PTS-STARTPTS"

Scale the video to fit a cube face of 480x480 px, video before scaling is 640x360, after 480x270:
ffmpeg scale filter and ffmpeg wiki scaling
ffmpeg -i dir/tmix.mov -vf "scale=w=480:h=-1" -c:a copy dir/scaled.mov
or
ffmpeg -i dir/tmix.mov -vf "scale=w=480:h=-1,setpts=PTS-STARTPTS" -c:a copy dir/scaled.mov

Take the forward cube face "5.mov" and overlay the scaled video:
ffmpeg overlay filter
ffmpeg -i dir/5.mov -i dir/scaled.mov -filter_complex "[0][1]overlay=x=0:y=105" -c:a copy dir/out5.mov

Alternatively, if you just use a black/monochrome background you could just pad the scaled video to 480x480, black is default:
ffmpeg pad filter
ffmpeg -i dir/scaled.mov -vf "pad=width=480:height=480:x=0:y=105" -c:a copy dir/5pad.mov

Assemble the video cubemap.
ffmpeg hstack filter  or   ffmpeg tile filter (which requires consistent naming)
ffmpeg -i dir/1.mov -i dir/2.mov -i dir/3.mov -i dir/4.mov -i dir/out5.mov -i dir/6.mov -filter_complex 'hstack=inputs=6' -r 25 -c:a copy dir/cubemap.mov

ffmpeg's v360 filter can convert the cubemap back to equirectangular after reassembly:
ffmpeg v360 filter
ffmpeg -i dir/cubemap.mov -vf v360=c6x1:e -r 25 -pix_fmt yuv420p -preset slow -crf 18 -c:a copy dir/equirectangular.mp4



equirectangular.mp4 with a video overlay on the forward cube face (5). It covers an area of 90°x50.625°

"the panorama"    Here I left open-source tools and used Pano2VR. Works on computers, you might have to interact with it, but with Firefox for Android the video doesn't start?

EXTRA: ffmpeg drawgrid filter    ffmpeg crop filter   good examples of cropping
Make a new black 2000x2000 px tif file, add grid lines to it like the cube faces above, you can use drawgrid, but first make cube face borders, here white, 8 pixels wide on faces 2000x2000.
ffmpeg -i 1.tif -vf "crop=1984:1984,pad=2000:2000:8:8:white,drawgrid=w=iw/9:h=ih/9:t=8:c=white" 1.png
 t=8 The thickness of the drawn cell.
 c=white The color of the drawn cell.   ffmpeg color syntax
It's not fully symmetric, I had to make the borders first. So don't trust the grid to pixel accuracy, probably I'm missing something.

back