WWDC2004 Session 214
Transcript
Kind: captions Language: en well welcome to welcome to the session my name is ian ritchie i've had the opportunity of managing part of the quicktime engineering team this last year Ashley for a number of years and we decided to what we in fact something you were here last year and we mentioned that we're working on a new set of cocoa classes for QuickTime and we listen to your concerns we heard in s movie and in its movie view had some issues you want to just to take care of and said well how are we going to do this because we're quicktime engineers we know quicktime inside and out we didn't know a lot about cocoa so we actually the whole team took coco classes and we met with the coco development team holly Ozorne andrew clatter and others and a lot of direction from even executive management on how to work on these classes and we'll explain today what we've come up with you're going to learn about the new AP is that we offer Tim Monroe will come up and talk about the classes will show you some sample code that we worked on we like what could you get working on today you know just to after a few minutes you have it on your DVD and then we'll go into what if you had a few days to work with this some things we came up with these last few days after we finished working on the seed for your DVD that you have and then we have a special guest at the end of this so the old classes in this movie in this movie view when we tried to use these just like you real flash you ran right into carbon you go oh no i've got a idol of movie well i don't know about that and what's a handle you know I since Mac OS 9 most people don't know these or are not used to using these structures and data types so you ran into limitations that we decided to address and of course there were an occasional buggers who than the old classes so you've probably heard Apple explain we're committed to Coco we want you to use cocoa if you're going to develop an application on OS 10 use cocoa and they mean it we develop an application on both OS 10 and Windows the quicktime player and we are committed to developing the quicktime player for let's pan in cocoa explain in a minute how we did that we developed a QuickTime broadcaster a lot of the ayats' that you see iphoto imovie other apps we have an apple are using cocoa so we encourage you all to embrace this technology and Apple is committed to providing access to other parts vos in cocoa classes so we looked at it as a cocoa programmer would we removed all the carbon isms so you can get up and get running in no time with your cocoa background and this next well where possible we adopted the cocoa model there's a few places that will tell you about that we made exceptions and we also provided a new palette to Tim and roll will go through in a little bit that will show you the new functionality so on the abstraction we have to deliver quicktime virtually everywhere we have ninety ninety-five percent of our users are on Windows so when you're developing an application we said well where do we put the code where do we put most of it push it down in a quick time as much as possible and then above this we have two layers we have an activex layer and we have a cocoa layer and these one of the layers here today that we're going to talk about is the cocoa layer that's what we built the player up on both for windows and mac so your application should be relatively quick time agnostic and just use the classes and be able to get up and running in no time I like to introduce now I even wrote some of these things down one of the Apple premieres multimedia engineers this is all imprinting look it up on the internet he is the resonant quicktime guru in many circles an author extraordinaire you've seen many of his articles in and he's also written the QuickTime toolkit volume welcome to i encourage you to run out and get this book let's bring him up now here Tim enroll he's also the tech lead of the QuickTime Coco kid come on a family Thank You Ian what I want to talk about here is briefly go through the kit give you an overview of what classes are in it and then I want to do a real quick demo that shows how to use the kid and then I want to get out of the way so that the really fun demos can come forward so there are five classes in the QuickTime for Coco kit and there are two data structures so let me start down toward the bottom with the data structures because we'll need those when we get to the classes we are providing a data structure called QT time that is going to be our preferred method for indicating a time or a duration in a QuickTime movie and you can see there is three fields here a time value and the time value is interpreted relative to the time scale which is the number of time units per second and finally we've added a flag field here and this allows us to do some interesting things like indicate that a time that we're passing back to you is not really a valid time or is perhaps an indefinite time this might happen for instance if you ask for the duration of a streaming movie we don't it doesn't really have a duration so we might pass you back the flag that it's indefinite you can see the QT time is indefinite like they're so we have a bunch of utilities for creating QT time structures for adding them together for comparing them we've tried to do everything as much as possible in the cocoa flavor and there are two predefined QT time structures that you'll be working with namely cutie zero time which is a zero time or duration with a non zero time scale and then the Qt indefinite time which has that flag that fits it and flag if you take two to QT time structures try that fast and put them together you have a cutie time range and that indicates a start time of the range and the duration of the range and once again we have a number of utility functions that you can use to operate on time ranges for instance QT time in time range will give you back up boolean value and finally we have added categories on the NS coder class that allow you to encode or decode QT time ranges and QT times trucks so when you archive or on archive objects you can add these items in so let's get to the classes now the main class you want to work with is QT movie this represents a cutie movie and movie controller we don't see any use in separating those two items into separate classes there are quite a number of ways to create a cutie movie instance I've got some of them listed here if you have a movie in a file you can give us a file name if you have a URL will take that if you have what a cutie data reference which I'll talk about in a second we can initialize in QT movie objects from that NS data or finally if you want to put a QuickTime movie in your nib we also have this method movie named which you may recognize this similar to the image named method for reading the movie out of your nib file now so once you've got a cutie movie object we have a large number of methods that you can use to navigate within the movie or to get movie attributes let me just talk about the attributes for a second there's a few methods that will give you a specific attribute directly for instance the current time method will give you back a cutie time structure which represents the current time now we could have defined methods for all the very many attributes that you might want to get but we haven't done that what we will give you is an nsdictionary that contains key value pairs of a large number of keys and the associated values if you just want one particular attribute then there is a method movie attribute for key so you can pass this with a specific key and we'll give you back the associated value so if you have a movie you can also get an array of tracks in that movie and finally if you need to go underneath a kid if there's something the QT kit doesn't do and you really like work with models karbonn ap is you can get the movie or the movie controller identifier and use that in your code the next class we're talking about is cutie track as you know QuickTime movie is composed of tracks so we will give you back if you wanted a list of tracks of QT track objects in the movie now there's only one way for you to create a cutie track object yourself and that's if you already have a QuickTime track we you can initialize a cutie track object from that existing quicktime track the way that you get and set track attributes is exactly parallel with the way that you do it with movie attributes finally you can get the media object that's associated with the track and also in the case that you need to go underneath the kit and work directly with the QuickTime track you can get that track identifier not much to say about media each cutie track has one media associated with it again if you want to create a media there's only one way to do that which is to start with an existing quicktime media and called the unit with quicktime media method media attributes works just the same way as movie and track attributes you can get the track associated with the media and finally if you need to go underneath the kit you can get the media identifier there's a cutie data reference class which I don't want to say much about because we'll talk about it a bit later but the standard way of talking about of referring to data in a movie is with a data reference so we'll talk more about this later and finally the the view object that will be working with is QT movie view it's a subclass of NS view that is associated with a particular QT movie object I've listed some of the attributes that you can get in set we'll look at this more in a second when we get to interface builder and finally there's a large number of IB actions that you can wire up to menus or buttons in your interface so that's really the kit they have asked us to mention a few issues that you will run into if you start working with version of the kit that's on your DVD but I've listed three of them here there are some cosmetic drawing issues that you'll run into that you won't see here today because we have a fixed version of it currently you cannot usefully subclass a cutie movie view and get the event handling to work just right and finally I would not recommend trying to rotate a cutie movie view right now so let's go to a demo with this and I'm going to show you with six lines of code just how easy it is to write a multi document quicktime display and editing application so let me launch Xcode here and i'm going to ask for a new project and I want a new project that is the cocoa document based application let's call this demo don't tell me you're crashing there we go i'm a pessimist let me open the dot H file and I'm going to need one instance variable here actually first I need to do this when i'm using the kit i need to of course no include cutie kitty h and then i'm going to want to have one instance variable here i want a cutie come on movie view and let's call that movie view what now this will work so let's say that that's all we need to add to my dot H file let's go into the dot m file and so I'm going to be loading windows from nib files so I want to come down to the window controller did load nib method and add a few lines of code so in the instance that I am loading a movie from a file so if self file name is not nil I want to do something and that is to create a cutie movie and let's call that movie and how am I going to create that I'm going to call the class method cutie movie movie from file and what's file self file name and if I get a movie i'm just being careful here I want to assign that movie to the movie view which is going to be loaded so I will say movie view set movie to movie and I believe I'm done with my code so let's save that now I need to set a few things in my target here first thing I want to do is when I'm building oh goodness I don't want to do the pre compile the prefix header because that will take too long and finally I want to set my document type so that when the Open File dialog comes up i can open MOV files and that's all I need there I could add in other document types here but i'll refrain from that so let's see if i can build this build succeeded most excellent but I'm not quite done yet because I need to set up my user interface so let me open the document nib I'm going to get rid of that text thing and the first thing I want to do is resize my window you'll notice that I didn't put any code into my source file that resizes the window to fit the movie so I'm going to shut this i'm going to set the size of the window to a known size that will fit my movies ok and now i want to drag a movie view object into my window set it down here i want to set its size to resize to fit the movie window when I resize it and now let's say a few attributes on the movie view you can see I can show or hide the control or I'll show it and I want to make this editable and I need to do one last thing I need to set up an outlet for the file owner so I'll come in here and add an outlet and we need to call that movie view now let's come over here and wire it up I will control click make the connection save that and if the demo gods are smiling on me i can go ahead and run this and demo is running and there isn't so let's now go over here to the open file and open a movie file after good thank you one thing you cannot forget to do is add the QT cage framework to your project or it will run so we're going to go to system library frameworks look down here for the Qt kit framework add that to our project yes now let's build and run and now things are working fine so i can open let's open that one but i tried to open before movie from file ah thank you it's not moving from file you think i know this stuff now it's a movie width file okay now that we've got that let's try running this oh I'm still running it there I look there we go now this should work was cause our fingers open that thing go we've got it this is actually a flash file one thing let me show you real quickly in the keynote on monday i showed you that there's a contextual menu for movies and if I control click and this is a flash movie I actually get items here that are relevant to flash so I can zoom in zoom out and so forth alright let me very briefly show you one more thing and this is to show you that the kit provides you a large number of behaviors for free ok so I've opened three movies here I have to be our panoramas and let me line this up just right so this is donner lake in the winter and donner lake in the summer and oh that's exciting so let me try opening that again alright so something is missing here what I had was a wired sprite movie that sent messages to the two panoramas to tell them to pan so I can't do that here because the movie isn't opening correctly but that Illustrated one thing that you get for free with the kit which is automatic inner movie communication so with that bumbling through let me bring up Tom Maremma and he will discuss what you can do hopefully with more success if you've got an afternoon to play with a kid all right where is the clicker huh is it how do I go forward on this I'm Tom Maremma I right technical documentation for Apple I've been working with a QuickTime team for the last seven years and this is just awesome stuff I decided to see what I could cook up with the framework basically in an afternoon whoops that was too fast how about going back here and I wanted to basically build a little quick time kit media player app and tiger something it was tasty easy to cook up and wouldn't burn my fingers I basically wanted to do us an app that could play display QuickTime movies import export and also do some editing beyond simple cut copy and paste and this would involve maybe a couple hundred lines of code so what did I need well first of all tiger cookbooks yes we have some tiger cookbooks to do to work with a QuickTime kit framework second thing is sample code which you can download which is piece of cake and then some basic cocoa programming third thing ingredients start with Xcode obviously make sure Panthers or tiger is installed and the key is add quicktime six dot six and then we're going to bake it up with the new classes when completed invite friends over to watch and enjoy my player up doing its thing finally all the documentation the reference and the programming guide is available plus the sample code that i use to build this app notice that we have not included the 3300 pages that are part of the procedural capi you won't need that nor will you need the thousands of other pages that we've written over the last ten years documenting this awesome quicktime technology so can I go to the demo please whoops that's going I'm going to just close think this is ten stuff we'll just do this around a little bit this is my cutie kit player app and as you can see i have added my cutie kit framework which is Tim what what Tim was showing this is basically an app that we've cooked up in a couple of days and what I want to show you is just a few features that are unique to it I also use the cutie kit palette and was able to drag here's my my cutie movie view and from here what I'm going to do is show you what you can do as far as adding some of the actions the as as you can see I have specified my fill color is blue Mike I'm showing my controller and I'm not going to be showing the editing cart yes my let me just go back to this and I want to show you what I've wired up here hey this is the cool stuff that comes with the kit as you can see i can add add scaled in addition to the cut copy and delete i can specify my actions to go to the beginning to the end i can replace it can start backward etc then from here let me just pop open real quickly thank you the main menu nib i don't know if you guys can see this is getting a little bit crowded here I should probably and here I've added importing plus and export view object I've added some of my other menu items and in my edit menu and also in my movie so from there let me just close close this down a little bit Alice ate anything and now just close say anything now here's where the here's the good stuff in my declarations they're all very straightforward I think this is standard cocoa stuff you can see what we're doing as far as the class methods in its some of the setters this is probably the most commonly used of our methods in the Qt kit and down here here all of our IV actions things get a little bit more complicated in the implementation file this puppy is a is somewhat longer as you can see here I have a pound to find that it specifies the width of my movie at 320 this is primarily to open up audio movies and this code sample code is all available for download and it's all documented block by block the interesting parts i think have to do with and I think Kevin Calhoun will talk a little bit more about some of the issues involving sizing and and here we're we're opening up our document with the contents of the file and this is partly where we're going to be doing some of our importing the beauty of working with the Cutie kid I think is that that it doesn't take a lot of code and it really it really dances for you so I'm going to just quickly build and run this puppy and there's my cutie kid player app as you can see this is the default now here's where it gets a little bit interesting I can basically import and I have control well if we get some sound we have sound we have sound on this issue ok the next item that I want to import for you guys is my mpeg-4 file now here we've got we got some control of our movie playback hopefully you don't have to flip with cockroaches like that and guess what we've added we have picked capability which I don't have time to demo now of additional editing functions that add as skilled replacement trim we can toggle the controller and if we want we can even clone it there we are okay things get pretty hot we can in vian even import JPEGs still images and my favorite import item being a guy who does documentation I decided to actually import a PDF of the documentation which for you guys and it has a scroller down here for if you guys can read it 30 frames a second there you are okay happy cooking so the document is available that you just saw now since you read it so quickly you don't need to pick it up off of your seed but for others at the conference you might point out to them that the QuickTime kit reference for objective-c and the QuickTime kid programming guide are available I am Kevin Calhoun i'm still a software engineer at apple computer and i'm going to talk to you about some more advanced scenarios once you get involved programming with the QT kit you are going to have needs that go beyond the things that you can do in a morning or an afternoon you might have to work into the evening these are the nighttime topics let me go through them one at a time for you as Tom mentioned there will be some code that's necessary if you want when you load you when your windows nib is loaded if you want the size of you or size the entire window to fit the natural size of a movie we've always made this easy for you it's possible by means of one of the methods that Tim mentioned earlier the Qt movie movie attribute method to find out what the natural size of the movie then you can use that size to set the size of your view or your window accordingly you can check whether the movie is displaying the movie controller and adding the size of the movie controller as it is and that code in fact code that looks exactly like this is in Toms sample application which we were distributed to you so you can see it in action Tom's of application you call that the Qt kit player is capable of opening any of the media formats that quicktime is capable of opening and it does this merely by calling the method QT movie movie with file that's all you have to do and you can open mpeg-4 all the still image formats that QuickTime supports avi a whole range of formats even QuickTime movie files but you might want to tell NS panel in its open panel when you bring it up that you want it actually to make all of those different file types selectable there are two ways to do that this is one of them here you can use the class method on QT movie can in it with file in order to determine whether a file should be selectable in NS open panel you do it just like this you set yourself as a delegate for the panel and you handle the method panel should show file name and you can respond should I show this file by calling Canon it would file the other thing that you can do is you can actually get from QT movie there's a class method that will return an array of all of the file types that QuickTime can open if that's what you need to do it's really a trade-off if you have a small number of files you might want to pass them for a filter like this if you have a wide range of file types it might be more efficient for you actually get that whole array okay other topics we showed you opening movies from files we mentioned that you can open movies from URLs well what happens if you have media data stored in an instance of NS data I've got Anna status inning around and I've got a VI in it or I've got mpeg-4 in it I want to make a cutie movie out of that well that's very very easy there's a class method on QT movie movie with data but I wanted to show you just a little under the hood what that method actually does it initializes and it well it creates an instance of QT data reference that essentially refers to your NS data as the source of the media that the movie will be able to play and manipulate when you do this it's very handy if you give QuickTime a clue about the format of the data in your instance of NS data there are two forms of clue that we're able to read one is a file name with a path extension if it's if it ends in dot mov or mp4 that's a good clue about the format of the data that's in the NS data or you can give us a mime type and that will help us determine how to import that data in your NS data then you can manipulate media data in instances vanness data using the very same methods that you saw demonstrated and use with files ok that's media data coming into the kit what about going out you have a lot of options for storing your movies in files and for re-encoding your movies into other forms of media option one you can simply write your movie out to a QuickTime movie file a file which only stores a reference to the media data which is stored externally that's easily accomplished via the Qt movie instance method right to file with attributes the second option is perhaps you want to save your movie after you've performed all the manipulations on it that you want to perform out to a QuickTime movie file but you want to store a complete copy of all the media that that movie requires that's easily accomplished by means of the Qt moves movie method right to file with attributes I've achieved a theme for my talk I'm satisfied I can move on but in this case you have to put in that nsdictionary that you pass for with attributes some information that tells the Qt kit that you want to flatten you want to copy all the media data to the output movie file so that's what this code accomplishes of course if what you want to do is to store your your model by means of an S archiver you can use that with QT movie instances as out you can archive the movie as part of your whole object hierarchy finally the last option is you can just get in an instance of NS data the serialized freeze dried form of a QuickTime movie using the method movie format representation once you have that you can store it anywhere you like an instant savannahs data which you can write to a file or do whatever you need to do it finally if what you want to do is not store your movie but re-encode it or export it or somehow turn the media that that movie plays are represents into another format how do you do that well you can simply use the method right to file with attributes some of the attributes that we support tell us what kind of container format do you want to store it in other words what quicktime movie exporter do you want to process the media and store it in that container format you can tell us you want ABI you can tell us you want aiff what have you and furthermore you can tell us what compression settings that you want to apply to the audio and the video as your media is recompressed and stored in that container format now this particular snippet of code the longest one that I'll show you today shows you that you can load some presets from a plist that you store inside of your application bundle that ink that contain those those export settings that i mentioned well the question is where do you get those export settings from that you might want to store and peel it well I wrote a little sample app that does exactly what you would need to do so let me come on over to the demo machine if a left-handed demo machine today and I wrote a very simple application that brett really does one thing only it manages a list of export settings and it saves them to a p list of exactly the form that i mentioned in that code snippet here this is a very simple coco app all that it does is show you an array of export settings such as high quality or digital video and for each of these priests so I want to use in my application I can edit those export presets let's see I want high quality to use the video compressor oh let's see what do I want to use I what do you want to use Michael pick slit and I want that to be high quality and I like 30 frames per second and i want my sound to be stored as apple lossless at 48 kilohertz because i know that's the audio format that i'm going to be working with and I'm not interested in preparing for internet streaming because i'm just using this in my production pipeline but if i'm delivering the cd-rom perhaps i want a different set of settings i may want to encode my video to mpeg-4 with medium quality and I want my audio in this particular case to go to mpeg-4 audio AAC looks good and so all I'm doing in this application is editing and saving these presets I set my high quality beat Apple pick slip video and apple lossless audio and I set my cd-rom a preset to be mpeg-4 video and mpeg-4 audio now I can save this collection of presets to a document i'm going to say these are my export settings and i'm going to store them out on the desktop and what I actually save in this application is a plist and inside of that P list which has the file type if only you could see the file type dot export settings it's a simple p list that contains those export settings that i can load in my application later on and apply to an export operation this is sample code that will distribute to you if you want to implement something for example like iMovie I can come back over to slides please if you have something like I movie that has a panel that says export to web export to cd-rom this is exactly how you can implement that in your own Apple patience finally my last scenario has interest when you're dealing with media the interesting thing about media is that it can come from any places and have a variety of characteristics one characteristic is that it can be slow it can be coming from remotely over a network or it can be a media format that quicktime supports that might take us a while to scan in order to apply all these great features for it for example if it's primarily a streaming format but you want to do editing on it quicktime might have to do a little bit of work to prepare it for that what you need to do in your applications is to check the load state of QT movies to determine whether or not they're ready for the operation that you want to perform check to see if the load state is complete before you perform editing or saving operations we're making it easy for you by giving you the movie attribute the QT movie load state that you can check for this and our own operations for example if you call right to file with attributes to do export will do the checking for you but it's something to be aware of okay so those are my higher-level scenarios of interests I'm going to turn the stage over to Adrienne bear locker who's going to show you some of the cool things that he built I'm not sure if you did it in the middle night or when but he'll tell you so can we switch to the demo machine please I'm going to show a couple of very simple demos using QT kit in tiger so the first demo I have is a movie screen saver so Tiger OSN has a screen saver framework for writing your own screen savers and you basically just returned a screen saver view so in this case we want to use a cutie movie view so we programmatically we can create a cutie movie view and add it as a subview to our screen saver view and in this case we've set some attributes of the view to to hide the controller and preserve the aspect ratio so this is this is a very this is only about 200 lines of code or so most of this actually involves like setting up there's some a configuration sheet in this case the only other thing i want to show here was the only up so we also we observe a notification there's about 16 different notifications on QT movie and in this case we we observe the QT movie did and notification so that we can know when the movie finishes and go on to the next one so what most these notifications are useful if you if you want to customize your user interface you see a little preview like other screen savers and this is just picking up movies in the feed from the movies folder and we can select which ones we want to put in here and loop them or mute them and picking crush test and as we go on to the next movie beep this one would finish so it's a really simple example the other example I have here is of a movie plug in New in Safari the thing in serene in tiger WebKit has exposed the cocoa plug-in API and it's actually very easy to write your own plugins for WebKit and so we just there's a message you you provide a class method plugin view with arguments and we get a dictionary this is just a dictionary of the attributes you get in the ambit from the embed tag in HTML and so I use those two to initialize our QT movie view subclass plug-in movie view and also create the movie and set that on the view and so the subclass in this case also so this is a plug-in protocol so in this case we return self the plug-in movie view itself to form the object for the web Script object so it's also very easy to add JavaScript support and you just need to implement these two methods is selector excluded from web script and web script name for selector and this is just mapping the cocoa selectors to the javascript function names themselves you see I have like play stops stepping and go to end and full screen and most of these just mapped to QT movie view so i just actually just called super for these except for full screen but it's actually very easy to do full screen in in cocoa i mean we just we can just create a window set the level to around screensaver level set the background color and add our QT movie view to the windows content view so let's just run this so not the greatest you I but all of these buttons these are all plugins they're coming to me visit we can we do so little empathy we need the quick and we can step and I'm sure you can think of much more interesting things to do so these are just a couple of very simple examples of what you can do using QT kit I'm sure you guys can come up with much more interesting things thanks so we're here huh well you've seen a few other things we've done recently with the cocoa classes in quick time you've been to some of the other quicktime sessions i hope and it's not a lot of new exciting technology is in this next version of quicktime and the cocoa developers that in vase the kit the quicktime kit will get a lot of these technologies for free we're going to continue to develop the classes going forward and there's a lot of functionality now that's in the kit today so adopt them put them in your app and we'll do the hard work and the heavy lifting for you you have the rest of the QuickTime team behind you okay thanks for coming that's our show oh wait one more thing oh there was one man that is more responsible for what we've accomplished here the instigator I guess be the man behind the throne that and also our number one QA person because from early days he was encouraging the QuickTime team and Apple to get behind the cocoa effort and has adopted the kits from early on and helped with the design and guideline and I'm very proud to have him here and you're in for a treat is dr. Michael Johnson of Pixar let's bring him up well thank you you know that was way too nice now I owe him money again um well yeah so just to start off on a group called mpg every year I come i'm in a different group so eventually they're going to get rid of me but they haven't yet so people are asking what MPG was it's actually the moving pictures group but you know the various jokes or your mileage may vary we move the pictures so you don't have to there's no experts here or the expert is silent and other people at pixar think of us as the media pipeline group and and really we're the people who are responsible for a chunk of in the studio tools group the apt technology and workflow for kind of what i think of is film development and that's really kind of development it sort of trying to come up with the movie the story department get a tutorial department the layout departments and these are the groups that really deal with is a film as a large-scale entity and a lot of the other groups at pixar on the production pipeline are dealing with a shot or a model and and and so we actually deal with sore larger chunks and so one app that some of you may have seen that we wrote back about three years ago is this thing called pitch doctor which we use in the in the story department and another one which some of you have also seen is the thing we call review sketch which lets our directors actually draw on top of any of the footage that they're seeing in the screening rooms and for the last year so we've been working on this thing we were calling the was still are calling the film online kit and it's a it really would not have been possible without this effort by all these amazing engineers in the quicktime group and it was something that I wanted to do because in you know a couple years ago my view quicktime was a quick time it's too big it's hard it scruffty and it's fragile in the sense that I had to know to call this and then that and then have this thing initialized or whatever and you know quick times api's they make me tired and and if you're a cocoa program actually that's so let's take a live a here how many of you would consider yourself coco programmers who want to learn something about quicktime today interesting how many of you would consider yourselves you know quicktime people they're sort of old-school carving people and you're trying to learn more about cocoa this time okay yeah it's about the mix I figured so but see that's the thing is like for those of you you know the second group there I really really really really want what quicktime can do for me like you know I I don't want to do this stuff myself and you know because my group of pics are we know we're pretty small group relatively speaking and we're all about leverage and quicktime is all about leverage and so I had an idea so so now here it is a you know from 2002 than a year on I had a different view because they'd come to me and I said you know we're working on that thing and want to do it and like what do you need out of this thing because here's what we're doing and so I said you know well actually pretty simple needs you know quicktime is this enormous enormous thing so i want you know a model level class 4a for a QuickTime movie it's pretty straightforward teams I want a really nice view level class for a QuickTime movie and so what do I mean by nice well the first obvious thing is maintain the aspect ratio that drives me nuts your work on a film like you know you can't know that's I got the bars don't mess with ya and so and then this was the thing that I think I think may have thrown them a little bit for a loop but I also think that it's kind of the obvious thing and I don't know if this is from because I work at a place like Pixar where we make cartoons or if it's because I'm a cocoa guy but I wanted to easily and quickly make movies of movies and there's a bunch other stuff I want it as well but but the sort of movies of movies who say what it what would this be and so this was actually one of the things that fundamentally appealed to me about quicktime was that if you looked at any of these other media formats and I don't even know what that means but but ways that you could imagine storing synchronized audio and video you know way back when I was a place called the Media Lab at MIT a long time ago and you know we would did stuff early on with quicktime and remember very early on hearing somebody talking about the fact that you could make a movie that had other movies in it and I was like well of course that's the obvious right thing and and so that's always always stuck in my head and so for us you know what that means is you know when I think of a movie I literally think of a movie that we're working on that's X 1 2 & 3 a given act has a bunch of sequences in it a sequence has a bunch of shots a shot has a bunch of frames and then those frames I'll have you know some set of layers on there so place i went to the ian and kevin actually and said this is sort of what i wanted in Kevin god bless him I gave me like a bunch of code that I did not understand and it did exactly what i wanted and every time i would say you know i would send him to man i would say Kevin um you know you old-school carboni quicktime guy um you know what I really wanted was I wanted to be able to do this thing with this in and out point he's like yeah Michael it's in the code just just use the code that I gave you and so you know but it was a lot of code and so I got confused easily so eventually I finally learned enough about quicktime to be able to ask the right questions and figure out how to actually implement this stuff myself in the kit and i like to think that those discussions had some influence on the api to make the kinds of things that I wanted to do much simpler for you guys now one of the things that that will sort of come up in this is you know is this stuff fast enough and I sort of have measures of of what's fast enough and so for me it does it get me the leverage I need and it absolutely does and and it's always you know it's the old one it is it's magic because if this stuff works at all to me I just remember a line from Alan Kay back a long time ago and he was had some harsh words for the Macintosh and somebody was like you know why you harsh it on the mac he said oh well it was the first personal computer you know worth insulting and and so this is like so I feel like what's with the kit it's like i finally met the point now where I can have a conversation about quicktime and actually you know say something give some useful critical feedback because because now it's finally good enough in the sense of like that i can actually do something real with it so this is i'm going to toss this up and I'm going to talk about a little bit now and then i'm going to give a bunch of random demos but this is this is pretty much the code that's like at the core little thing that I asked Kevin for a while ago and the idea was here is I have a little thing in my film online kit the fol kit there's a little thing called fol element and an fo element basically just has a movie and it has an in an out point it has some other little bits and pieces of information there but the idea was is you have an fol element then you have an fol sequence and that would be a subclass off of it so an fol sequence was an ordered list of fol elements and the idea there was so you could have movies of movies of movies I didn't want to just have it be I wanted to be as thin as possible layer on top of the kit but I wanted it to be a layer I didn't want to just you know try and convince Apple to basically you know write it for me I've done that before and I think you guys have that codec and and so so this is all it really came down to and what's cool about this is that you can do the whole thing with QT time which is a wonderful wonderful little struct and again sort of goes back to sort of the core getting it right with quicktime thing the fact the QuickTime has always thought about time correctly and they always thought about it as you know a value with reference to a scale you know to just you know Jim that's off and and so what's going on here is basically I'm grabbing the movie out of out of this sequence that I'm in and and I'm grabbing the movie that I want to stick in there and I find the I find the time that I want to move the thing into there and then I call this method this insert segment of movie time range at time and and magic happens so some other things to think about and I'm gonna give you a bunch of demos here but I want to kind of put a bunch of ideas in your head when you get your hands on this stuff one of the cool ones is we worked with the the final cut folks to come up with I mean they did all the heavy lifting we gave them one good idea on this XML format I've got the Earl here I went and checked that last night to make sure that was that was a live link there and it's a great file format and what's cool about this is especially if you're like me and you're building things on top of the QuickTime kit and the in QuickTime is great file format don't get me wrong but there's a lot of times you're going to want stuff to basically be editable somewhere else especially if you're like me and you've got you know you own a teeny part of a very large production pipeline and you need to have things flow around there this XML format is really great for that and in our kit we actually support we can read and write it and so that means you can sort of put these things together and then you can save them out and just double click open them up and final cut and it just works another thing that I've been sort of thinking about as I've been here I mean the command line apses is a big thing also for us and with cool about the kit is so again I've been trying to learn quick time for years okay failing miserably for the most part until this stuff came along and one of the things that sort of always comes up is people wanting to make reference movies right you've got like these five movies and you'd like to make a move there's my movies with movies game again but you know and I guess there's I guess there's this guy Peter hottie and he wrote this thing a million years ago and people all go and get this you know it's over hero runs and classic and you know there's there's some little thing for doing this stuff and I'm sure all the QuickTime gurus are going well no Michael you just do this but but as far as I could ever tell you know it's just sort of black magic and you can write this in like three lines now with the kit that's just so killer you know you can basically open up a movie do you know insert movie of movie into that movie as you iterate over your movies and then save the thing out again and now you know you can even transcode it to a different codec if you want amazing and then also I was just thinking when i went to the automator talk the other day about the fact that you know if you think about these things little command line apps you can imagine doing all sorts of really neat things with QuickTime movies so anyway the other thing that you may want to do is you may want to put whatever stuff you do on the kit on an ib palette and that's what we did so so we have this idea of what we call a sequence provider and a sequence provider is basically a model object that is holding on to its basically fronting for one of these sequences it's basically providing that thing for you to a model controller layer and we have a set of formal protocols that these sequence providers can form to so there is the notion of an fol sequence providing there's an fol mutable sequence provide a providing an fol beautiful movie sequence providing we're way to protocol E and so we've actually implemented this for two things one of them is actually a very lightweight thing you know think of like iTunes except think of it for movies and so you'd like to basically have huge lists of movies big cut list of movies but you really don't need to play them you know you're really just kind of organizing them it'd be like bringing up iTunes where you're getting ready for a party and you know all this music you don't need to actually play it you just kind of want to rearrange it and put it in a particular order the next one is an actual hardcore editable playable movie sequence something where you can hit spacebar and it's just going to play play for you and so so we implemented these two things as serve objects on the pallet there so with that go to bring up I be everybody has to arrange their little I be world differently myself included oh yeah hmm right all right so just start off with a simple thing no document opening error occurred well that's good we should have rebooted this this machine all right we'll make a new one see I tried all my stuff on Panther and then they put me on a tiger machine so the the basic idea here is here's here's our little palette here we have a whole bunch of different objects a bunch of which you're not going to see today sorry so so the first thing we want to do is you want to actually drag out this little object that has a bunch of movies in it and because we are very firm believers in the sort of iterate really quick kind of thing we actually have I can go and I can add and delete movies to this thing here which I will later on this but it comes up and it starts up having just a bunch of movies to a bunch of tests movies sort of built in there to provide out so the first thing you want to do is you know pretty much what everybody else has been doing here which is you drag out a little you drag out a little movie view and in my case I actually wire it up to a sequence provider so now if i go into test interface mode i actually go and build up a little sequence of those movies there and so I just have this simple little movie that's there now that's not super interesting it's sort of what the other guys were doing and I must be the sexy demo so I have to do something better than that so one of the things that is really really neat about this and the things thing that they got really right is the fact that this is very you know and again happy that most of you raise your hands on the cocoa side of the fence there is that this is you know the QuickTime kit makes it very very easy to make very NBC kinds of things and so you know here we have old table which is representing the movie and as we're playing this thing here you know it sort of showing up that stuff there and we can do all the sorts of things you would expect I can drag and drop these things around now what's going on here I'm editing a movie okay I'm editing a movie of movies here and it starts to get really interesting of where it's actually just updating this stuff so we'll put some more yeah see I know why those guys don't want to open that's weird anyway we'll go and instead of having a just a table view we can use a an outline view and so you can notice now that when we get with some of these things there were little disclosure triangles on them and that's because these themselves are movies of movies of movies so in our little test thing that we've got there we actually have it set up so that it's not only to sort of one level of hierarchy but it's too and in all the sort of stuff that you expect to have work works you know you can serve drag between them and stuff like that and we're doing you know we're doing some heavy lifting there but the fundamental quicktime activities going on there is that little function that I put it there which is basically all I'm doing is I'm inserting element I've got sort of a companion one of that which is basically delete element from segments and these guys really did it right it's really sort of works the way you would expect it to work and again we've got with the kit that we've been working on we have a whole sort of raft of these these UI elements so let's just go and see if we go and we said let's put that in a tab view where do I put on shampoo something's been puttin up to have you so let's put this guy in a tab view there and then we can actually go and we have another another view which is a tableau view and so if we wire that guy out to sorry I'm try going to scroll view and this guy will go and let's actually also drag a little slider so we'll do the sort of iphoto kind of thing so we can see our our movie that we have here as both as but looking at it that way or this way and again sort of all the same kinds of things we can go and move these things around and and then we can go and I should have made it continuous that's what you want to use I be so now when you go in there you can try that sort of stuff now i really want to sort of take this moment here since you're since your cocoa folks here to evangelize a few things people i came from the old nextstep world that's sort of how i got to cocoa and one thing that used to happen a lot more in the in the next step world and it seems to be happening in the cocoa world is people would put things on pallets and and it makes me sad that i don't see more IV pallets and i pushed really hard on the QuickTime kick guys to get sort of all their ducks in a row on there so in terms of you know the all the encoding methods and things like that are in there so that you can actually go and put all this stuff in there put it in a nib and there's a certain rigor that that happens when you actually go to the trouble of putting things on an IV pallet and there's a certain cost up front in terms of actually making it so that all your objects know how to serialize themselves out and that they're using key coding you know correctly and and there's you know there's some work you have to do there but it's really worth it because there's nothing like you know taking out another app to to know when you've got bugs in your code and the cool thing about ib is you know I'm you know in a test interface mode there if I'm not releasing everything correctly or I'm doing some bad trouncing on things there I'm going to pay for it really quickly and I much prefer to sort of take the pain of that kind of stuff not quite completely upfront but you know people don't sort of go and finish things out well enough i think in it it kind of makes me sad so i'm hoping people will see you know this thing as a kind of a non-trivial example that was basically done by there's like you know for people that contributed to the code on this thing here so it's not a huge wasn't a huge huge effort but but it is something that you want now take out against or there's the obvious thing then that if you're going to really start trying to do Production apps with this stuff the one thing that I think you know we all know that we need is a timeline and so we have a little Timeline view that we can drag out here and eventually start up there so here we have a little time line and same sort of stuff happens you know you've got selection you can see it happening between them there we've got interactive we can serve change the in and out points on there and then indicate those things and and what here's sort of a neat thing so remember this is a movie of movies inside our movie right so and remember that that little movie had if we look it had it was made up of three and four but it's a movie and it has in and out points so theoretically we could actually change the end points of that thing and move it in far enough that that it's sort of representative first frame is no longer three but four and so that sort of just proving that I sort of have no you know I'm not lying here another thing that you could do on this kind of stuff is you can use sort of non-trivial movies so let's actually get rid of my trivial movies and show you some non-trivial once now unfortunately when I grabbed these movies I grabbed them off the disc farm and we made them from there and so these movies have no sound but but they are real movies nonetheless and so this is some stuff from a little movie we're working on this year called The Incredibles and and so this was from the trailer and so this is pretty interesting because these are the real are we we're in a bad place right now let me just check this again sorry I'm going to quit I be for a second here and do this again because some things say they're being freed in the middle there you probably want to start again okay so if we drag out a little movie view here and we drag out a timeline and then we pull out a sequence provider and then we'll go and we'll edit that sequence provider in order to add those movies and again and so that you know what I'm hoping that that you're you're getting from this is the fact that you can you can use this kit to do real things you know these guys have done there's still I think I think there's still lots of there's lots of quick time left that's not really exposed in in the kit right now but I think there is an enormous amount of work that these folks have done so here's our little sequence here and what's fun with this is that you know you can even actually edit this thing you know while it's playing this is what i mean by it's magic I didn't do anything to get that you know domain like I'm just like editing the movies of movies there and these quick time folks are just making that all work and and I don't really know you know sort of what they're doing and I don't have to know that's the point of doing stuff with cocoa right leverage it's all about leverage and trying to get and trying to and to leverage what what these folks are doing so you can get back and do sort of the real work that you want to do is that the time for talk or do we need to leave time for questions for talk okay good it's that Professor okay I'll wrap this up here so that's its kind of dark up there that's too bad this is this is actually full film res pic slit playing back there and and we can also there's other things in the kit that I sort of haven't talked about but I can do things like we have this notion of markers that you can drop down and you can drop markers on things and and snaps into things or we can put a I could put like a marker here and then I can extend that thing out and and then I can do things like drawing on top of it there and then I can actually go and just play and like the drawing there is actually using a child window so there's actually this is again it's sort of the magic of cocoa right is I've got the child window stuff over here so i did that drawing in a separate window that's coming in cutie movie view that has no knowledge of that stuff at all the GPU is doing the compositing there so i didn't have to like you know draw some sketch track inside of quicktime and then hope the quicktime you know it was a fast path in quick time to sort of composite that stuff together you know I can sort of have that little drawing up there and this is the kind of stuff that we do all the time and have it not cost me anything from quicktime and what's so great about this from again from a coco person's perspective is the quick times finally sort of you know arrived in you know to my party where you know they were having a great party over there by themselves here but now like I get to use them and I get to make them plug and play with all the things you know interface builder and child windows stuff and and just being able to build a framework and to be able to sort of move things around really easily and that's just that's just enormous and sort of what you know these folks have actually accomplished you know sitting on the shoulders of the Giants of all the QuickTime efforts for the last ten years you know I just you know I'm the Klimt it's just really huge and so that's that's all I've got thanks you