Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trying to add a timecode track in my movie import component.



The TimeCodeDescription looks fine to me. I'm guessing you've already double-checked that you're filling in the timecode record that you pass in to TCTimeCodeToFrameNumber() with the correct time value. Does QuickTime Player also display the same incorrect timecode value for the first frame (you can display the timecode in QuickTime Player by using TCSetTimeCodeFlags() to set the tcdfShowTimeCode bit in the timecode flags, and making sure that the timecode track is enabled)?

On Sep 8, 2006, at 7:04 PM, Robert Monaghan wrote:

I get a timecode track now, but the times are consistently wrong. (Consistent, but wrong.. :)

For example, if I do:

err = TCTimeCodeToFrameNumber(tcHandler, &(**tcDesc).timeCodeDef, &tcRecord, *tcRecordHandle);
**tcRecordHandle = EndianU32_NtoB(**tcRecordHandle);
err = AddMediaSample2(....


and a timecode of: 01:03:02:00 for my start frame, Final Cut Pro 5.1.1 reports it to be: 04:21:41:08
Subsequent frames are sequential listed in the timecode track, which is good. But the start time is completely wrong..
Here is how I build the TimeCodeDescription.. maybe something is wrong, there..


	OSErr err = noErr;
	TimeCodeDescriptionHandle timecode;
	TimeCodeDescriptionPtr tcdp;
	UInt32 size;
	Str255 tcSrcName;
	UserData tcUserData;
	size = sizeof(TimeCodeDescription);
	timecode = (TimeCodeDescriptionHandle)NewHandleClear(size);
	if (err = MemError()) goto bail;
	
	tcdp = *timecode;
	tcdp->descSize = size;
	tcdp->dataFormat = TimeCodeMediaType;
	tcdp->dataRefIndex = 1;
	tcdp->flags = 0;
	
	tcdp->timeCodeDef.flags = tc24HourMax | tcNegTimesOK;
	tcdp->timeCodeDef.fTimeScale = 2400;
	tcdp->timeCodeDef.frameDuration = 100;
	tcdp->timeCodeDef.numFrames = 24;
	
	tcdp->srcRef[0] = 0;
	

strncpy((char *)&tcSrcName[1],"My Time Code Track", 21);
tcSrcName[0] = 21;
err = NewUserData(&tcUserData);
if (err == noErr)
{
Handle tcNameHandle = NULL;
err = PtrToHand(&tcSrcName[1], &tcNameHandle, tcSrcName[0]);
if (err == noErr)
{
err = AddUserDataText(tcUserData, tcNameHandle, TCSourceRefNameType, 1, langEnglish);
if (err == noErr)
TCSetSourceRef(*tcHandler, timecode, tcUserData);
}

if (tcNameHandle != NULL)
DisposeHandle(tcNameHandle);

DisposeUserData(tcUserData);
}


Beyond that.. I really can't see what the problem is..

More testing..

Again, if anyone sees something, let me know..
Thanks Sayli!!

bob..



On Sep 8, 2006, at 2:10 PM, Sayli Benadikar wrote:

Hi Bob,

BeginMediaEdits() definitely needs to be called before you call AddMediaSample2() to add the timecode samples to the timecode media.

You mentioned that you tried passing in an empty handle dataref when creating the new media but this didn't work...
Passing in an empty Handle Data Reference Handle to NewTrackMedia (so that the timecode media is created in memory) should work. Here's how you'd create the handle data reference handle and the new media:


	Handle						timeCodeDataRef = nil;
	OSType 						atomHeader[2];

// create a Handle Data Reference Handle - see Tech Note 1195: Tagging
// Handle and Pointer Data References in QuickTime for more information
timeCodeDataRef = NewHandleClear(sizeof(Handle) + 1);
if (err = MemError()) goto bail;
atomHeader[0] = EndianU32_NtoB(8);
atomHeader[1] = EndianU32_NtoB(OSTypeConst('data'));
err = PtrAndHand(atomHeader, timeCodeDataRef, 8);
if ( err ) goto bail;

// create media for the timecode track
timeCodeMedia = NewTrackMedia(/* the timeCodeTrack*/, TimeCodeMediaType, /* the timeCodeMediaTimeScale*/, timeCodeDataRef, HandleDataHandlerSubType);
if (err = GetMoviesError()) goto bail;
DisposeHandle(timeCodeDataRef);
timeCodeDataRef = nil;


When filling out the TimeCodeDescription struct, you set the dataRefIndex to 1 (indexes are 1-based), to indicate that the first (and, in this case, the only) dataref in the timecode media is the one that contains the required sample data.

HTH,
Sayli Benadikar
QuickTime Engineering


On Sep 7, 2006, at 10:53 PM, Robert Monaghan wrote:

Nope.. tried that..

This is what I found that might be the problem.. found this via Google..

typedef struct TimeCodeDescription {
long descSize; /* size of the structure */
long dataFormat; /* sample type */
long resvd1; /* reserved--set to 0 */
short resvd2; /* reserved--set to 0 */
short dataRefIndex; /* data reference index */
long flags; /* reserved--set to 0 */
TimeCodeDef timeCodeDef; /* timecode format information */
long srcRef[1]; /* source information */
} TimeCodeDescription, *TimeCodeDescriptionPtr, **TimeCodeDescriptionHandle;


dataRefIndex - Contains an index value indicating which of the media's data references contains
the sample data for this sample description



So, when I set up my TimeCodeDescription, what should I put for a dataRefIndex value? (And will this even matter?)


bob..


On Sep 7, 2006, at 10:42 PM, Steve Israelson wrote:

Call BeginMediaEdits (or whatever?)

On 7-Sep-06, at 10:43 PM, Robert Monaghan wrote:

Howdy all!

I am trying to create a timecode track for a movie, as it is being imported. When I run the code, it returns: -2050 badDataRefIndex.. It stops at AddMediaSample2, with this error. From reading what little I can find on Apple's site, the errors appear to be caused by NewTrackMedia not having a data reference. So.. if I supply a data reference from my video track, or an empty handle as a data ref, I get: -2043 dataNotOpenForWrite.

Here is a snippet of code, based upon Electric Image movie importer..

if ((tcTrack == NULL) && (doTimeCode)) {
// Create a new timecode track
tcTrack = NewMovieTrack (theMovie, // Specify the Movie
(**videoDesc).width << 16, // A fixed denoting width of the track, in pixels.
(**videoDesc).height << 16, // A fixed denoting height of the track, in pixels
kNoVolume); // Specifies the volume setting of the track, kNoVolume = 0


// Create a media for the track. The media refers to the actual data samples used by the track.

tcMedia = NewTrackMedia (tcTrack, // Specifies the track for this operation
TimeCodeMediaType, // Type of media to create
kTimeScale, // Set the time scale, this defines the media's time coordinate system
NULL, // Specifies the data reference
0); // Specifies the type of data reference
if (err = GetMoviesError()) goto bail;


                        tcHandler = GetMediaHandler(tcMedia);
                        if (tcHandler == NULL)
                                goto bail;

}
....
Get my timecode records and tc defs built.
....
SetTrackEnabled(tcTrack, TRUE);
err = TCTimeCodeToFrameNumber(tcHandler, & (**tcDesc).timeCodeDef, &tcRecord, *tcRecordHandle);
**tcRecordHandle = EndianS32_NtoB (**tcRecordHandle);


err = AddMediaSample2(tcMedia, // Specifies the media for this operation
(UInt8 *)*tcRecordHandle,
(ByteCount)GetHandleSize((Handle)tcRecordHandle),
frameDuration,
0,
(SampleDescriptionHandle)tcDesc, // Handle to a sample description
1, // Specifies the number of samples contained in the reference
0, // Contains flags that control the operation
NULL); // Returns the time to Decode sample. NULL for now.




I hope someone can point me in the right direction.

Bob..

_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-api/sisraelson% 40mac.com


This email sent to email@hidden


_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-api/sayli% 40apple.com


This email sent to email@hidden



_______________________________________________ Do not post admin requests to the list. They will be ignored. QuickTime-API mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/quicktime-api/email@hidden

This email sent to email@hidden
References: 
 >Trying to add a timecode track in my movie import component. (From: Robert Monaghan <email@hidden>)
 >Re: Trying to add a timecode track in my movie import component. (From: Steve Israelson <email@hidden>)
 >Re: Trying to add a timecode track in my movie import component. (From: Robert Monaghan <email@hidden>)
 >Re: Trying to add a timecode track in my movie import component. (From: Sayli Benadikar <email@hidden>)
 >Re: Trying to add a timecode track in my movie import component. (From: Robert Monaghan <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.