back

normal video enclosed in a synthetic panorama

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

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 fps:
ffmpeg -loop 1 -i dir/1.tif -c:v libx264 -preset slow -crf 18 -t 20 -r 25 -pix_fmt yuv420p dir/1.mov
ffmpeg -loop 1 -i dir/1.tif -c:v libx264 -preset slow -crf 18 -t 20 -r 25 -pix_fmt yuv420p dir/2.mov
ffmpeg -loop 1 -i dir/1.tif -c:v libx264 -preset slow -crf 18 -t 20 -r 25 -pix_fmt yuv420p dir/3.mov
ffmpeg -loop 1 -i dir/1.tif -c:v libx264 -preset slow -crf 18 -t 20 -r 25 -pix_fmt yuv420p dir/4.mov
ffmpeg -loop 1 -i dir/1.tif -c:v libx264 -preset slow -crf 18 -t 20 -r 25 -pix_fmt yuv420p dir/5.mov
ffmpeg -loop 1 -i dir/1.tif -c:v libx264 -preset slow -crf 18 -t 20 -r 25 -pix_fmt yuv420p dir/6.mov
To speed this up, you can chain the commands together with "&&" and if the first command executes without problems, the second will run, and so on.
ffmpeg -loop 1 -i dir/1.tif -c:v libx264 -preset slow -crf 18 -t 20 -r 25 -pix_fmt yuv420p dir/1.mov && ffmpeg -loop 1 -i dir/1.tif -c:v libx264 -preset slow -crf 18 -t 20 -r 25 -pix_fmt yuv420p dir/2.mov && and so on.

It is essential for all files to have the same length, I used this for the actual video/audio:
ffmpeg -i dir/2tmix.mp4 -ss 00:00:00 -t 20 dir/tmix.mov
cutting small sections, ffmpg wiki
 -ss : offset time from beginning. Value can be in seconds or HH:MM:SS format, (not needed in the example above).
 -t : duration. Value can be in seconds or HH:MM:SS format.
 -to : stop writing the output at specified position. Value in seconds or HH:MM:SS format.
If the video is i-frame only, use  -c copy for very fast trimming.
Check the duration by just opening the movie in ffmpeg to see the duration  Duration: 00:00:20.00, start: 0.000000, bitrate: etc.

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

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 my computer (you have to interact with it), but has problem on some mobiles?

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

back