How to Convert Equirectangular to Cubemap in FFmpeg
This article provides a quick guide on how to use FFmpeg’s
v360 filter to convert 360-degree video from
equirectangular projection to cubemap projection. You will find the
exact command-line syntax, explanations of the essential parameters, and
examples of different cubemap layouts to help you achieve the best video
quality and compatibility.
The v360 filter in FFmpeg is a powerful tool designed
for converting between various 360-degree video projections. To convert
a standard equirectangular video to a cubemap, you must define the input
projection as equirectangular and the output projection as a cubemap
format.
The Basic Command
The simplest command to perform this conversion uses the standard
equirect input and the cube output parameters.
By default, this generates a 6x1 cubemap layout (six cube faces aligned
in a single horizontal row).
ffmpeg -i input.mp4 -vf "v360=input=equirect:output=cube" output.mp4Choosing Cubemap Layouts
The standard 6x1 strip can result in an extremely wide video that some hardware decoders struggle to play. To solve this, you can specify alternative cubemap layouts using different output names:
3x2 Cubemap (
c3x2): Arranges the six faces in a 3-column, 2-row grid. This is highly recommended for better video player compatibility.ffmpeg -i input.mp4 -vf "v360=input=equirect:output=c3x2" output.mp41x6 Cubemap (
c1x6): Arranges the faces in a single vertical column.ffmpeg -i input.mp4 -vf "v360=input=equirect:output=c1x6" output.mp4
Enhancing Output Quality
When converting projections, pixels are mapped to new coordinates,
which can introduce aliasing or blurriness. You can control the quality
of this mapping using the interp (interpolation)
parameter.
The default interpolation is bilinear, but you can use
lanczos or bicubic for sharper, higher-quality
results:
ffmpeg -i input.mp4 -vf "v360=input=equirect:output=c3x2:interp=lanczos" output.mp4Customizing Face Order (Optional)
If your target video player requires a specific order for the cube
faces (Right, Left, Up, Down, Front, Back), you can use the
out_forder parameter. The default face order is
rludfb. To change it, specify the letters in your preferred
sequence:
ffmpeg -i input.mp4 -vf "v360=input=equirect:output=c3x2:out_forder=lru肩fb" output.mp4(Note: l = Left, r = Right,
u = Up/Top, d = Down/Bottom, f =
Front, b = Back)