[FFmpeg-user] Fastest lossless codec and settings.

Peter B. pb at das-werkstatt.com
Fri Jan 2 01:20:09 CET 2015

On 01/01/2015 06:14 PM, Zsolt wrote:
> Interestingly even rawvideo and the other uncompressed formats I tried
> resulted in high max/near-max CPU usage. I would have expected low cpu
> usage and I/O issues. Even if it's a lot of data muxing can't be that
> expensive, right?

My observations in that regard is, that uncompressed "should" have the
least computing requirements (=therefore soft on the CPU), but depending
on your setup and OS, file and data I/Os might cause considerable CPU
load, too.

You are completely right that uncompressed should have little CPU usage
and rather run into I/O bottlenecks.

> Is there a circumstance where YUV can losslessly sotore/restore the
> original image? The is issue is rounding errors, right?

Depends on what the original image's pix_fmt was:
For screen capture, I assume it's RGB 8bits per component, so pix_fmt
"bgr0" should contain the whole information.
For RGB<->YCbCr conversion, it mostly involves numerical and
quantization issues, maybe rounding too - but as far as I know there
*is* a conversion algorithm, used for example in JPEG2000 or FFV1, that
performs a lossless conversion between these pix_fmts.

It's called "RCT" (Reversible Color Transform) [1]:
"Proper implementation of the RCT requires that numbers are rounded as
specified that cannot be expressed exactly in matrix form."

Please correct me if I'm wrong, and don't immediately shoot me ;)

> Lot of recommendations, which is cool. But isn't there some sort of
> agreement which is the fastest lossless codec/setting? (Not counting
> uncompressed formats)

There are a handful of lossless video codecs, but depending on your
use-case and source material, there are choices to make.
Mainly due to the filesize, not many people are doing lossless yet, so
there's not so much hands-on-experience to start with.
Additionally, it's usually not a good idea to have a "one size fits all"
codec, since tries in that regards have often led to "jack of all trades
- master of none" results ;)

Christoph Gerstbauer was right, and has already mentioned "ffvhuff" (a
HuffYUV variant), as it seems to be one of the fastest lossless codecs
around. HuffYUV was released in 2000, and designed to perform in
real-time on the hardware of that time.
FFV1 compresses way better, but requires considerably more CPU.
for  screen-capture, "Motion PNG" might also be suitable?

FFV1 can do RGB (which would be necessary for screen-capture). Maybe
"ffvhuff" also supports RGB. You'd have to try.

Would be very interested in your performance observations, and which
codec you finally used.
May I ask about what CPU you're planning to use? ("older CPU" could
range from 286 to P4 2.x GHz...)


== References:
[1] http://en.wikipedia.org/wiki/JPEG_2000#Color_components_transformation

More information about the ffmpeg-user mailing list