anandnet / flutter_video_info

A flutter plugin to get basic metadatainfo of a video file.
https://pub.dev/packages/flutter_video_info
MIT License
9 stars 25 forks source link

Provide video orientation in iOS also #9

Closed elaunch-keval closed 3 years ago

elaunch-keval commented 3 years ago

I checked plugin iOS code but i did't find code for orientation.

For reference : https://gist.github.com/wdcurry/433dd1db8f315cf6edd9ff8d2ee6f411

anandnet commented 3 years ago

@keval-d thanks for your reference it helped a lot, I have added this in the new version

elaunch-keval commented 3 years ago

This solved my issue.

jsonObj["orientation"] = String(videoOrientation(tracks: tracks))

private func videoOrientation(tracks :[AVAssetTrack]) -> Int {
        if let videoTrack = tracks.first {
            let txf = videoTrack.preferredTransform
            return Int(Double(atan2(txf.b, txf.a) * 180) / Double.pi)
        }
        return 0
    }