How to Group Video Angles in MKV Using FFmpeg

The Matroska (MKV) container format supports hosting multiple video, audio, and subtitle streams within a single file. This article demonstrates how to use FFmpeg to package multiple video feeds—representing different camera angles—into a single MKV file, apply metadata titles to distinguish the angles, and configure stream dispositions so media players can switch between them seamlessly.

Step 1: Prepare Your Source Files

To group multiple video angles, you need the individual video files representing each camera angle. For this example, we will use two video files (angle1.mp4 and angle2.mp4) and assume angle1.mp4 also contains the primary audio track.

Step 2: Combine and Map the Streams

You must explicitly map each input video stream to the output container. By default, FFmpeg only selects one video and one audio stream. Use the -map option to select all desired streams.

Run the following command to merge the files without re-encoding:

ffmpeg -i angle1.mp4 -i angle2.mp4 -map 0:v -map 1:v -map 0:a -c copy -metadata:s:v:0 title="Main Angle" -metadata:s:v:1 title="Alternative Angle" -disposition:v:0 default -disposition:v:1 0 output.mkv

Command Breakdown

Step 3: Playback and Switching Angles

Once the command finishes, open the resulting output.mkv file in a compatible media player such as VLC or MPV.