It's always possible to export to a lossless codec like Pixlet, but this procedure saves a great deal of time, disk space, and it works well for me. I've tested it on several sorts of MPEG files, of both MPEG1 and MPEG2 standard, and haven't had any trouble. Also, the procedure I outline below takes advantage of another QuickTime Player Pro feature, the ability to mask various layers of the picture to get rid of the annoying analog noise that sometimes shows up at the top of the frame in TV captures. When the alternative is exporting to DV, letterboxing in iMovie, and rexporting back to MPEG1 or MPEG2 for VCD or DVD, being able to make simple edits in QTPro is a real time saver.
[robg adds: I haven't tested any of this hint...]
It is a quirk, or heck, I don't know, maybe a feature, of QuickTime Player Pro that even when an MPEG track is contained as one track in a movie, it can't be edited readily. Many of the menu functions are disabled in the Edit menu. Also, it appears that the first frame of the movie must be preserved for some reason, and this generally means that whatever sound is in that first frame is also preserved. The following procedure helps with that problem too, and yields acceptably shiny, edited movie files for further processing. To do this, you will need:
- QuickTime Player Pro.
- ffmpeg, an open source command line tool. Although there are several versions around that will do the job I'm fondest of the version buried in the ffmpegX.app package that can be downloaded from here.
- A collection of masks. These are PICT files, sized to standard frame sizes, with black at the parts you want to cover and white at the parts you don't. They are used to cover the analog noise at the top of the frame.
- A collection of Background movies. These are very short movies that you use to cover up the first frame.
- A moment of silence. Since the first frame can't be deleted, any audio shows up in the first frame as well and might make an unpleasant noise. Create it in .wav format.
- Export the sound from the file in WAV format using ffmpeg.
- Open the .wav file in QuickTime Player Pro. Double-clicking the file may open it in iTunes, which you don't want, so be careful. Click on the selection end marker (that's the small triangle BELOW the progess bar, with the point facing to the right) and make sure that it is open rather than solid. Hit the right arrow twice, which should move the marker to 15 frames from the beginning.
- Open a .wav file containing a half second of silence. Select all of it, switch to the exported .wav file, and choose "replace" off the Edit menu. Now select all of the exported .wav file.
- Open your .mpg file in QuickTime Player Pro. Select Edit -> Add Scaled. You now have a movie container with two tracks: an MPEG muxed track and a "sound track".
- Open the Background movie corresponding to your movie displayed frame size (typically 640 x 480 or 320 x 240). Rewind the movie to the beginning and add it in with the Edit menu (Edit -> Add). Here, it's important to select "Add" not "Add scaled". You're trying to cover up the first frame so that you don't have to look at it, not cover up the whole thing.
- Open your mask file corresponding to the movie displayed frame size, select all, and close it. Add this to the movie as well, using Edit -> Add Scaled. You now have a movie container which contains four tracks: An MPEG Muxed Track, a Sound Track, a Video Track 1, and a Video Track 2. The layers correspond to the order we added these tracks.
- Open the Movie Properties window (Movie -> Open Movie Properties). Select MPEG Muxed Track from the left pulldown. Select Volume from the right pulldown. Run the volume for this track to zero. You have a separate sound track for this file, and you don't want to listen to the one on the MPEG track anymore.
- Select Video Track 2 from the left pulldown. Select "Graphics Mode" from the right pulldown. Choose "transparent" from the window, and click on the "Color..." button. A standard color window will appear, from which you will want to select white. I use the gray scale slider selection and run it all the way to the right, but other choices will also work. Basically you're telling QuickTime Player Pro to show you everything that is underneath the white part of your mask, and obscure everything else.
- Save the movie. You now have a movie container which is ready for editing in QuickTime Player Pro. There is one snag, though: The Edit -> Clear selection is still grayed out. I believe the presence of MPEG tracks disables this in the player. I work around this as follows. Using the mouse or just play commands, I put the current time cursor at the beginning of the commercials I want to delete. I then choose Edit -> Select None. This snaps the selection beginning and ending markers to the current time. I repeat my search through the programming to find the selection's end. Then I execute the following AppleScript:
I keep this one in my /Library/Scripts/ folder, and name it " Edit" with a leading space so it shows up first in the Scripts Menu. (This is installed from the utility in /Applications -> AppleScript -> InstallScriptMenu). I'm told that all the functions I'm talking about are available via AppleScript even from the non-pro version of QuickTime Player, but as I was happy to buy a license it didn't matter much to me. Specifically for editing the first frame, you want to rewind the movie fully, and then step forward by one or two frames with the arrow key. Do Edit -> Select None. Then scroll forward to where you really want the movie to start. Execute the AppleScript above. Now, when you rewind, your first couple of frames will be silent and dark, and the remaining ones will be the programming you want.tell application "QuickTime Player" set the selection end of the front movie to the current time clear the front movie end tell - Save your edited film.
Timesaving hint #1:
I realize the procedure above is tedious. To simplify it, create a new folder wherever you like, and inside it create another folder called "Done". Inside that, create a third folder called "Masks" and place the pictures (PICT files) for the masks (in 320x240 and 640x480) in there. Also create a couple of very short movies of no more than a half second duration in the same size. In my case I did this with the QuickMovie application, but you could export a slide show of black frames from iMovie and then export again from QuickTime Player Pro in, say, the Cinepack codec. Finally, exporting some sound as WAV from iMovie with the volume edited down to zero gets you the half second of silence you need. Place all of these support files (the masks, the lead-in movies, and the silent wav) in the "Masks" folder. Make sure their names are consistent with the code below (change whichever you prefer). Put the following AppleScript in your /Library -> Scripts -> Folder Action Scripts folder:
on adding folder items to this_folder after receiving these_items
tell application "Finder"
if not (exists folder "Done" of this_folder) then
make new folder at this_folder with properties ¬
{name:"Done"}
end if
set the destination_folder to folder "Done" of ¬
this_folder as alias
set the mask_folder to folder "Masks" of ¬
destination_folder as alias
set the destination_directory to POSIX path of ¬
the destination_folder
end tell
repeat with i from 1 to number of items in these_items
set this_item to item i of these_items
set the item_info to info for this_item
if this_item is not the destination_folder and the ¬
name extension of the item_info is not in ¬
{"zip", "sit"} then
set the item_path to the quoted form of the ¬
POSIX path of this_item
set the audio_path to the quoted form of ¬
(destination_directory & (name of the ¬
item_info) & ".wav")
set the_script to ("/Applications/ffmpegX.app/Contents/Resources/ffmpeg -i " & ¬
item_path & " -vn -acodec pcm_s16le " & audio_path)
do shell script (the_script)
end if
set qt_open to "open -a '/Applications/QuickTime Player.app' "
set the_other_script to (qt_open & item_path)
do shell script (the_other_script)
tell application "QuickTime Player"
close (every window whose name contains "Untitled")
set {width, height} to the dimensions of the front movie
set the mask_path to the POSIX path of the mask_folder
set silent_path to "'" & mask_path & "Silence.wav'"
set bg_path to "'" & mask_path & "TV Background " & width & ".mov'"
set mask_path to "'" & mask_path & "TV Mask " & width & ".pct'"
do shell script (qt_open & bg_path & " && " & qt_open & mask_path & " ¬
&& " & qt_open & audio_path & " && " & qt_open & silent_path)
(* get a half second of silence *)
copy the front movie
close the front movie saving no
(* add the silence to the first half second of the .wav audio *)
set selection start of the front movie to 0
set selection end of the front movie to 150
replace the front movie
select all the front movie
copy the front movie
add the back movie with scaled
close the front movie saving no
(* add the mask *)
select all the front movie
copy the front movie
add the back movie with scaled
close the front movie saving no
(* add the background *)
select all the front movie
copy the front movie
close the front movie saving no
set layer of track 1 of the front movie to -4
set layer of track 3 of the front movie to -5
tell movie 1
set the operation color of track 3 to {65535, 65535, 65535}
set the transfer mode of track 3 to transparent
end tell
set sound volume of track 1 of the front movie to 0
set the movie_name to the name of the front movie & ".mov"
set the movie_file to (((destination_folder as string) & movie_name) as string)
rewind the front movie
(* add the background to evade "first frame" problem *)
add the front movie
step forward the front movie by 1
select none the front movie
save movie 1 in file movie_file
close movie 1
end tell
end repeat
end adding folder items to
Attach the script as a folder action to the folder you've created (the one that contains the "done" and "masks" folder) and any mpg file you drop into it will be processed. On my 1GHz Powerbook, the entire process executes in about 1/15 the duration of the original movie. Just about all of that is the .wav exporting. My 2x1.25 PowerMac is quite a bit faster but I haven't benchmarked it specifically.
Timesaving hint number 2:
Download the files needed to do all this from here. They're in the archive stored there as "Process Mpeg Files.sit."

