• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Q] How to retrieve FourCC code for a video track?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Q] How to retrieve FourCC code for a video track?


  • Subject: Re: [Q] How to retrieve FourCC code for a video track?
  • From: JongAm Park <email@hidden>
  • Date: Fri, 7 Aug 2009 10:55:00 -0700

Well.... I would answer to my own question..

With help of a "dumpster", I figured out where the codec fourCC was stored and what data chunk should be retrieved.
So....

QTMovie *movie;
NSError *error;
NSURL *movieFileURL;
NSDictionary *movieAttributes;

NSString *samplePathURL = [NSString stringWithString:@"file://localhost/Volumes/Work/Sample Video/pimpmyride_DVCPROHD-720p60-dvhp.mov"];

NSString *trimmedURL = [samplePathURL stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSRange fileLocalHostRange = [trimmedURL rangeOfString:@"file://localhost" options:NSLiteralSearch];
fileLocalHostRange.location; fileLocalHostRange.length;

NSString *finalPathString = [trimmedURL substringFromIndex:fileLocalHostRange.location+fileLocalHostRange.length];

//movieFileURL = [NSURL fileURLWithPath:@"/Volumes/Work/Sample Video/pimpmyride_DVCPROHD-720p60-dvhp.mov"];

movieFileURL = [NSURL fileURLWithPath:finalPathString];
movie = [QTMovie movieWithURL:movieFileURL error:&error];

BOOL isVideoTrack = NO;

if (movie)
{
NSMutableString *trackFormatStr = [NSMutableString string];

NSArray *tracksArray = [movie tracks];
int i, tracks = [tracksArray count];
for (i=0; i<tracks; ++i)
{
QTTrack *track = [tracksArray objectAtIndex:i];

NSDictionary *attribute = [track trackAttributes];
NSString *trackTypeString = [attribute objectForKey:QTTrackDisplayNameAttribute];
isVideoTrack = [trackTypeString isEqualToString:@"Video Track"];

if( isVideoTrack )
{
NSString *codecString = [attribute objectForKey:QTTrackFormatSummaryAttribute];
NSRange aRange;

NSLog( @"Track %d : %@", i, codecString );

aRange = [codecString rangeOfString:@"DVCPRO HD 720p60"];

if( aRange.location != NSNotFound )
NSLog( @"dvhp");

/************** From here, it will retrieve the SampleDescriptionHandle *******************/
QTMedia *videoMedia = [track media];
NSDictionary *mediaAttribute = [videoMedia mediaAttributes];
NSLog(@"media attribute : %@", mediaAttribute );
SampleDescriptionHandle videoTrackDescH = (SampleDescriptionHandle)NewHandle( sizeof(Handle) );

GetMediaSampleDescription([videoMedia quickTimeMedia], i, videoTrackDescH );

NSLog(@"depth : %d",(*(ImageDescriptionHandle)videoTrackDescH)->depth );
NSLog(@"width : %d",(*(ImageDescriptionHandle)videoTrackDescH)->width );
NSLog(@"height : %d",(*(ImageDescriptionHandle)videoTrackDescH)->height );
NSLog(@"name : %s",(*(ImageDescriptionHandle)videoTrackDescH)->name );

NSLog(@"codec : %d",(*(ImageDescriptionHandle)videoTrackDescH)->cType );
char codecType[5];
bzero(codecType, 5);
OSType codecTypeNum;

memcpy((void *)&codecTypeNum, (const void *)&((*(ImageDescriptionHandle)videoTrackDescH)->cType), 4);
codecTypeNum = EndianU32_LtoB( codecTypeNum );

memcpy(codecType, (const void*)&codecTypeNum, 4);
NSLog(@" == %s", codecType );
/**************************************************************/

}
}

}

By the way, is there any safe way to remove the line where NewHandle() is called? Because it is not recommended to be used, I would like to remove it.
However, GetMediaSampleDescription() call looks to ask an allocated new handle.

Thank you.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Pro-apps-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: [Q] How to retrieve FourCC code for a video track?
      • From: Darrin Cardani <email@hidden>
  • Prev by Date: [Q] How to retrieve FourCC code for a video track?
  • Next by Date: how trims & cuts effect reference image wells
  • Previous by thread: [Q] How to retrieve FourCC code for a video track?
  • Next by thread: Re: [Q] How to retrieve FourCC code for a video track?
  • Index(es):
    • Date
    • Thread