jtpt
jtpt

Reputation: 11

Merging flat videos into a 360 video using ffmpeg

I've got a DIY multi-camera rig; I'd like to use it to create 360 degree videos using ffmpeg. I can get a single video into the correct equirectangular projection, but can't seem to get all videos.

I can use ffmpeg and v360 to convert get a single video and place it at the correct orientation in the frame with this command.

ffmpeg -i 1.mp4 -vf v360=output=equirect:input=flat:h_fov=60:v_fov=47.5:yaw=60 -t 2 out.mp4

However, I can't seem to successfully feed multiple input videos to v360, and have them show up in the same output video.

I've tried using filter_complex, and then horizontally stacking them, but it's not actually merging the videos together - it just creates 2 separate equirectangular videos.

ffmpeg -i 1.mp4 -i 2.mp4 -filter_complex '[0:v]v360=output=equirect:input=flat:h_fov=60:v_fov=47.5:yaw=60[first]; [1:v]v360=output=equirect:input=flat:h_fov=60:v_fov=47.5:[second]; [second][first]hstack[out]' -map "[out]" -t 2 out.mp4

Overlay doesn't work, either, since the output videos from v360 aren't transparent in the parts of the image without video. I just end up with a single input video showing up in the output.

ffmpeg -i 1.mp4 -i 2.mp4 -filter_complex '[0:v]v360=output=equirect:input=flat:h_fov=60:v_fov=47.5:yaw=60[first]; [1:v]v360=output=equirect:input=flat:h_fov=60:v_fov=47.5:[second]; [second][first]overlay[out]' -map "[out]" -t 2 out.mp4

Is there a way to feed multiple input videos to a single v360 equirectangular filter? or a way to make the empty output from v360 be transparent, so I can overlay the output videos using multiple v360 calls, with the appropriate yaw parameters?

Thanks in advance!

Upvotes: 1

Views: 2585

Answers (1)

Mick
Mick

Reputation: 25471

AFAIK, ffmpeg does not support video stitching itself.

This is usually done using dedicated video stitching software and the output is generally in a format, i.e. looking like a standard mp4 video, that other tools like ffmpeg can then work with.

There are some manual workflows that use some open source tools to stitch frame by frame, but this is quite an effort intensive approach - you can see an example using an open source Hugin image stitcher, Hugin (http://hugin.sourceforge.net) here (link live at time of writing):

There is also open source stitching software based on the now closed VideoStitch company. This is available on GitHub but it would be worth checking how well supported it is before making your decisions on the tools to use:

Upvotes: 1

Related Questions