Reading a file

For any operation, the first step is to #include and then create a pointer of type quicktime_t. quicktime_t *file; Open the movie with the quicktime_open function. Argument 1 is the path to a file. Argument 2 is a flag for read access. Argument 3 is a flag for write access. You can specify read, read/write or write access by setting these flags. Don't specify read/write mode for files that already exist. Read/write mode should only be used for creating new files. file = quicktime_open("test.mov", 1, 1)); This returns a NULL if the file couldn't be opened or the format couldn't be recognized. Now you can do all sorts of operations on the file. /************************************************* * Reading a file: **********************************/ If you just want to read a file, a good place to start is before opening the file, making sure it is Quicktime with quicktime_check_sig(). quicktime_check_sig("path"); This returns 1 if it looks like a Quicktime file or 0 if it doesn't. Then you can open the file as above. Next get the number of tracks for each media type in the file: int quicktime_video_tracks(quicktime_t *file); int quicktime_audio_tracks(quicktime_t *file); While Quicktime can store multiple video tracks, the audio track count is a bit more complicated. In addition to the track count, Quicktime can store multiple audio channels for each audio track so you have to count those too, for each track. int quicktime_track_channels(quicktime_t *file, int track); Tracks are numbered from 0 to the total number of audio tracks - 1. The library doesn't handle any extraction of channels from each track. It just reads raw track data. For each audio track, other routines you might find useful for getting information are: int quicktime_audio_bits(quicktime_t *file, int track); long quicktime_sample_rate(quicktime_t *file, int track); long quicktime_audio_length(quicktime_t *file, int track); char* quicktime_audio_compressor(quicktime_t *file, int track); quicktime_audio_length gives you the total number of samples in a given track regardless of the channels or bitrate. The sample rate is samples per second. The audio compressor routine returns a 4 byte array identifying the compression of the track. The available video information for each video track is: long quicktime_video_length(quicktime_t *file, int track); int quicktime_video_width(quicktime_t *file, int track); int quicktime_video_height(quicktime_t *file, int track); float quicktime_frame_rate(quicktime_t *file, int track); char* quicktime_video_compressor(quicktime_t *file, int track); long quicktime_frame_size(quicktime_t *file, long frame, int track); Tracks are numbered 0 to the total number of tracks - 1. The video length is in frames. The width and height are in pixels. The frame rate is in frames per second. The video compressor is a four byte array containing one of Quicktime's video data format types. More on these later. Unless you get a really nihilistic file for reading, you can safely assume the encoding scheme for track 0 of audio or video is the same for all tracks of that media type. That's what the encoders do. The library decodes compressed video frames into rows of unsigned RGB bytes. First use int quicktime_supported_video(quicktime_t *file, int track); to find out if the codec for the track is in the library. This returns 1 if it is and 0 if it isn't supported. Then use int quicktime_decode_video(quicktime_t *file, unsigned char **row_pointers, int track); to decompress a frame at the current position of the track into **row_pointers and advance the current position.