AlexEidt / Vidio

FFmpeg wrapper providing simple, cross-platform Video I/O, GIF Creation, and Webcam Streaming in Go.
https://pkg.go.dev/github.com/AlexEidt/Vidio
MIT License
351 stars 16 forks source link

Add check for rotate tag #12

Closed lgaribaldi closed 10 months ago

lgaribaldi commented 10 months ago

When a video has a "rotate" tag in metadata, the video player rotates when playing the video, giving it a portrait perspective. Because of this, the width is still larger than height even in a portrait video. Which causes the stride to be off and the resulting frame to be scrambled. This can be fixed by inverting the width and height of the video when there is a rotation.

Related to #10

AlexEidt commented 10 months ago

Looks good. Thanks for the fix, just add some parentheses for operator precedence and I'll merge. I understand that the expression will evaluate correctly, I just find the intent more clear with the parentheses.

if rotation, ok := data["tag:rotate"]; ok && (rotation == "90" || rotation == "270") {
video.width, video.height = video.height, video.width
}