360 Tiled Video with FFMpeg

360 Tiled Video with FFMpeg

This post will expand on the topic of tiling video that was covered in this post, https://www.cloudacm.com/?p=3026.  The video sourced in this post are directional and is well suited for creating a 360 degree view of surroundings.

The original video from each camera is 1080p, so the first step in this example is to reduce the resolution to 25 percent.  This command was run to make that adjustment.

### Resize videos to 1/4 of original ###
ffmpeg -i DriverSide_Original.MOV -vf "scale=iw*.25:ih*.25" DriverSide.MOV
ffmpeg -i Front_Original.MOV -vf "scale=iw*.25:ih*.25" Front.MOV
ffmpeg -i PassengerSide_Original.MOV -vf "scale=iw*.25:ih*.25" PassengerSide.MOV
ffmpeg -i Rear_Original.MOV -vf "scale=iw*.25:ih*.25" Rear.MOV

Since these will be tiled videos, there will be gaps and overlaps from each.  To make the viewing a bit easier to watch, a black frame was created around each of the videos with the following command.

###   Drawing a black frame around each video   ###

ffmpeg -i DriverSide.MOV -vf drawbox=x=0:y=0:w=480:h=270:t=1:color=black@1 EXP2_BOX_DriverSide.MOV
ffmpeg -i Front.MOV -vf drawbox=x=0:y=0:w=480:h=270:t=1:color=black@1 EXP2_BOX_Front.MOV
ffmpeg -i PassengerSide.MOV -vf drawbox=x=0:y=0:w=480:h=270:t=1:color=black@1 EXP2_BOX_PassengerSide.MOV
ffmpeg -i Rear.MOV -vf drawbox=x=0:y=0:w=480:h=270:t=1:color=black@1 EXP2_BOX_Rear.MOV

Now the videos can be tiled to create a single video with the full view.  This command was used.

###   Side by side of Rear and DriverSide   ###

ffmpeg -i "EXP2_BOX_Rear.MOV" -vf "[in] scale=iw:ih, pad=2*iw:ih [left];movie=EXP2_BOX_DriverSide.MOV, scale=iw:ih [right]; [left][right] overlay=main_w/2:0 [out]" "EXP2_BOX_RearDriverSide.MOV"

###   Side by side of Front and PassengerSide   ###

ffmpeg -i "EXP2_BOX_Front.MOV" -vf "[in] scale=iw:ih, pad=2*iw:ih [left];movie=EXP2_BOX_PassengerSide.MOV, scale=iw:ih [right]; [left][right] overlay=main_w/2:0 [out]" "EXP2_BOX_FrontPassengerSide.MOV"

###   Full round   ###

ffmpeg -i "EXP2_BOX_RearDriverSide.MOV" -vf "[in] scale=iw:ih, pad=2*iw:ih [left];movie=EXP2_BOX_FrontPassengerSide.MOV, scale=iw:ih [right]; [left][right] overlay=main_w/2:0 [out]" "EXP2_BOX_FullRound.MOV"

The cameras also have audio which was edited in Audacity to represent their left, center, or right positions.  This command was used to add the audio file to the video.

###   Replace audio in final video from combined camera audio   ###

ffmpeg -i "EXP2_BOX_FullRound.MOV" -i "Drive.wav" -c:v copy -map 0:v:0 -map 1:a:0 "EXP3_AUDIO_FullRound.MOV"

Adding to video to Vimeo required some additional work to allow the platform to represent it as a 360 degree video.  Refer to Vimeo’s help article on what these steps are.  At the time of this post, this link provided those details, https://help.vimeo.com/hc/en-us/articles/12426105907729-Upload-360-video.  Since the processed video thus far has a resolution of 1920 x 270, padding was needed so the final video had a 2:1 projection ratio with 1920 x 1080 being the final resolution.  This command was used to add the padding.

###   Pad video to support Vimeo 360 projection   ###

ffmpeg -i "EXP3_AUDIO_FullRound.MOV" -vf "pad=width=1920:height=1080:x=0:y=405:color=black" "EXP4_360_FullRound.MOV"

Tiling video with FFMpeg is a simple method to create 360 degree videos from low cost cameras.






Comments are closed.