Strip Rotation Metadata from MP4 with FFmpeg

This article explains how to quickly remove rotation metadata from an MP4 video file using FFmpeg. You will learn the exact command-line instructions to clear orientation tags without re-encoding your video, ensuring the process is both lossless and fast.

Why MP4 Files Have Rotation Metadata

Smartphones and cameras often record video sideways or upside down, saving a “rotation” flag (such as 90, 180, or 270 degrees) in the metadata instead of physically rotating the pixels. While modern players read this tag and rotate the video automatically during playback, some older players or editing software ignore it, causing the video to display incorrectly. Removing this metadata resets the video to its natural orientation.

Method 1: Resetting the Rotation Metadata (Lossless & Fast)

The fastest way to strip the rotation metadata is to set the rotation tag to zero while copying the video and audio streams. Because this method does not re-encode the video, it takes only a few seconds and preserves original quality.

Run the following command in your terminal:

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

Command breakdown: * -i input.mp4: Specifies your source video file. * -c copy: Directs FFmpeg to stream-copy the video and audio without re-encoding them. * -metadata:s:v:0 rotate=0: Targets the metadata of the first video stream (s:v:0) and sets the rotate value to 0 (or clears it). * output.mp4: The name of your new file without the rotation tag.

Method 2: Removing Display Matrix Side Data (FFmpeg 6.0+)

In newer versions of FFmpeg, rotation data may be stored as display matrix side data rather than a traditional metadata tag. To strip this side data entirely, use the side_data_filter:

ffmpeg -i input.mp4 -c copy -bsf:v extract_extradata -side_data_filter remove -rem_side_data displaymatrix output.mp4

This command permanently discards the display matrix side data, forcing players to render the video in its raw, unrotated format.