Advertisement

Tutorials7 min read

Fix a Sideways Video So Every Player Agrees

A clip plays upright everywhere except the one place that matters. Nothing is broken: two pieces of software disagreed about a rotation flag in the metadata. Baking the rotation into the pixels removes the disagreement entirely, and asks nothing of whatever software comes next.

By · Part of the Browser-local editing workflows topic cluster

A video plays upright on your phone, upright in your photo app, and sideways the moment you upload it. Nothing is broken. Two pieces of software disagreed about a number in the file, and the one that disagreed was the one your audience is using.

The rotate tool fixes this by removing the disagreement entirely.

Why a video can be sideways in one place and not another

Phones do not physically rotate their sensor when you turn them. They record the frames in the sensor's own orientation and write a rotation value into the file's metadata that says, in effect, "display this turned 90 degrees".

Players that read that value show the video upright. Players that ignore it show the raw frames, which are sideways.

Most consumer players read it. Plenty of other software does not, or reads it inconsistently: older editors, some upload pipelines, some frame-extraction tools, some social platforms' transcoders. That is why the problem appears at the worst moment, after upload, rather than while you were checking your work.

The same mechanism explains the stranger version of this bug, where a video is upright in the preview and sideways in the exported result. Something in the chain honoured the flag and something else did not.

Baking the rotation into the pixels

This tool rotates by 90, 180 or 270 degrees and writes the rotation into the frames themselves rather than into a metadata flag.

After that there is nothing left to interpret. The frames are stored the way they should be displayed, the orientation metadata is no longer load-bearing, and a player that ignores metadata entirely still shows the video the right way up.

That is the whole value. A metadata-only fix asks every future piece of software to cooperate. Baking it asks nothing of anybody.

The cost is that the video is re-encoded, because you cannot change the pixels without rewriting them. Which leads to the one thing worth planning.

Do it once, from the best source

Re-encoding is lossy. A rotate is one generation of loss, which is usually invisible and always non-zero.

So rotate the original, not an export of an export, and rotate once. If you are also going to convert, compress, pad or upscale, do those in one sensible sequence rather than rotating, checking, converting, checking, and re-rotating.

For the same reason, rotating a video back and forth is not free. Turning it 90 degrees and then 270 degrees does not return you to the original file. It returns you to a twice-encoded copy of it.

Dimensions swap at 90 and 270

A 1920 by 1080 clip rotated 90 degrees becomes 1080 by 1920. This is obvious in principle and easy to forget in practice, and it matters if anything downstream expects a specific size.

At 180 degrees the dimensions stay the same, which makes it the cheap case conceptually even though it still re-encodes.

If the resulting shape is not what your destination wants, that is a separate problem with a separate tool: pad it with the canvas extender rather than cropping to force the ratio.

Check for the right kind of wrong

Before rotating, be sure the problem is rotation and not mirroring.

A rotated video is the correct image turned. A mirrored video is the correct image flipped, and rotating it will never fix it, because no amount of turning converts a mirror image into the original. Text is the giveaway: if any writing in the frame reads backwards, it is mirrored, not rotated.

Front-facing camera footage is the usual source of mirrored video, since the preview is mirrored so it feels like a mirror, and some pipelines record it that way.

After rotating, verify somewhere else

The fix is only proven by a player other than the one that was already showing it correctly.

The most useful check is the destination itself, or something close to it. Upload the fixed file where the sideways version appeared and confirm. Checking in the same app that already displayed it upright tells you nothing, because that app was reading the metadata flag all along and would have been happy either way.

Nothing is uploaded

The rotation happens on your device. The file is not sent anywhere to be turned around, which for personal video, client footage, or anything unreleased is the difference between a tool you can use and one you cannot.

A short method

  1. Confirm it is rotated and not mirrored: look for text reading backwards.
  2. Start from the original file, not from a re-export.
  3. Rotate once, by the amount that makes it upright.
  4. Expect the dimensions to swap at 90 and 270 degrees.
  5. If the new shape is wrong for the destination, pad it rather than cropping.
  6. Verify in the place the problem appeared, not in the app that was already fine.

Applies to NSS Background Remover v2.6.2, the release that was current when this article was published.

Was this article helpful?

Your answer is saved in this browser only. This control makes no network request and does not send the answer to an NSS feedback endpoint.

Found this useful?