So, from time to time I get mired in some technical digression. It often occurs to me that I should document my efforts with the assumption that somebody else might be spared some anguish from repeating the mistakes.
In this case, I've been learning the best ways to use my new Canon HF100 AVCHD flash camera, and trying to use it for a few different purposes. Foremost is using it to capture performances of my kids at school, and various family events. Living across the country from most of my family, it benefits all of us to have some video of the kids as they quickly grow up.
One of the first decisions to make when shooting in digital HD is the recording format to use. Canon offers multiple capture settings which have various trade-offs, none of which are explained well in the manual. Primarily, there is the matter of recording "quality" which really translates to bandwidth. One of four modes must be selected to determine whether video is recorded at full-quality FXP-mode (17Mbps) down to LP-mode (5 Mbps). Only FXP records in true 1920x1080 HD, but the other settings provide a similar 1440x1080 image. A lot of video fits on a 16GB flash chip at any setting, but the lower modes provide some nice video in a compact format. That said, I tend to record in the 12Mbps XP+ setting, which doesn't completely overwhelm my PC when I'm playing it back. Ultimately, we'll acquire an HDTV and BlueRay-Disc player to view these home movies, and my goal is to preserve the original files on standard DVD until that time. Temptingly, the PS3 will play AVCHD video off of a standard DVD-R in high-def over HDMI, but we haven't one of those to play with, either.
The true confounder comes with the recording frame-rate selection. The camera offers three choices between 60i (interlaced), 30p (progressive), or 24p (progressive movie-mode). I don't have much need to mimic the frame-rates of film cameras, so the 24p doesn't interest me. However, it was difficult to choose between 60i and 30p. On the face, it seems that the 60 field/second interlaced setting and the 30 frame/second progressive are nearly identical. After all, the camera sensors only capture a fixed amount of data, and the bandwidth is fixed in a given mode. However, the resulting file differs greatly in ease-of-use as well as conversion. Although the 60i mode is more responsive for fast-action, the progressive setting is sufficient for my purposes and increases compatibility with current software video tools.
For example, YouTube will accept video in most any modern format, including AVCHD. Unfortunately, the 60i mode causes the YouTube video conversion to double the length of the video while corrupting the audio track. This problem occurs because they have no way to determine automatically that the frame-rate reflects an interlaced capture. As a consequence, they try to maintain audio-video synchronization by "stretching" the sound across the doubled frames. It's a mess. On the other hand, the 30p files were handled with ease, and display beautifully in "HD" on YouTube.
So what to do with the problem 60i files I already captured? After searching online for solutions, I discovered that few tools have caught up with this recording format. In addition, the various camcorders from different manufacturers haven't maintained full compatibility with the spec, so some files are more "standard" than others. Only very recent builds of free tools like VLC can play the files, but failed when trying to save a de-interlaced copy. There is one free tool that does an excellent job of decoding and transcoding the format, FFmpeg. This command-line tool has built-in decoders for dozens of still and motion digital formats, and happily converts to most modern output files. In this case, FFmpeg can read the interlaced AVCHD h.264 mpeg-transport-stream, and repackage the content as de-interlaced h.264 in an mpeg4 container format. The benefit being that YouTube will accept the high-quality result and successfully process the video as HD without complaint or corruption. One caveat being that the camera records audio in AC3 dolby-digital standard, but mpeg4 expects AAC audio. FFmpeg easily converts the sound with no apparent degradation, and supplies YouTube with the proper file.
For reference, here are the FFmpeg parameters that work for me:
ffmpeg.exe -deinterlace -i "r0001_test.MTS" -f mp4 -r 29.97 -vcodec libx264 -vpre hq -s 1440x1080 -b 12000kb -aspect 16:9 -acodec aac -ab 256k "r0001_test.mp4"
This is not a fast conversion for long videos, but it is worth the wait to clean-up the problems so I can share these home videos. Note: I have been experimenting with reducing the size of the output mpeg4 resolution, since YouTube shrinks the dimensions anyway.
I also tried out a couple FFmpeg GUI front-ends. A very powerful tool called SUPER exposes many settings for ease-of-use. However, the latest build of SUPER I could find contains a much older FFmpeg build, which doesn't handle the deinterlacing of h.264. I did discover the simpler WinFF, which lets me specify the build of FFmpeg to use. After creating a compatible preset option for this video conversion, it simplifies the process.
Thanks for reading.
Wednesday, July 22, 2009
Subscribe to:
Posts (Atom)
