Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Videos recorded in portrait gets snapshots distorted for rotation metadata as '-90' #509

Open
Hagfjall opened this issue Mar 30, 2024 · 0 comments · May be fixed by #510
Open

Videos recorded in portrait gets snapshots distorted for rotation metadata as '-90' #509

Hagfjall opened this issue Mar 30, 2024 · 0 comments · May be fixed by #510

Comments

@Hagfjall
Copy link

Movies I record on Samsung Galaxy S23 in portrait mode have this metadata (only showing related data):

$ ffprobe -print_format json -loglevel error  -show_format -sexagesimal -show_streams ./20240330_072509.mp4 | jq '.streams[] | {coded_width, coded_height, side_data_list}'
{
  "coded_width": 1280,
  "coded_height": 720,
  "side_data_list": [
    {
      "side_data_type": "Display Matrix",
      "displaymatrix": "\n00000000:            0       65536           0\n00000001:       -65536           0           0\n00000002:            0           0  1073741824\n",
      "rotation": -90
    }
  ]
}

Note the rotation is -90.

When I run

public static async Task<bool> SnapshotAsync(string input, string output, Size? size = null, TimeSpan? captureTime = null, int? streamIndex = null, int inputFileIndex = 0)
with only width as Size (to keep aspect ratio) the result gets distorted.
Reason is most likely due only checking the positive numbers of rotation here:
if (source.PrimaryVideoStream.Rotation == 90 || source.PrimaryVideoStream.Rotation == 180)

Hagfjall added a commit to Hagfjall/FFMpegCore that referenced this issue Mar 30, 2024
Some video-files have their metadata as -90 instead of 90. This PR handles correct aspect-ratio and rotation when taking snapshots.

The sample video provided in the PR is my own recording. A bit too big maybe? I couldn't find any command to set the metadata to `-90` on existing video. Would be happy to get it working on already existing test-data to reduce size.

Fixes rosenbjerg#509
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 a pull request may close this issue.

1 participant