Change Video Rotation Metadata in FFmpeg

Rotating a video by re-encoding its physical pixels is a slow, CPU-heavy process that can degrade video quality. This article explains how to instantly change a video’s orientation (such as rotating it 90, 180, or 270 degrees) using FFmpeg by modifying only its metadata, leaving the underlying video stream untouched and preserving original quality.

The FFmpeg Command for Metadata Rotation

To rotate a video using metadata, you use the stream metadata option (-metadata:s:v) combined with the stream copy flag (-c copy). This tells FFmpeg to write the rotation instruction into the file header and copy the video data without re-encoding it.

Run the following command in your terminal:

ffmpeg -i input.mp4 -metadata:s:v rotate="90" -c copy output.mp4

Command Breakdown

How to Reset or Clear Rotation Metadata

If a video plays sideways because of an incorrect rotation tag, you can reset the rotation metadata to zero with this command:

ffmpeg -i input.mp4 -metadata:s:v rotate="0" -c copy output.mp4

Important Considerations