Raising The Bar On Non-Broadcast Output: Mastering and Encoding with Video Purifier and x264
COW Library : Apple Final Cut Pro X Tutorials : David Lawrence : Raising The Bar On Non-Broadcast Output: Mastering and Encoding with Video Purifier and x264
The DP did an amazing job, client editorial feedback was smart, everything cut together smoothly. You've finished the grading and sound mix and have final sign-off. It's a wrap! Time to deliver the finished goods to a happy client.
More and more often, this final deliverable is a video file encoded to H.264 for web or PC playback, rather than a tape or optical disc. If you're using Final Cut Pro, you can simply Send To Compressor, encode using one of the built-in H.264 settings and be done. It certainly does the job, but consider this: you're taking your pristine, carefully crafted video file - the product of countless hours of work - and running it through a process that will literally throw away up to 90% of the information!
Mastering and encoding are the last steps your project goes through before the world sees it. If you want your files to look their absolute best, it's well worth giving these final steps the same care and attention to detail you give the rest of your post-production efforts.
In this tutorial, I'll share a simple workflow I use to prepare my finished video files for non-broadcast delivery. Using these tools and settings, I'm able to create master files that look better than their edited source, and encoded files that are virtually indistinguishable from their masters.
Video Purifier for mastering and the x264 codec for encoding.
Mastering With Video Purifier
Video Purifier is a standalone Mac OS application (Lion compatible) made by Innobits AB, a Swedish company best known for its BitVice MPEG encoder. It's reasonably priced at $196 and can be purchased from the Innobits web site. A free demo version is available so you can try it risk free.
According to Innobits Owner, Roger Andersson, the unique, custom signal processing algorithm in Video Purifier "is geared towards bandwidth reduction to facilitate encoding at lower bit rates. Better picture is actually a byproduct." Andersson said that maintaining picture sharpness and detail, regardless of lower bit rates was a primary objective in the algorithm's design.
Video Purifier does three main things very well:
1) Noise reduction
Video Purifier performs each of these functions with precise control and quality rivaling more expensive systems. Its noise reduction technology is unavailable elsewhere. It works with any source frame rate and any size from SD to 4K. It will output to any codec format available on your system.
Its tools are useful for many applications, one of which is mastering.
Here are the steps I follow in creating a master:
1) Export a QuickTime pre-master from the NLE in native source format
My typical project timelines are ProRes 422 1080p24 or 30, and occasionally XDCAM-EX 1080i60. I'll usually mark-in two frames of black at the head before program start, and mark-out three frames of black after the last frame of program. If the program ends with a held frame, I make sure there are at least three frames of hold before the marked out point. This insures head and tail frames are always clean after encoding. I then export the marked region as a native format QuickTime file. This file is my pre-master.
Next, I watch the pre-master to check for quality. In particular, I look for any shots that may be extra noisy. If anything stands out, I'll make a note for later.
2) Open the pre-master in Video Purifier
Either drag the file into the Video Purifier window or open it from the File pull-down menu. The video will load and is ready to process. If Scene Detection is turned on in the preferences, Video Purifier will begin analyzing the footage to mark scene changes for easier navigation. I typically leave this setting OFF.
3) Set deinterlace preferences
Note - if your pre-master is progressive, you can skip this step.
Press CMD-P to open the preferences window. With interlaced footage, you must check the Interlaced 2:1 box in the Interlacing/Deinterlacing section. You must then specify field order by either checking or leaving unchecked the Top Field First box. It's very important to correctly match these boxes to your footage. Video Purifier will not set these values for you. Since we're ultimately targeting web/PC/mobile device delivery, we need to deinterlace. Check the Use deinterlacer box. Click OK to save the preferences.
4) Set the noise threshold
Even well lit, well-shot footage captured with good professional cameras will show a small amount of noise. If you look closely, especially in still areas with solid color, you'll often see a slight grain or scintillation moving in the image. Video Purifier does an outstanding job eliminating this random noise while leaving any subtle image details undisturbed. The change adds a noticeable crispness to the image.
Simple UI controls let you specify how much noise removal processing to apply and exactly where in the footage to apply it. At the window bottom, a scrubbable timeline with variable zoom range allows navigating the footage down to the frame level. The timeline displays thumbnails that scrub under the centered time indicator, as the cursor is dragged left or right. The main window shows the frame you're currently on.
Mark a range on the timeline with in and out points using the green and blue pin icons. Once a range is set, click the + or - buttons to set the noise reduction threshold for that range. Using these tools, it's possible to precisely set specific noise reduction thresholds in different sections of the footage. For example, an extra noisy shot can be marked and given a higher than normal threshold to deal with its greater noise.
At the top of the Video Purifier window are simple transport and window controls. Pressing Play plays the marked range in a loop. By default the window is split vertically down the center. The left side shows the frame before processing, the right side shows after processing. Clicking the + or - buttons as the video plays allows you to see the effect of the current threshold setting. You can slide the dividing line or the video under the line during playback to check the effect on different areas of the image.
Note - when processing, video does not play back in real time. The reason for this is because the processing algorithm looks 7 frames ahead and 7 frames behind each frame it processes. This means about 15 frames of processing are required before any threshold changes take visible effect and once in effect, playback will be still be slower than normal due to look ahead and look behind buffering. Nonetheless, even though playback is not in real time, it's fast enough to accurately judge the noise filter's temporal effects.
Threshold values range from 0 (off) all the way up to 60. For me, the sweet spot is between 4 and 7. At these lower values, processing is virtually transparent - noise is removed with almost no perceptible loss of image detail. Values above 10 begin showing subtle artifacts and details begin flattening.
Video Purifier works best on low to moderate random noise. If your footage is extremely noisy, or the noise has a structured pattern, it may not be effective. For heavy and/or structured noise - static or excessive gain for example, try the Neat Video plug-in, explained in this COW tutorial.
For typical mastering with minimal random noise throughout the program, I select all with CMD-A and set a threshold of 4.
5) Process and save the master file
After the threshold is set, press the Process button. A standard save dialogue asks where to save the file. After choosing the save location, a dialog asks what codec to use. I normally use ProRes 422 or an uncompressed format. Press OK and Video Purifier goes to work.
I find on my 2.8GHz late-2008 unibody MacBook Pro with 8GB RAM, processing times average about 4:1 the length of the program. Video Purifier relies on memory and memory bandwidth for its signal processing rather than CPU bandwidth. Lots of fast memory makes a bigger difference in performance than lots of CPU cores. This also means you can run Video Purifier in the background and it usually won't get in your way while you do other things.
When Video Purifier finishes, the master is done. This master is now the reference file for all subsequent work. At this point, I'll delete the pre-master as it's no longer needed.
6) Create scaled masters from the reference master
I deliver encoded videos in at least two or three sizes depending on client needs. Clients always receive a 1080p reference and 720p high quality file. Here are my typical delivery sizes:
a) 1080p reference (maximum size)
The 1080p reference master we just made will now be scaled to generate masters for the other needed sizes.
Open the file in Video Purifier and press CMD-P to open the preferences window. Make sure Constrain Proportions and Match Output/Destination are both checked. Enter your target width and height, and press Apply, then press OK to exit back to the main window.
Because we're working with the cleaned reference master, I leave the threshold at zero, which turns Video Purifier's noise filter off. This saves processing time so files finished scaling faster.
According to Andersson however, engaging the filter - even with a threshold of 1 - on the cleaned reference master would further improve the scaled files. This is because each scaled frame gets rendered from the 7 look-ahead and 7 look-behind frames in the noise filter algorithm; in effect, benefitting from a virtual "super resolution" at render time.
If you're not in a rush, press CMD-A to select all, then + to turn the noise filter on with a threshold of 1. Then process the file to disk as before.
Video Purifier's scaler quality is excellent and can be used for up-scaling as well as down-scaling.
Repeat this process for every size master you need. Once all the masters are finished, it's time to encode.
Encoding with x264
x264 is a free, open source library for encoding in the popular, industry standard H.264/MPEG-4 AVC format. Just to be clear:
x264 is H.264
x264 files are completely compatible/interchangeable with H.264 on any H.264 capable system.
The primary benefits of x264 are twofold - developers constantly optimize x264 algorithms for better and better quality and efficiency; and they expose a vast array of parameters to the user, allowing for much deeper manipulation of the codec. There are many forums online where video enthusiasts trade their x264 recipes. Feel free to experiment but make sure you understand what you're doing. If key parameters are incorrectly set, H.264 compatibility can break.
I find it's unnecessary to get that deep under the hood to get great x264 encodes. Here's the Compressor set-up and parameters I use. They're simple, safe and produce great looking results:
1) Download and install x264
Download the codec for Mac OS here: http://www.macupdate.com/app/mac/24173/x264encoder
2) Install by placing x264Encoder.component into the Library/QuickTime
3) Create Compressor presets
Create a new preset using QuickTime Movie as the file format. Select the Encoder tab and click Video Settings.
Select x264Encoder from the Compression Type dropdown list.
Set x264 options
Next click the Options button. There are over a hundred parameters available for tweaking. We're only interested in two:
Under the Behavior tab, make sure these settings are as follows:
Under the Tagging tab turn gamma 2.2 tagging ON
Note - QuickTime gamma is notoriously buggy. I learned about this x264 setting from research that led me to this web page:
In my testing, I found it works perfectly across platforms and devices. However, I recently saw this 2009 COW post that recommends the opposite approach:
I suggest you compare these settings yourself and post your results.
Once gamma tagging is set, click OK to close options, and OK to save the QuickTime video settings and exit back to the encoder tab.
Click the Audio Settings button in the encoder tab. Audio settings are a matter of taste. My preference is AAC Stereo, 44.1 Best quality, 320 Target Bit Rate. Click OK to save.
Set Frame Controls OFF
Next, click the Frame Controls tab. Make sure Frame Controls are off.
Set Geometry to 100%
Select the Geometry tab and select 100% of source for frame size.
Name, describe and save your preset.
Finally, give your preset a meaningful name and description so everything it does is obvious at a glance.
I have three presets with my three most common target bit rate values:
5000 kbits/sec for 1080p video
3000 kbits/sec for 720p video
2000 kbits/sec for 540p video and below
For SD and smaller videos, I'll drop the bit rate down by hand to 1.5K or 1K after applying the preset to the video.
Congratulations, you're ready to encode with x264.
Import your masters and use the appropriate bitrate for the frame size of each video. Since Video Purifier was used to scale and deinterlace the source files, encoding speeds in compressor will be faster because it doesn't have to also do this work.
I hope you've found this tutorial helpful. Give it a try and let me know what you think. If you have any questions, please leave them in the comments and I'll do my best to answer. I hope your finished files look better than ever!
Innobits Video Purifier Info:
Video Purifier free trial download:
x264 Mac download:
x264 Developer page
x264 Settings Wiki (All x264 settings explained!)
HandBrake x264 tune settings
Neat Video website
Neat Video Creative Cow Tutorial