Welcome to our community

Be a part of something great, join today!

  • Hey all, just changed over the backend after 15 years I figured time to give it a bit of an update, its probably gonna be a bit weird for most of you and i am sure there is a few bugs to work out but it should kinda work the same as before... hopefully :)

The Art of Compression and Encoding

Noobie question: is X264 the new H264? Also what is CRF?

X264 is H.264. It is the best way to encode H.264. H.264 is a broad standard, which is implemented in several different encoders. Adobe Media Encoder uses the MainConcept H.264 encoder, for example. However, X264 is far and away the best H.264 encoder out there.

As for CRF, let's go through the basics. With any compression, there are tradeoffs between - file size, quality and encode times. To target a certain file size, one inputs their desired bitrate. Similarly, to target a certain quality, we input CRF (constant rate factor). Once we target one of these two parameters, the other two remain variable. X264 has dozens of settings, each of which is a trade off between efficiency and encode time. There are presets too, designated by speed (e.g. Fast, Slow, etc). If we assume a target bitrate - the file size will remain the same, but the quality will change based on the presets used. The slower presets, higher the quality, but the longer the encode times. On the other hand, if we use CRF, the quality is constant no matter what our source footage is. It is the file size / bitrate which will change with the presets used. So, the slower presets will lead to greater compression and lower file sizes, but longer encode times. (E.g. Let's assume we are using CRF 18. Choosing Very Fast leads to a 4GB file encoded in 20 mins. Very Slow will get you identical quality in a 2GB file but take 2 hours to encode.) But quality is always constant. You can then use this bitrate and do an intensive 2-pass for slightly finer quality.

Why CRF is helpful - let's suppose one has to encode Transformers and Goodbye Dragon Inn. Two completely different films - one with hyperkinetic motion within the frame, with thousands of cuts - while the other is still, still characters, still camera, and maybe a hundred shots in the entire film. You can use a standard bitrate, let's say 6000 Mbps. This will give good results for both, but not ideal - quality will vary between the two. Instead, if we use CRF 18, we can optimize for quality rather than bitrate. Thus, the Transformers will end up with an average bitrate of 8 Mbps - with greater quality, while Goodbye Dragon Inn will compress down to 3 Mbps, but still maintain the same quality. This is of course assumes all the settings are common. In reality, one can achieve even greater compression by tweaking the settings depending on the type of source footage. E.g. by increasing the GOP size and Quantizer delta in the case of Goodbye Dragon Inn, you might get it down to 2.6 Mbps for the same quality.

And how to you control the CRF? Is it just an export setting in compressor or AME?

This is why I advise against using Compressor or AME - they are far too limited. CRF is by all means the most basic of parameters and even that is missing. Not to mention neither support X264. (athough you can get X264 working with AME with X264VFW on Windows - and X264VFW does feature CRF) It is best to use dedicated software like MeGUI. The best way, like I mentioned, is to use a frameserving app to serve frames directly from the NLE to the compression app.
 
And how to you control the CRF? Is it just an export setting in compressor or AME?
It's built into the X264 encoder. For example, in MPEGStreamclip you can go into options and enable that and change the values. I will include all of this in my testing of MPEGStreamclip.
 
Here's an excellent guide to tweak your X264 settings that I frequently refer to - http://mewiki.project357.com/wiki/X264_Settings.

It's built into the X264 encoder. For example, in MPEGStreamclip you can go into options and enable that and change the values. I will include all of this in my testing of MPEGStreamclip.

MPEG Streamclip is extremely limited as well. Even Handbrake has more options!
 
MPEG Streamclip is extremely limited as well. Even Handbrake has more options!
Although I agree when compared to some of the other options available, one of the things I'd like to be cognizant of is that people will be on multiple platforms. Handbrake, another Mac option, although certainly viable, has some limitations as well such as what kind of source it can take. I am using the most current version of X264 within MPEGStreamclip and it has additional parameters that were not in previous versions. I'd say it's actually got some decent controls in there, but again compared to some other tools, I realize it may fall short but for some people may be enough for most material. Subhadip, which version of X264 are you referencing as it relates to MPEGStreamclip?
 
Although I agree when compared to some of the other options available, one of the things I'd like to be cognizant of is that people will be on multiple platforms. Handbrake, another Mac option, although certainly viable, has some limitations as well such as what kind of source it can take. I am using the most current version of X264 within MPEGStreamclip and it has additional parameters that were not in previous versions. I'd say it's actually got some decent controls in there, but again compared to some other tools, I realize it may fall short but for some people may be enough for most material. Subhadip, which version of X264 are you referencing as it relates to MPEGStreamclip?

Fair enough - but it will be in the best interest of everyone if the best solutions for each platform are considered. It may well be the best option for Mac, but certainly isn't for Windows or Linux. That said, I must give MPEG Streamclip another go - the last I tried was a beta version for OS X a couple of months back, with the latest X264 build back then. I assume there have been changes since then? I use X264 2120 currently on Windows.

For OS X, Hybrid is worth a shot.

Edit - I just realized that there's no way to encode X264s on MPEG Streamclip on Windows. So it's not really a multi-platform solution.
 
Fair enough - but it will be in the best interest of everyone if the best solutions for each platform are considered. It may well be the best option for Mac, but certainly isn't for Windows or Linux. That said, I must give MPEG Streamclip another go - the last I tried was a beta version for OS X a couple of months back, with the latest X264 build back then. I assume there have been changes since then? I use X264 2120 currently on Windows.

For OS X, Hybrid is worth a shot.
Absolutely, I agree. I think we can cover a lot of ground from the most accessible of solutions (AME, Compressor, etc) to the more advanced, high end tools people are using. I think it will all be helpful. Here are some screen shots of X264 implementation in MPEGStreamclip. My guess is it's exactly what you used. Like I said, these controls are probably not as advanced as some other tools, and therefore may not be the ideal choice for everyone.
Flags.jpg

Values.jpg

Behavior.jpg

Tagging.jpg
 
@Steve, love the start simple approach - probably get 90% of possible quality with just understanding the off the shelf tools available to us all.
 
Absolutely, I agree. I think we can cover a lot of ground from the most accessible of solutions (AME, Compressor, etc) to the more advanced, high end tools people are using. I think it will all be helpful. Here are some screen shots of X264 implementation in MPEGStreamclip. My guess is it's exactly what you used. Like I said, these controls are probably not as advanced as some other tools, and therefore may not be the ideal choice for everyone.

Agreed. Beyond the default tools (AME, Compressor etc) I think any X264 frontend with the default presets is a good place to start. MPEG Streamclip is certainly adequate for this purpose. Are you using the latest beta?
 
Hell, a better example, how are apple trailers as good as they look when they're a measly 8.5mbit/s or whatever?

+1 on so many levels. Their stuff always look amazing.
 
Agreed. Beyond the default tools (AME, Compressor etc) I think any X264 frontend with the default presets is a good place to start. MPEG Streamclip is certainly adequate for this purpose. Are you using the latest beta?
I have both, the released version(1.9.2) and the beta(1.9.3b7). As far as I know, I have the latest Mac build of X264 encoder.

Perhaps a good strategy would be to start off with the basics, the entry level tools that allow some level of control and then work our way up from there. I am far from an expert on encoding, so I am hoping people like yourself will jump in and help this thing build momentum and become a valuable resource here.
 
I just waded through this thread. Good idea btw, Steve.

Besides compression I found scaling to be one of the most determining factor regarding the quality of the result. Here all the usual suspects don't do the best possible job. Telestream's Episode is doing best in this regard, Apple's Compressor is performing below average, IMHO. No wonder really. My Smoke renders under real time for scaling 1080p to SD using all available cores while Apple's compressor is as quick including compression and not using all cores. It's obvious that the software tools are optimized in render speed, not a thing that necessarily helps the quality.

I find that scaling the film down to the target resolution with a trusted tool uncompressed and from there compressing it to h264, WMV etc... is always better then letting the compression tool make the down-res. If you try to convert a pristine 1080p piece with very good text supers to SD MPEG2 for DVD you will notice the difference immediately on the text parts.

Otherwise all the compression tools do the job more or less well and have strengths and weaknesses:

Adobe Media Encoder: It is very good as creating Flash encoded clips and does not need extra plug-ins for this task. For some reason Adobe's Media Encoder creates funky black bars on the side when using one of the DVD presets.

Apple Compressor: It's good at creating ProRes files. Not every compressor can do that this good. Others have funky settings that make my Smoke not liking them. You have to dig pretty deep into the software to fix that.

Telestream Episode: Actually the best of the bunch when scaling is involved. Episode is the only one that allows WMV encoding on the Mac right out of the box. Unlike Adobe Media Encoder it is not linked to an NLE. This can be very helpful.

Bottom-line: On the Mac we have them all installed and use them according to their strengths.

Hans
 
Bloody hell lads, it's "Blu-ray". Get it right. Sorry, a pet peeve of mine.

On-topic: x264 is fantastic. The quality it can squeeze out of ridiculously low bitrates is nothing short of miraculous.
 
Thx Steve, this is a great initiative!

It's hard to find information about all parameters to be able to get the best results.
I have always used h.264 from MainConcept (which is inside the Sorenson Squeeze encoding tool). Reading this thread I think x264 might be a better option (more basic parameters to tweak?).
Within Squeeze's h.264, there's no crf controls available.
I work on windows, mostly DNXHD (Avid) or Uncompressed Animation (AfterEffects) to encode to Bluray/DVD/web.

:wink5:- waiting for my Scarlet-X -
 
One needs to take into consideration raster size of clip as well into the formula and what the viewer will be using when watching. Mobile devices like phones and tablets have a built in maximum size imposed by the screen. When watching on your computer with screen resolution of 1920 x 1080, then some choices have to made in trade-offs between bit rate, raster size, etc. One must also consider whether the quality of the player resize is good enough for what the end goal is - for example, making smaller than 720p for iPad consumption and letting the player scale. It depends on what the experience will be. For example, I am currently developing a solution for video viewing where I am looking for the best image at the lowest data rate that to fulfill the goal of the project. It does not need to be detail critical but I do need consistency in color. etc. There are lots of considerations when encoding and it is truly an art form, especially when delivering to different channels with different requirements. The industry as whole is working towards the one version in the sky and deliver on the fly to device based on connection - and to some extent that's what a slingbox does which I use a lot in my post work with remote clients for certain processes. There is also a time factor - if I am creating dailies for a quick review or a final piece for delivery, I will cut corners in the dailies version due to turnaround time.

Then there are potential issues between graphic levels and video levels. And what happens when a mobile device is played back to a device that is expecting video levels? Does it scale the black/white levels accordingly? Then you run into the different "looks" modes on home screen and projectors for normal, dynamic, cinema, etc. which all play with levels and tweaking of certain ranges of the color space. If I watch an RGB encoded movie which is 0-255 on such a monitor and cinema mode is on which basically takes the 16-255 levels and makes it full range, you end up with crushed blacks - and that's assuming the monitor was close to being correct overall in the first place. I have no idea what my iPad is calibrated to, and how consistent that is overall.

And of course progressive sources always encode better overall compared to interlace (motion resolution versus data rate), and starting out with a high resolution images engages the concept of "supersampling" when creating images at lower resolution, bit depth data rate, etc. Trailers look so good because they are at 24fps (low frame rate) and progressive - any given data rate will have more quality per frame at 24 compared to 30 or 59.94.

My quick thoughts -


Michael
 
these guys have done a good job of optimizing Compressor and it's only 39 bucks. I get good results.

http://www.compressorpack.com

would love to have something similar developed for Adobe, now that we are all migrating.

this is another very good alternative: http://www.dvkitchen.com/features/encoder.html -

DV Kitchen is fast, which makes it easy to run experiments with various compression selections, until you get a result you like.

These are both simple and inexpensive.

Also - DivX is becoming a decent alternative - the problem has always been narrow acceptance, but I think that's changing.

More good links on the subject...

http://www.compression.ru/video/codec_comparison/mpeg-4_avc_h264_2005_en.html

http://www.doom9.org/index.html?/codecs-final-105-1.htm
 
Resizing is definately part of compression quality.
What bothers me is that in Photoshop you can choose from 5 different resizing algorithms. There's no such option in Premiere Pro (or AE). There were times I resized in Photoshop just to know that the optimal algorithm was being used.
Right now my latest info was that, working in Premiere, creating a new sequence and resizing the source within the timeline and then export is supposed to give best results, but there are different opinions out there.

As for x264, how do you guys update it? Do I have to remove older versions or even packs that contain it like ffmpeg when updating?
 
Last edited:
There are lots of considerations when encoding and it is truly an art form, especially when delivering to different channels with different requirements.

There is also the fact that one size does not fit all, and one set of settings can't possibly be optimal for every scene in a show. That's why scene by scene programmed compression is what's done for DVD and BluRay releases. And that compression is controlled by a compressionist, a person whose sole job is to determine proper optimal compression settings on a per scene basis based on the total "bit budget," or the required final file size. That's one reason why studio level DVD's have always looked a lot better than those produced by individuals using single compression settings, regardless of the compression engine. When there are fewer compromises, there are better results.
 
Back
Top