Skip to content

Conversation

@arturjpv
Copy link

@arturjpv arturjpv commented Jun 5, 2025

When using recordings from mobile phones with vertical aspect ratios, the dimensions of the video can be encoded in a non standard resolution, adding additional information in a SAR / DAR section.

For example:

Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1080x720 [SAR 3:8 DAR 9:16], 1743 kb/s, 29.92 fps, 29.92 tbr, 90k tbn (default)

or with rotation information

Stream #0:2[0x3](eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 1920x1080, 20286 kb/s, SAR 1:1 DAR 16:9, 29.99 fps, 30 tbr, 90k tbn (default)
...
  displaymatrix: rotation of -90.00 degrees

Use SAR information to calculate the size of the output images. In the first example, 1080x1920.
Swap width and height if we find rotation information of -90 or 90 degrees.

The testing of this code has not been exhaustive, I have only tested it with vertical/horizontal recordings of a couple of Android phones, but videos with no SAR/DAR information encoded should not be affected.

@arturjpv arturjpv changed the title Feature/non standard resolutions Add support for non standard resolutions Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant