diff --git a/src/osgPlugins/avfoundation/OSXAVFoundationVideo.mm b/src/osgPlugins/avfoundation/OSXAVFoundationVideo.mm index c7aed2782..ce26d0ddb 100644 --- a/src/osgPlugins/avfoundation/OSXAVFoundationVideo.mm +++ b/src/osgPlugins/avfoundation/OSXAVFoundationVideo.mm @@ -1,6 +1,7 @@ #include "OSXAVFoundationVideo.h" -#include +#include +#include #include #include @@ -16,6 +17,7 @@ #include "OSXAVFoundationCoreVideoTexture.h" + namespace { static NSString* toNSString(const std::string& str) @@ -353,8 +355,27 @@ void OSXAVFoundationVideo::open(const std::string& filename) AVAssetTrack* track = [tracks objectAtIndex:i]; size = track.naturalSize; _framerate = track.nominalFrameRate; + + CGAffineTransform txf = [track preferredTransform]; + + osg::Matrixf mat; + mat.makeIdentity(); + + if(!CGAffineTransformIsIdentity(txf)) + { + // user should take this into account and transform accordingly... + mat(0,0) = txf.a; + mat(1,0) = txf.c; + mat(3,0) = txf.tx; + + mat(0,1) = txf.b; + mat(1,1) = txf.d; + mat(3,1) = txf.ty; + } + + this->setUserValue("preferredTransform", mat); } - + _s = size.width; _t = size.height; _r = 1;