VionetoVioneto
Back to the magazine

VIONETO MAGAZINE Playback & technology

Check MP4 orientation with ffprobe and the display matrix

Use ffprobe to distinguish the encoded frame size from display rotation, then check how your target player shows the video.

Two film frames show a bicycle in upright and sideways orientations.
Illustration for aligning a video file.Image: Vioneto · AI-generated illustration

A phone video appears upright in one app and sideways after export. Check both the encoded frames and the instructions for displaying them. In an MP4, a display matrix can describe rotation. The track’s width and height give you the encoded dimensions.

Inspect the video track for a display matrix

Select the track you want to inspect. This command reports the first video track as JSON and leaves the input file unchanged. If your file has several video tracks, select the one that has the problem.

ffprobe -v error -select_streams v:0 -show_streams -of json datei.mp4

Vioneto example

Look at width and height, then look for rotation in a display matrix in side_data_list. Record the value and identify which way a prominent detail should point. Check that detail in the player to confirm what the viewer sees.

Compare two versions of one test clip

We made a two-second clip with a white marker in the upper-left corner. The second MP4 copies the encoded video packets and adds a 90° display matrix. All 24 packet hashes matched in order.

  • Both tracks report 320 × 180 encoded pixels.
  • The second MP4 also reports a 90° display matrix.
  • When FFmpeg applies the rotation, decoding produces a 180 × 320 frame.
  • With automatic rotation disabled, the same file decodes at 320 × 180.

Identify the point where orientation changes

Check the source and export with the same method. If their encoded dimensions are already swapped, the edit or export may have rotated the pixels. When the difference appears only with a display matrix, check whether the target app applies that metadata.

If needed, export a short test clip with a clear top edge and open it in your target player. If you also export still frames, check their orientation and look for remaining rotation metadata. A second rotation can bring the problem back.

These observations come from a local FFmpeg test. A transcoder, browser player and thumbnail pipeline can handle rotation differently. Test the actual published version your viewers will open.

ffprobe documentation: stream inspection

FFmpeg documentation: video and rotation options

Understand encoded dimensions and aspect ratio

Topics

Sources and further reading

  1. https://ffmpeg.org/ffprobe.html
  2. https://ffmpeg.org/ffmpeg.html