Re: Text track in QTMovie
Re: Text track in QTMovie
- Subject: Re: Text track in QTMovie
- From: Joe Turner <email@hidden>
- Date: Sat, 20 Dec 2008 16:31:42 -0600
Okay, I took your suggestions. It seems that my array of characters is
the issue. My ByteCount s and other variables have seemingly correct
values, but the array of chars' value does not change from before it
gets written to. So, I tried a few more ways and no luck.
I tried using a UInt8 *chars = malloc(size)
char *chars = malloc(size). But still no luck.
I have a feeling that it has to do with how I initialize it.
K&R is coming this week, so, that should help me too (thanks for the
recommendation!!).
Thanks a ton!
Joe
On Dec 16, 2008, at 1:28 PM, douglas welton wrote:
Hi Joe,
My suggestions:
1) write a small application that test your routine before you give
it someone else to use. given the code you already have doing this
should take all of 5 minutes. Once you do this, you can use the
debugger and find your boo-boos. I suspect they will be quite
obvious.
2) GetMediaSample2 returns an error code. However, the code in your
email does not check the returned value. Making an assumption that
the function has completed without an error may not be in your term
best interest ;^}
3) chars[] is not a C function call. K&R is your friend!
regards,
douglas
On Dec 16, 2008, at 1:40 PM, Joe Turner wrote:
Sorry for taking so long.
Okay, what I am looking for is the contents of the text track.
Like, for a movie, it would be the chapter names and times.
The issue is that I am making this for someone who is using
AppleScript, and is just using a call method on my method to do
this. So, the Debugger will not stop at my breakpoints (I thought
it did, even if it is being called by a call method).
Anyways, I guess what I am looking for is an error in the code I
have created. Like, am I passing something wrong? Am I trying to
parse something as a different format than it is? I can create a
new project and do this and tell you the debugger contents too
though, if needed.
I am used to objective-c, and some of these C calls can confuse me
sometimes. Like, is chars[] the same thing as a UInt8?
Thanks for your help,
Joe
On Dec 14, 2008, at 8:54 PM, douglas welton wrote:
when you say it won't show you the "track names" do you mean:
a) your NSLog() function is failing and nothing is printed
b) NSLog() prints something, but the value of string appears to be
either nil or empty (which one?)
c) you really want the name of the track (i.e., the thing
displayed in the QT Player) and not the text in each sample. If
this is the case then we have to do something entirely different ;^}
d) all of the function calls succeed and when examined in the
debugger you can see the values for size and chars[] are valid but
your NSString cannot be properly constructed.
Can you clarify? BTW, what values are you seeing in the debugger?
On Dec 14, 2008, at 8:33 PM, Joe Turner wrote:
Okay, so I did what you said, but yet, it still won't show me the
track names. Here is my code:
Media media = [[[[[movieView movie]
tracksOfMediaType:QTMediaTypeText] objectAtIndex:0] media]
quickTimeMedia];
TimeValue64 timeValue = 0;
TimeValue64 duration = 0;
GetMediaNextInterestingDecodeTime(media, nextTimeMediaSample +
nextTimeEdgeOK, timeValue, fixed1, &timeValue, &duration);
ByteCount size;
GetMediaSample2(media, NULL, 0, &size, timeValue, NULL, NULL,
NULL, nil, nil, 1, NULL, NULL);
char chars[size];
GetMediaSample2(media, &chars, size, NULL, timeValue, NULL,
NULL, NULL, nil, nil, 1, NULL, NULL);
NSString *string = [[NSString alloc] initWithBytes:chars
length:size encoding:NSUTF8StringEncoding];
NSLog(@"String: %@", string);
Thanks,
Joe
On Dec 14, 2008, at 7:03 PM, douglas welton wrote:
Hi Joe,
Since you didn't define "easy" or tell me what you'd tried, then
I'll have to make some assumptions about what you know. I will
assume that you have read the documentation on QT media samples.
The basic steps:
Get the text track.
Get the track media.
loop thru the media samples using a function like
GetMediaNextInterestingDecodeTime() with the parameters of your
choice
Use GetMediaSample2() to get the data/length associated with
the text sample.
Create an NSString with the bytes/length returned in the
previous call
regards,
douglas
On Dec 14, 2008, at 7:26 PM, Joe Turner wrote:
I have a QTMovie (that is valid), and it has a text track. I am
wondering if there is any easy way to get the contents of the
text track into an NSString.
Thanks,
Joe
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden