ROTATION & METADATA

A sideways phone video: rotation metadata versus real pixels

A measured look at display matrices: stream copy can keep a phone video upright, stripping the flag exposes the same pixels sideways, and transpose bakes the rotation in.

A person holding a smartphone upright to record two people in a room
Illustrative stock photo: Ron Lach / Pexels. The photo is not a screenshot demonstrating the steps in this guide.
AT A GLANCE

A phone video can be upright because of a rotation flag, not because its pixels are upright. Keep the flag for a lossless copy; rotate the pixels when the receiving app ignores it.

The picture and the instruction are separate

A phone held vertically may record a landscape sensor frame and write a display matrix that tells the player to turn it. The encoded frame can be 640×360 while the upright presentation is 360×640. The pixels did not move. The file carries an instruction about how to present them.

This is convenient during capture: the phone does not have to re-encode the whole frame when the device turns. It becomes confusing during editing. One application honours the matrix, another ignores it, and a third applies it twice. A viewer may call the file “sideways” while the encoded frame is still perfectly valid landscape video.

The test used a short synthetic clip with a coloured corner marker. One copy carried a 90-degree display matrix, one had the flag removed, and one had its pixels physically transposed. The encoded payload stayed identical between the first two copies.

Same payload, three presentations

FileCoded frameDisplay matrixDecoded presentationBytes
Flagged640×360−90°360×640, upright12,243
Flag stripped640×360None640×360, sideways12,243
Pixels transposed360×640None360×640, upright12,178

The flagged and stripped files had the same video stream hash. Removing the flag did not delete or reorder a single encoded picture packet; it removed the instruction that made the landscape pixels display upright. The transposed file had a new coded frame and no matrix, which is why it survived in applications that ignore rotation side data.

The transposed picture was one H.264 generation away from the flagged presentation and measured 57.54 dB average PSNR against it. Decoding the flagged stream to raw frames and re-encoding the same rotation produced a stream hash identical to the transposed export. That is a useful control: the physical rotation itself was deterministic; the difference came from re-encoding.

Conceptual diagram for Sideways video: flag or pixels?
Original ToolWillow diagram. Illustrated concept, not measured product results.

The sign of the number is not the direction

FFmpeg’s -display_rotation option is easy to misread. In the test, -display_rotation 270 before the input wrote side data of rotation: -90, which displayed the scene upright. -display_rotation 90 wrote +90 and produced a portrait image that was upside down for this source. A positive number is not a synonym for clockwise.

Do not copy a rotation number from a forum post without checking the actual file. Inspect the decoded frame, not only the metadata value. The same warning applies to phone apps that offer “rotate left” and “rotate right”: one may change a flag, another may render new pixels, and a third may only change the preview.

Useful check

ffprobe -v error -show_streams -of json input.mp4 can show a rotation value under side_data_list. Compare that value with the decoded frame dimensions and the way two different applications present the file. Metadata alone does not prove the viewer will honour it.

What the three common repairs actually do

OperationWhat changesRe-encode?Best use
Keep the display matrixNothing in the payload; the player is told how to present itNo, with stream copyArchive or handoff to software that honours the flag
Strip or rewrite the matrixPresentation instruction onlyNo, with stream copyCorrect a wrong flag, but verify the result because the pixels do not move
Transpose the pixelsThe coded frame is reordered and re-encodedYesCompatibility with an app that ignores rotation metadata

A stream copy is fast and preserves the encoded picture, but it cannot make an app honour a flag. A transpose is slower and introduces a generation of lossy encoding, but the orientation is now in the pixels. Neither operation fixes a tilted horizon. That is a separate geometric correction, and it usually requires cropping or filling the corners.

Why the same file looks right in one app and wrong in another

There are four common failure patterns. First, the player ignores the display matrix and shows the coded frame. Second, an editor reads the flag on import but writes a new file without it, so the export is sideways. Third, an app applies the phone’s orientation and the file’s matrix, producing a double rotation. Fourth, a preview shows a cached thumbnail that was generated before the file was changed.

Diagnose in this order: inspect the coded dimensions and matrix; decode one frame with a tool that reports its output size; open the same file in two independent players; then import it into the destination editor and inspect the timeline, not just the source browser. If the timeline is upright but the export is sideways, the problem is in the export path, not the original file.

Do not “fix” a file by rotating it repeatedly until one preview looks correct. Record the starting state and work on a copy. Rotation is lossy when it re-encodes, and repeated exports accumulate damage.

When to keep the flag and when to bake it in

Keep the flag when the destination is a modern player, a phone, or an editor that has already handled the file correctly. It is the smaller, faster, lossless option. Bake the rotation into the pixels when the destination is a web upload, a simpler device, a presentation tool or an application that has demonstrated it ignores the matrix.

The browser rotator applies the source’s display matrix first, then the rotation or flip you choose, and exports an upright picture without relying on a rotation flag. That makes the result predictable in software that ignores side data. It also means the tool re-encodes and may adjust an odd dimension by one pixel to keep the output even. The tool does not straighten a tilted horizon or fill the corners after a non-right-angle correction.

For a phone clip that is already upright, do not apply an extra 90-degree rotation just because the coded frame is landscape. Check the presentation first. If you need a lossless archive copy, keep the original with its flag rather than repeatedly transcoding it.

A short verification procedure

  1. Copy the original and record its coded dimensions, duration and rotation side data.
  2. Decode one frame and note the displayed dimensions. A 640×360 coded frame with a 90-degree matrix should decode to 360×640.
  3. Open the file in two players that use different decoding paths. Confirm that both show the same orientation.
  4. If the destination ignores the flag, export a transposed copy. Compare a corner marker and a face, not only the thumbnail.
  5. Check the new file’s coded dimensions, side data and duration. The orientation should now be in the pixels.
  6. Play the export in the actual destination before replacing anything.

Download the flagged clip · Flag stripped · Pixels transposed · Flagged frame

The measurements are from desktop FFmpeg 8.1.1. No named phone, messaging app or editor was tested, and different players can interpret rotation side data differently. The practical rule is to verify the presentation, not just the number in the metadata panel.

Common questions

Is a video with a rotation flag lower quality?

The flag itself does not re-encode the picture. It changes presentation instructions. Quality depends on the encoded stream and any later re-encode.

Why does my rotated export still look sideways?

The receiving app may ignore rotation side data, or the export may have dropped the flag. A transposed copy puts the orientation into the pixels instead.

Does rotating a video reduce quality?

A metadata-only rotation with stream copy does not. A pixel rotation requires decoding and re-encoding, which can change quality and file size.

Can I rotate only 90 degrees without re-encoding?

You can change the display matrix without re-encoding, but the coded pixels stay in their original orientation. Apps that ignore the matrix will still show the old orientation.

Sources & further reading

Written for ToolWillow with original explanations and examples. Consult current product documentation for controls that vary by version.

Try the free browser tools →