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.mkvCommand Breakdown
-i angle1.mp4 -i angle2.mp4: Specifies the two input files.-map 0:v: Maps the video stream from the first input (angle1.mp4) as the first video track (index 0).-map 1:v: Maps the video stream from the second input (angle2.mp4) as the second video track (index 1).-map 0:a: Maps the audio stream from the first input to accompany both video angles.-c copy: Copies the video and audio payloads directly without re-encoding, preserving quality and saving processing time.-metadata:s:v:0 title="Main Angle": Names the first video track “Main Angle”. Media players will display this name in their video track selection menu.-metadata:s:v:1 title="Alternative Angle": Names the second video track “Alternative Angle”.-disposition:v:0 default: Sets the first video track as the default stream to play when the file is opened.-disposition:v:1 0: Explicitly removes the default flag from the second video track to prevent playback conflicts.
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.
- In VLC, right-click the video, navigate to Video > Video Track, and select either Main Angle or Alternative Angle.
- In MPV, press the
_key (underscore) to cycle through the available video tracks.