How to Convert Side-by-Side to Anaglyph with FFmpeg
This article explains how to use the stereo3d filter in
FFmpeg to convert a side-by-side (SBS) 3D video into an anaglyph format,
allowing you to view 3D content on standard monitors using classic
red-cyan glasses. You will learn the correct command-line syntax, the
distinction between half-width and full-width inputs, and how to choose
the best anaglyph output method for your needs.
To convert a side-by-side video to anaglyph, you must use FFmpeg’s
video filter flag (-vf) followed by the
stereo3d filter. The basic syntax requires you to define
the input format and your desired output format:
ffmpeg -i input.mp4 -vf "stereo3d=input_format:output_format" output.mp41. Identifying Your Input Format
Before running the command, you need to know if your side-by-side video is “half-width” (most common for downloaded 3D media) or “full-width” (where each eye’s frame is stored at full resolution).
sbs2l: Side-by-side half-width (left eye first)sbs2r: Side-by-side half-width (right eye first)sbsl: Side-by-side full-width (left eye first)sbsr: Side-by-side full-width (right eye first)
2. Choosing Your Output Anaglyph Format
FFmpeg supports several anaglyph output variations. The most common are red-cyan, but you can choose how colors are processed:
arcd: Red/cyan anaglyph Dubois (highly recommended as it reduces ghosting and optimizes color reproduction)arcc: Red/cyan anaglyph full colorarch: Red/cyan anaglyph half color (balances color and reduces eye strain)arbg: Red/cyan anaglyph gray (black and white, lowest eye strain)
3. Example Commands
Convert Half-Width SBS to Red/Cyan Dubois Anaglyph (Recommended) This command takes a standard half-width SBS video and converts it to a high-quality red-cyan anaglyph using the Dubois algorithm:
ffmpeg -i input_sbs.mp4 -vf "stereo3d=sbs2l:arcd" output_anaglyph.mp4Convert Full-Width SBS to Full-Color Red/Cyan Anaglyph If your source video is full-resolution SBS and you want to preserve maximum color vibrancy, use this command:
ffmpeg -i input_full_sbs.mp4 -vf "stereo3d=sbsl:arcc" output_anaglyph.mp4Hardware Acceleration (Optional)
Because video encoding can be CPU-intensive, you can add your preferred video encoder to speed up the process. For example, to use NVIDIA hardware acceleration (NVENC), append the H.264 encoder to your command:
ffmpeg -i input_sbs.mp4 -vf "stereo3d=sbs2l:arcd" -c:v h264_nvenc output_anaglyph.mp4