For an introduction to this see my: cubemap, cube faces and equirectangulars "mono"
The reason for this was a man having surround sound files and only a 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, 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.
(Note to myself, i-frame only: Encode every frame as a keyframe)
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.
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 "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 cubemap.mov -vf v360=c6x1:e -r 25 -pix_fmt yuv420p -preset slow -crf 18 -c:a copy 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
To add grid lines to a cube face you can use drawgrid, but first make cube face borders, here red, 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=8 The thickness of the drawn cell.
c=red 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.