From Flash to MP4

May 25, 2010 by dmacnet

I’ve been thinking about saving some Flash videos from YouTube, Vimeo (videos without a download link), and other sites for playing on iPods and other platforms that don’t support Flash video. Since most Flash video these days uses the h.264 codec, it should be possible to de-multiplex the .flv file to extract the video and audio streams, then re-multiplex them into an MP4 container, with no re-encoding.

On a Mac with Perian and QuickTime Pro installed, just open the .flv file in QuickTime Player 7, do “Save As,” choose “self-contained movie,” and after a few seconds, you’ll get a copy of the video in a QuickTime .mov file.

There’s also a more roundabout way to do it on Windows, if you really want a .mp4 container file.

  1. Download the Flash video file (.flv extension). The Firefox add-on DownloadHelper is one way to do this. You should probably download the highest-resolution version available.
  2. Run FLV Extract and drop the .flv file onto it to create .264 and .aac files, which contain the video and audio respectively. If it produces files with different extensions, your Flash video file isn’t encoded in h.264 so the next step won’t work, sorry.
  3. Run YAMB and add the .264 and .aac files to re-multiplex them into a .mp4 file.
  4. Play the .mp4 file and check that audio and video stay in sync before you delete the .flv file.

Electronic Image Destabilizing

January 21, 2010 by dmacnet

Do you understand all the automatic settings on your electronic equipment? Recently, I was reminded to not assume that the current settings are appropriate, when one of them did the opposite of what it was supposed to.

I was shooting video of a mini-conference in which a lot of the footage was of one person at a time standing and speaking behind a podium, in front of a white board. The camera was a Panasonic consumer MiniDV camcorder that was bought several years ago on a budget (it wasn’t mine). I was using a tripod and did a lot of head-to-waist shots with occasional zooms or pans when the speaker got close to the edge of the frame.

Fairly often, the shot would jerk somewhat up and down again, as if the tripod head were loose and shaking. It was a consumer-level video tripod (a Velbon), but I thought I had tightened the pan/tilt head about right to prevent slipping. I fiddled with it a few times, then started looking through the camera’s setup menus. There was an icon on the LCD that said “EIS”, so I looked up what that meant, since I understood all the other information on the screen.

I found out that “EIS” means Electronic Image Stabilizer. With it on, the camera analyzes the image and when it detects something moving up and down rapidly, it concludes that there is camera shake occurring, so it shifts the image in the other direction to compensate. It’s a poor man’s Steadicam for hand-held shots.

But the EIS backfired on my tripod-mounted shots. Whenever one of the speakers would wave his arms up and down to emphasize a point, the camera would lock on to the arms and try to keep them stationary, moving the podium and white board up and down instead! So it destabilized my stable shots.

I turned off the EIS, and my shots were stable for the rest of the event.

Audio Encoding in iTunes

January 19, 2010 by dmacnet

If you use iTunes to make MP3s, you’re not making the best sounding MP3s you could. It appears to me that the iTunes MP3 encoder is optimized for encoding speed, not sound quality. For better sound quality, use the newer AAC (M4A) format instead of MP3; but if you need to make MP3s for compatibility with older players (hardware or software), the iTunes MP3 encoder is not the best one to use. For low bit rates (below 128 kbps), the Fraunhofer MP3 encoder produces the best results; it’s used in some commercial software such as the Pro Tools MP3 Option.

For medium to high bit rates (roughly 128 kbps and above), the best sounding MP3 encoder in my comparisons (and other peoples’) is a popular free one called LAME. On Macs, there is a way to make MP3s in iTunes using LAME instead of the iTunes built-in MP3 encoder. It’s a free application called iTunes-LAME. Here are its download page and installation instructions.

The LAME encoder program in the iTunes-LAME package is fine, but it is not the newest version (as of this writing, iTunes-LAME comes with LAME 3.97, and the newest is 3.98.2). If you want to take advantage of more recent quality and speed improvements to LAME, you can get a newer version of LAME for MacOS X. Look for a listing like “LAME 3.98 for MacOS X: A universal binary which will run on both PowerPC and Intel powered Macs”. To install it, double-click its DMG file, and a window should open up showing two files, “lame” and “COPYING”. Next, right-click (or control-click) on the iTunes-LAME application and select “Show Package Contents”. Open up the Contents folder in the resulting window, and the Resources folder under that. Rename the existing “lame” file there to something like “lame original” in case you ever want to revert to it, then drag the new “lame” file into that Resources folder.

Or, if you really want to keep up with the latest version and are comfortable compiling programs, you can get the LAME source code. You’ll need to use a Terminal window to compile it (and you need the Apple XCode Tools installed), then install the new “lame” file as described earlier.

Once you have iTunes-LAME installed, when you run iTunes a scroll icon (signifying scripts) shows up in your iTunes menu bar, toward the right. Click on the scroll and select “Import with LAME…” from the drop-down menu. This brings up the iTunes-LAME window.

The iTunes-LAME encoding options are specified using a text box. For personal use to get the best sound quality, I type --preset extreme (those are two dashes in a row before “preset”). If I want to use a particular bit rate, say 256 kbps, I type --preset cbr 256. Some other good settings for various purposes are documented on audio forums.

LAME has way more options than most people would care about, but fortunately you can ignore most of them. When you see references to --alt-preset, that’s just an older name for the --preset option.

The iTunes-LAME Prefs button brings up a preferences window which includes the option of whether it should encode all the tracks in the current playlist that are checkmarked, or those that are highlighted (selected). Set it whichever way you find more convenient.

After you have entered in the LAME encoding settings, to make MP3s just select (or checkmark, depending on that setting) one or more tracks in iTunes and click the big round Import button on the iTunes-LAME window.