| ★ wanayoo — archive 1999 http://www.mactech.com/articles/develop/issue_14/Olson_final.html | Nouvelle recherche | Portail wanayoo |

MAKING BETTER QUICKTIME MOVIESKIP OLSONQuickTime 1.5 makes it easier than ever to make CD-playable movies. These tips on capturing, compressing, and playing back movies will help you use the new Apple Compact Video compressor to its best advantage, creating movies that will play well off a standard CD-ROM drive on a Macintosh LC computer.
What makes movie creation tricky is the tradeoffs required to get QuickTime movies to play off a CD-ROM drive, the most effective distribution medium for digital video. Uncompressed, full-screen, full-motion video requires a data transfer rate of about 27,000 kilobytes/second, yet a typical CD- ROM drive has a data transfer rate of only 100 kilobytes/second. QuickTime solves this problem by using video compression, which requires you to make tradeoffs between frame size, frame rate, image quality, and sound quality when making a movie. The tips in this article will help you make the right tradeoffs to produce high-quality movies that will play off CD-ROM. You'll also find tips on capturing digital video, using the MovieShop utility on this issue's CD to produce compressed movies, and playing back what you've created. I assume you're already familiar with the basics of movie making with QuickTime. TIPS ON TRADEOFFSMaking the right tradeoffs is the key to producing better QuickTime movies. Depending on your target platform, to get smooth playback you may need to limit the frame size and rate, minimize the differences between frames, and trade off audio for video quality. PLATFORM Table 1 Common QuickTime Platforms Macintosh
FRAME SIZE Frame sizes are typically specified by horizontal and vertical pixel measurements. Some common frame sizes for digital video are shown in Table 2.
For the Apple Compact Video compressor to function optimally, the frame size should be a multiple of 4 in each dimension. This is because the compression algorithm uses a 4-pixel by 4-pixel cell. FRAME RATE The frame rate of source material in the NTSC video format is approximately 30 fps. Much source material is shot using film at 24 fps and then transferred onto videotape. Frame rates to use for movies based on these types of source material are shown in Table 3. Other video standards such as PAL and SECAM have different frame rates; if your movie is based on one of these types of source material, you'll have to compensate accordingly. For our target platform, we can use 12 fps with good results. Table 3
If Your Source Material Is NTSC Video:
If Your Source Material Is Film:
There are a couple of minor quirks having to do with frame rate that you should be aware of when you make a movie. First, you'll note that I said the NTSC frame rate isapproximately 30 fps. For reasons lost in the dawn of television, the NTSC frame rate is actually 29.97 fps. If you assume the frame rate is 30 fps, long movies can lose synchronization between sound and video over time, since there are fewer video frames than expected. For example, if you digitized 100 seconds of video, you would expect to get 3000 frames, but you would really only get 2997 frames in that period of time. The GrabGuy utility and the HyperCard® Movie Making Stack (found on theQuickTime 1.5 Developer CDand on this issue's CD) automatically take care of this problem, but if you find sound sync drifting over time on long movies, you may need to duplicate a video frame every 1000 frames to get things back in sync. The second item to note involves transferring 24-fps film to 30-fps video. On videotape, each frame is composed of two fields, one containing the odd scan lines and the other containing the even scan lines. These fields are interlaced to produce the frame. When film is transferred to video, six extra frames are "made up" every second. Typically, once every four frames, two adjacent film frames are put into the two fields of a single video frame to form a fifth frame. Figure 1 shows how this works. These made-up frames have a blurred look when digitized.
Figure 1 Making Up Extra Frames When Film Is Transferred to Video
FRAME DIFFERENCING
Figure 2 Example of Frame Differencing When you're using the Apple Compact Video compressor, it's a good idea to create movies in which not much changes from one frame to the next, since frame differencing is one way the compressor achieves lower data transfer rates. Here are some things to keep in mind to get the most benefit from frame differencing:
Frames can't be differenced indefinitely, however. At regular intervals akey frame-- a frame that refreshes the entire movie area, not just the pixels that differ from the previous frame -- is inserted. You can adjust the interval to achieve the tradeoff between data rate and movie quality that you desire. Normally, you should have one key frame per second. The more you put in, the higher the data rate and the better your movie looks but the less compression gain you get from frame differencing. SOUND SAMPLING RATE If your source is mostly people talking and not music, you can record audio at the alternate sampling rate of 11.127 kHz. In many cases this will make your video look sharper and give acceptable sound quality. With most audio sampling hardware, it's best to set the hardware at the sampling rate you desire, since the hardware will often do filtering to avoid aliasing artifacts. One exception is the MacRecorder digitizer (from MacroMedia), which doesn't filter at 11.127 kHz. If possible, you should record at 22.254 kHz on a MacRecorder and downsample the audio to 11.127 kHz when you compress the movie. One other thing to keep in mind when using a MacRecorder to digitize audio at 22.254 kHz is that its sample rate tends to drift away from the standard Macintosh rate, so you should always resample it to 22.254 kHz or 11.127 kHz when you compress the movie. TIPS ON CAPTURINGThe QuickTime 1.5 Developer CDand this issue's CD contain two utilities for capturing video: GrabGuy and the HyperCard Movie Making Stack. GrabGuy is an application that does a multipass grab off a controllable VCR like the Sony µMatic, giving frame-accurate recording. HyperCard and the Movie Making Stack enable you to get frame-accurate grabs off controllable Pioneer laser discs. Most video cards also come with software that enables you to grab raw video directly to RAM or hard disk.To get the highest possible quality when you're capturing the source material, you should do three things:
I'll discuss these tips one at a time. START WITH A CLEAN SOURCE Beware of tapes that have been duplicated many times or played a lot -- they can be very noisy. If your digitizing card supports S-Video inputs, use them if you can, as S-Video delivers better quality than composite video. ADJUST LEVELS GRAB AT A LARGER SIZE THAN YOU NEED To save disc space, you should grab using JPEG compression set to the highest quality instead of grabbing raw frames. Most of the quality you might lose this way isn't used by the Apple Compact Video compressor anyway, so this won't reduce the quality of your final movie very much. A number of video cards now support hardware JPEG compression, which makes this even easier. TIPS ON COMPRESSINGThe MovieShop utility on this issue's CD is indispensable for compressing QuickTime movies. After an admonition to edit before compressing, I'll take you through the steps involved in using MovieShop to create CD-playable movies. My emphasis here is more on what to do than why you're doing it. If you're curious about the reasons you go through the steps you do, refer to the MovieShop documentation on the CD.EDIT BEFORE COMPRESSING Here's why: Movies are composed of tracks that typically contain video and sound data. When you capture a movie, the track data is often stored sequentially in the file, resulting in a file layout like the first one shown in Figure 3. To play this movie, QuickTime must allocate four large buffers -- one for each track -- and seek between tracks during playback. This can cause miserable playback performance off CD-ROM drives, which typically have very slow seek times (we're talking hundreds of milliseconds).
Figure 3 Ways of Storing Video and Sound Track Data in a Movie
The most efficient layout is to append the second video/sound sequence onto the first, as illustrated by the third file layout in Figure 3, so that only one buffer is needed and playback is optimized. When you compress with MovieShop, it automatically merges all the video and sound tracks of a movie into a single video and sound track, thus giving you the most efficient layout. SET THE DATA RATE
Figure 4 Setting the Data Rate in MovieShop
MovieShop tries to limit the data rate of a movie by adjusting the amount of frame differencing (motion quality) and lowering the compression quality (spatial quality). However, since the Apple Compact Video compressor determines motion and spatial quality internally, you should turn these settings off by entering the numbers shown in Figure 5. (For details about what these magic numbers mean, see the MovieShop documentation.) That way, Apple Compact Video will always make the right choices for the data rate you've chosen. If your source material is in color, choose "Millions of colors"; if it's in black and white, choose "256 grays." "Use previous compressed video" should be checked for most video sources; however, if you're compressing raw animations or composite movies with a constant background, uncheck this setting to get more benefit from frame differencing. MovieShop will then use the last uncompressed frame instead of the last compressed frame as the basis for frame differencing. The key frame setting should be related to the frame rate of your video. As I mentioned earlier, you should normally have one key frame per second, although in some cases you might want to have fewer than one per second to lower the data rate (which will, however, decrease quality as well). SET THE SOUND SETTINGS SCALE AND CROP THE MOVIE
Figure 6 MovieShop's Cropping Dialog DISABLE EXTRA COMPRESSION METHODS
The version of MovieShop on the CD (v. 1.0c2) has a bug that causes it to use the settings for
methods 2, 3, 4, and 5 even when they're below item 18. If you're working with that version, you
should additionally set those methods to the following values to really disable them:
Again, for details about what these magic numbers mean, see the MovieShop documentation. Once you've set up MovieShop this way, click "Make the movie," choose an output file, and sit back and watch the show. It can be a long wait, but the results will be worth it. TIPS ON PLAYBACKIf you're developing an application to play QuickTime movies, there are four things you can do to make movie playback everything you'd hoped it would be:
OPTIMIZE SCREEN POSITION AND DEPTH The screen depth also affects playback. If the screen is set to millions of colors, the movie will play back more slowly than at 256 colors, because there are more bytes to move to the screen every frame. The Apple Compact Video compressor is optimized for thousands of colors (16 bits/pixel), so you'll get the best performance and quality at that depth. AVOID CLIPPING HIDE THE MOVIE CONTROLLER DON'T CALL WAITNEXTEVENT AS OFTEN SEE YOU AT THE MOVIES!Now you know a little bit more about making and playing movies than you did before you sat down with this article. You understand what the tradeoffs are in making CD-playable movies: to get smooth playback, you may need to limit the frame size and rate, minimize the differences between frames, and trade off audio for video quality. You know that to get the best possible quality when you capture, you need to start with a clean source, adjust levels, and grab at a larger size than you need. You know how to use MovieShop with the Apple Compact Video compressor to compress your movie. And you know that to get the best possible playback, you need to optimize the movie's screen position and depth, avoid clipping any portion of the movie, hide the movie controller, and not call WaitNextEvent as often.In a nutshell, if you want your movie to play well on a Macintosh LC II with an AppleCD SC and thousands of colors, you should use the following setup:
With this knowledge, you can really put this technology to work and produce a QuickTime movie with the best of them. While you may not become the next Steven Spielberg, you can at least see your name in lights (check out theQuickTime 1.5 Developer CDAbout Box movies to see the QuickTime team in action). See you at the movies! KIP OLSON lives by the motto "I never met an avalanche I didn't like" and spends his winters skiing the extreme in places like Chamonix, Jackson Hole, and Hoboken. When not cornice surfing, he's been known to cast a #12 Adams to a rising brookie and score a perfect 18 at putt-putt golf. He works for Apple in his spare time. * For more information on QuickTime 1.5, your best source is the QuickTime Developer's Kit v. 1.5, available from APDA. This kit includes the complete printed documentation for QuickTime 1.5 as well as the QuickTime 1.5 Developer CD , which is full of example code, movies, and utilities. The new Inside Macintosh: QuickTime and Inside Macintosh: QuickTime Components together provide a complete description of QuickTime 1.5. * For more on capturing, see the article "Video Digitizing Under QuickTime" in this issue. * For more information on AlignWindow and other alignment routines, see the Image Compression Manager chapter of the QuickTime 1.5 Developer's Kit documentation, and Inside Macintosh: QuickTime .* THANKS TO OUR TECHNICAL REVIEWERS Dean Blackketter, Bill Guschwan, Peter Hoddie, Eric Hoffert * |