Wednesday, June 9, 2010

Editing H.264 in Ubuntu

It took weeks of searching through marginally informative posts to get enough information together to edit the HD video captured by the 5D Mark II in Ubuntu 10.04, but I'm happy to say that I have at least three solutions at this point with which I'm very pleased. HD video captured with the 5D Mark II is stored using the H.264 video codec and raw 16-bit PCM audio, all of which is wrapped in a QuickTime container. Having never gotten very serious about video before, at least two weeks were dedicated to constructing that one sentence.

The first approach to dealing with this absolutely stunning video is to use the Pitivi video editor, which is included with the Lucid Lynx release of Ubuntu. The problem with using Pitivi is that the probability that rendering will fail increases with increasing project size (at least as of version 0.13.4). I was unable, for example, to render projects that included more than about eight minutes of video. This is a known issue and I expect a fix soon. The other problem is that it's missing some basic features like transitions, but the interface is so simple and intuitive, you'll be able to pick it up in a few minutes. For a version number like 0.13.4, you can hardly complain and I'd use Pitivi immediately for anything under about 5 minutes, pulling in images created in GIMP for titles, credits, and etc.

I had the most success rendering with the default settings (Ogg container, Vorbis audio encoding, Theora video encoding), but neither Facebook nor YouTube were happy with these. Both Facebook and YouTube were happy, however, with renders to an MP4 container with XViD (xvidenc) video and AAC (faac) audio encoding, but I really had to do a lot of work to make these available in Ubuntu because neither encoder is provided with the distribution version. If you want to use Ubuntu for this type of editing, you're going to have to bite the bullet and compile some things yourself. Visit the Ubuntu forums for more information. For some reason, I have yet to get x264enc to work for anything, which is why I'm still using XViD.

The link to the forum post above, in fact, brings me to solution number two, ffmpeg. I'm fully convinced that this command-line utility would do everything I ever needed to do with video if I understood it well enough. Until then, here are a few simple recipes I've put together for working with video from the 5D Mark II. If you want to use Cinelerra to edit the video, use ffmpeg to convert it to a more palatable form as follows:

ffmpeg -i X -vcodec mpeg4 -b 3000k -s hd720 -acodec libfaac -ab 256k -ar 44100 Y.mov

where X is the input (e.g. MVI_0001.MOV) and Y is the output (e.g. MVI_0001.MOV again in this case). After this conversion, Cinelerra will play both the audio and video tracks and the -s hd720 is only required if you'd like to reduce the size of the video before using it in Cinelerra. Cinelerra is, in fact, my third solution, but it requires ffmpeg as a preprocessing step.

If you want some compression before uploading to Facebook or YouTube, use the following:

ffmpeg -i X -vcodec copy -qscale 2 -s hd720 -acodec libfaac -ab 128k -ar 44100 Y.mp4

And if you want to trim a segment out of the video first, use the following:

ffmpeg -i X -vcodec copy  -acodec copy  -ss HH:MM:SS -t HH:MM:SS Y

where the first time (-ss) is the start time and the second time (-t) is the duration of the video segment you'd like to keep. I oscillate between specification of the bitrate (-b) and the quality (-qscale). You only need one or the other and I think specifying the quality is probably the easiest unless you're dealing with a hard bitrate requirement.

So there it is. Hop on Ubuntu, follow the ffmpeg directions in the link above, use the handful of recipes provided, and check out Pitivi and Cinelerra for more advanced editing. The best places to look for help are the link above and man ffmpeg. Good luck!

Sunday, August 2, 2009

Watermarking with Lightroom and ImageMagick


Someone gave me a friendly reminder that I should update my watermark today. The watermark I had been using appears at the bottom of an image, which is easy to crop. Given my unending faith in humanity, I suspected that everyone would retain the original copyright notification, but my faith was, once again, misplaced. As a result, the watermark you see above will now be a central feature of most of my posted images. The rest of this entry explains how to put together something like this yourself using Lightroom 2.4 (LR) and ImageMagick (IM).

The fact is that LR will watermark images for you automatically when you export them, but boy is it ugly. IM affords a plethora of possibilities (and perhaps even a plethora of piƱatas if you ask nicely), all of which may be accessed from the command line by telling LR to execute a simple batch file after an export. Start by downloading and installing IM if you haven't done that already. Now locate the folder to which LR will export and create a new text file there called watermark.bat. Right-click on that file and select Edit, which should open a blank document in Notepad. Copy the following text into this file, save it, and close it:

:BEGIN
IF _%1 == _ goto END
CALL composite -compose screen Watermark.psd %1 %1
SHIFT
GOTO BEGIN
:END

This code is based on the code I found here. Watermark.psd may be replaced with any image you like and IM will use it as a watermark after we add some post-processing in LR. Let's do that now. With an image or three selected, open the export dialog in LR and scroll all the way down to the bottom where it says Post-Processing. Select Open in Other Application ... and then select the batch file you just created. Click Export and voila. If you'd like more options for combining your watermark with your exported images, refer to the IM site above or do a search as there are literally thousands of helpful tips available for this tool. In the meantime, I'll work on restoring said faith.

Thursday, July 23, 2009

Liveview and the Hoya R72


I tried the Hoya R72 with the EF 24-70 f/2.8L this morning only to find out that it wasn't quite enough light for liveview, although shooting outside instead of through my office window might make the liveview bright enough to see. I had heard that the EF 50mm f/1.4 had a hot-spot problem, but I decided to try it anyway to see if I could get liveview working. In fact, liveview worked brilliantly with this lens and I found that I could zoom and focus as usual through the Hoya R72. I took this setup outside and shot the image of our wall above using an exposure of 30 seconds at f/2.8 and ISO 400. There was indeed a hot-spot in the image, but it was very mild and a large, gradual exposure adjustment brush with a value of -0.60 fixed the problem in Lightroom. For processing, I did something new based on an article I found here. I used a custom DNG profile I created based on the article to help me find a neutral white balance in Lightroom and then moved things over to Photoshop CS3 only to switch the red and blue channels. An excellent video tutorial on creating your own custom DNG profile was linked in the article and can be found here. Based on these results, I may very well use the EF 50mm f/1.4 for IR images and I'll give the EF 24-70 f/2.8L another try in more light.

Monday, July 20, 2009

A Quick and Dirty IR Workflow


I had some reading to do today and so I walked down to the park and set up the camera for a 45-minute exposure. Up until now, I've been shooting out of my office window and the composition isn't exactly a Minor White. After a few 45-second test shots at f/4.0 and ISO 3200, I set the remote for 45 minutes and the camera for ISO 50. It's convenient that seconds at ISO 3200 are about the same as minutes at ISO 50. The same is true for ISO 6400 and ISO 100, which makes a nice rule of thumb. Before pressing start on the remote, I attached the lens hood, tied my floppy sun hat over the viewfinder, and hung my backpack from the tripod. The sun would be shining on the filter for the next 45 minutes, so the lens hood wouldn't be any help, but the hat kept light from leaking in through the viewfinder and onto the sensor, which has been a very repeatable problem in the past. The backpack was used to stabilize the tripod on an already breezy day. With all of that in place, I hit start and sat down to read.

Exactly 45 minutes later, I packed everything up, leaving the camera on and the viewfinder covered for the ensuing 45-minute dark image, and headed home. I left the camera outside while it collected the dark image because the air conditioner was on and I would expect the hot-pixel signature to change with temperature. Once again, I sat down to read. Another 45 minutes later, I brought the camera in and imported the image into Lightroom 2.4. I set the color temperature to 2000 and the tint to -130, which are values that have worked well in the past for what we're about to do, and adjusted the exposure, brightness, contrast, and etc. as usual. When I had a pretty good looking image, I shipped the results over to Photoshop CS3, switched the red and blue channels using the channel mixer, and added a warming filter (85) at 45%. None of these steps are required, of course, but the false color image that results has a deep blue sky and warm highlights, which may be appropriate for some compositions.

In the end, the image was just off from tack-sharp, but the clouds cooperated beautifully, the camera stayed put, there was no viewfinder leakage, and the sun on the filter didn't do a thing. I attribute the softness to the f/4.0 aperture and so I imagine I'll move right back to a very comfortable f/11 when the Hoya R72 arrives.

A Foray into IR



I started this blog because I kept reading that an unconverted Canon EOS 5D Mark II either can't be used for IR photography or that the exposures are prohibitively long as a consequence of the very strong IR-blocking prefilter that comes with the camera. These remarks discouraged me from using the camera for IR work until I actually tried it and, to my surprise, found that the camera was both very well suited for long exposures and sensitive enough to even the deep IR to produce very high quality images. In fact, this camera has won awards for its long exposures, making it very well suited to IR photography when you actually want the exposure to be long. I do, so this is a match made in, well, a very enjoyable place.

The image above (and the accompanying 1:1 crop) was taken out of my office window using a Canon EOS 5D Mark II that has not been converted for use with IR, a Canon EF 24-70 f/2.8L, a Tiffen #87 IR filter, and an exposure of 90 minutes at f/4.0 and ISO 50. From this point forward, you can assume that all of the IR images presented were taken with this combination of camera and lens as this lens is the only good lens I have on the good list. Two of my other favorite lenses, the Canon EF 50mm f/1.4 and the Canon 70-200 f/2.8L IS produce hot spots, putting them on the bad list. I should also note that liveview cannot be used with the Tiffen #87 because the image is too dark, however I've read elsewhere that liveview can be used with the much more standard Hoya R72, which is really more of a Near IR (NIR) filter than an IR filter as it begins transmitting light at 700 nm, reaches 50% by 720 nm, and 85% at 750 nm. Hopefully I can locate a Hoya R72 at a reasonable price soon.

For the time being, I can safely recommend two different daylight exposures in association with the Tiffen #87: 2 hours at f/4.0 and ISO 50 or 1 hour at f/4.0 and ISO 100. Both of these assume you're shooting with the equipment above at 24mm and will produce sharp, high-quality images from about 10 feet to infinity. Make sure to set the infinity focus exactly at the 24mm IR mark on the lens (the red line extending to the number 24) and enable Long Exposure Noise Reduction in the Custom Functions as this seems to perform better than any hot-pixel correction scheme available in post-processing.