Movies and Menus
Subject:   Movie Dimensions...
Date:   2003-01-28 15:38:36
From:   below

here is the requested source code to find out the Dimensions of a movie. This is pure 'C', not Objective-C, and it uses Carbon, as this sort of functionality is not yet present in Cocoa.
I stripped it of all comments for size, but if you have any questions mail me: below-at-mac-dot-com.
This is based on Apple sample code, hidden well somewhere in the Dev Info...


code starts here ----->
#include <Carbon/Carbon.h>
#include <QuickTime/QuickTime.h>

#include "QTUtils.h"

Boolean QTUtils_MovieSize (Movie theMovie, Rect * movieRect)
OSErr myErr = paramErr;
short trackCount, index;

if (theMovie == NULL)

trackCount = GetMovieTrackCount(theMovie);

for(index = 1; index <= trackCount; index++)
Track aTrack = NULL;
Media aMedia = NULL;
OSType aMediaType;

aTrack = GetMovieIndTrack(theMovie, index);
aMedia = GetTrackMedia(aTrack);
myErr = GetMoviesError();
if(myErr != noErr)
printf("Problems with getting trackmedia = %d\n", myErr);
return false;

GetMediaHandlerDescription(aMedia, &aMediaType, 0, 0);
if(aMediaType == VideoMediaType) // We just want to check the video media samples.
SampleDescriptionHandle anImageDesc = NULL;
anImageDesc = (SampleDescriptionHandle)NewHandle(sizeof(SampleDescription));
GetMediaSampleDescription(aMedia, 1, anImageDesc);
myErr = GetMoviesError();

if(myErr != noErr)

long rest;

movieRect->top = 0;
movieRect->left = 0;

movieRect->bottom = (*(ImageDescriptionHandle)anImageDesc)->height;
movieRect->right = (*(ImageDescriptionHandle)anImageDesc)->width;

return true;