Lossless video compression - Now with less bytes!
- Sir_Lagsalot
- Joined: Mon Jun 23, 2003 6:42 pm
Lossless video compression - Now with less bytes!
Lagarith is a lossless video codec I've been working on: http://lags.leetcode.net/codec.html
It compresses better than Huffyuv (and other lossless codecs I've come across) in every situation I've seen. The trade-off is speed naturally, it tends to encode at about half the speed Huffyuv does, and the decode speed is bit slower than the encode speed in most cases. More info and some numerical comparisons to Huffyuv can be found on the site.
Reasons I would recommend this codec:
Size matters and video will not be used often (archived lossless master copy, or if you have to send a lossless file to someone else)
The video is very compressable - Lagarith will absolutely mop the floor with Huffman for things like credits.
The video is very uncompressable - Lagarith can compress scenes that Huffyuv would expand, and purely random video was only expanded 0.25 percent in Lagarith; the same video crashed Huffman.
This was primarly tested with Virtualdub, so thats what I would recommend using. If you come across any errors in the codec, let me know.
It compresses better than Huffyuv (and other lossless codecs I've come across) in every situation I've seen. The trade-off is speed naturally, it tends to encode at about half the speed Huffyuv does, and the decode speed is bit slower than the encode speed in most cases. More info and some numerical comparisons to Huffyuv can be found on the site.
Reasons I would recommend this codec:
Size matters and video will not be used often (archived lossless master copy, or if you have to send a lossless file to someone else)
The video is very compressable - Lagarith will absolutely mop the floor with Huffman for things like credits.
The video is very uncompressable - Lagarith can compress scenes that Huffyuv would expand, and purely random video was only expanded 0.25 percent in Lagarith; the same video crashed Huffman.
This was primarly tested with Virtualdub, so thats what I would recommend using. If you come across any errors in the codec, let me know.
- Zarxrax
- Joined: Sun Apr 01, 2001 6:37 pm
- Contact:
- AbsoluteDestiny
- Joined: Wed Aug 15, 2001 1:56 pm
- Location: Oxford, UK
- Contact:
- Sir_Lagsalot
- Joined: Mon Jun 23, 2003 6:42 pm
I considered YUV, but have decided against it for the time begin due to the issue with converting to RGB for programs that can't handle YUV. Basicly, there are different methods for converting to and from YUV, and thus my implementation would likely not match what the encoder would have used; that is a program like Avisynth's YUV to RGB would produce different output than my codecs conversion from YUV to RGB, so you would get diffent video depending on where the conversion was done.
- jonmartensen
- Joined: Sat Aug 31, 2002 11:50 pm
- Location: Gimmickville USA
- Tab.
- Joined: Tue May 13, 2003 10:36 pm
- Status: SLP
- Location: gayville
Very nice. The only thing I'd be concerned about are the heavy patents on arithmetic coding, though I think ffv1 makes use of it, so I wouldn't worry unless you see ffmpeg go down :p
The gain is impressive. 70% of huffyuv, and according to my calculations, on my test sequence, only 120% larger than ffv1 if in yv12 colorspace. That's something for a one man project. I wonder if more of the gain comes from the arithmetic coding or the selective RLE. Good ideas.
Minor bug, it crashes dshow.
for encoding and
for decoding.
That's what I've settled on after going through a lot of papers that agree/disagree.
The only question is whether to use CCIR 601 or not.
Furthermore, AFAIK avisynth uses different numbers. For the sake of compliance, you could just stick to whatever vdub and avisynth use.
The gain is impressive. 70% of huffyuv, and according to my calculations, on my test sequence, only 120% larger than ffv1 if in yv12 colorspace. That's something for a one man project. I wonder if more of the gain comes from the arithmetic coding or the selective RLE. Good ideas.
Minor bug, it crashes dshow.
There's a lot of confusion in the area, but the correct matrices seem to be (assuming unsigned RGB -> signed YUV and back)I considered YUV, but have decided against it for the time begin due to the issue with converting to RGB for programs that can't handle YUV. Basicly, there are different methods for converting to and from YUV, and thus my implementation would likely not match what the encoder would have used; that is a program like Avisynth's YUV to RGB would produce different output than my codecs conversion from YUV to RGB, so you would get diffent video depending on where the conversion was done.
Code: Select all
Y = 0.299R + 0.587G + 0.114B - 128
Cr = -0.16874R - 0.33126G + 0.500B
Cb = 0.500R - 0.41869G - 0.08131BCode: Select all
R = Y + 1.402Cb + 128
G = Y - 0.34414Cr - 0.71414Cb + 128
B = Y + 1.772Cr + 128That's what I've settled on after going through a lot of papers that agree/disagree.
The only question is whether to use CCIR 601 or not.
Furthermore, AFAIK avisynth uses different numbers. For the sake of compliance, you could just stick to whatever vdub and avisynth use.
- Brad
- Joined: Wed Dec 20, 2000 9:32 am
- Location: Chicago, IL
- Contact:
Okay. I am hardly any kind of expert at all on video and compression and whatnot, so my tests and opinions probably won't really amount to a whole lot, but I figured I'd post my findings anyway.
I made a short movie in flash that had just animated text and gradients, with a lot of different colors. I wanted to do it like this so I could confirm for sure that there is nothing lossy going on. Had I tried it with like DVD video, there's still a bit of compression already there, so it'd be hard to tell where it was coming from. Anyways, the movie was about 8.6 seconds long, 246 frames, at 30fps. I exported the movie at 720x480.
Well, the first time around, I forgot that when Flash exports to AVI, any symbol that is labeled as a Movie Clip, doesn't play. So all I got was 246 frames of black video. But the file sizes were pretty interesting to see anyways:
Flash Movie Export Test 1 - Black Video
720x480 - 30fps - 8.6 seconds - 246 frames
Uncompressed - 249,085kb
Huffyuv 2.2.1 - 62,278kb
Lagarith - 8kb
Hehehe. So, that showed me that Lagarith handles solid colors (or at least black) much better than Huffyuv.
So I went back and changed the Movie Clips to Graphics so they'd play when exported to AVI, and re-rendered, and got this.
Flash Movie Export Test 2 - Animated Text, Colors, and Gradients
720x480 - 30fps - 8.6 seconds - 246 frames
Uncompressed - 249,085kb (duh)
Huffyuv 2.2.1 - 70,997kb
Lagarith - 24,837kb
NICE
Quite impressive! Zoomed in on the Lagarith video and didn't see any signs of quality loss.
So anyways, I wanted to go ahead and see how well it worked with actual video (in this case, rendered CG, not anime). So I went ahead and recompressed my FF8 Iron Chef video from a few days ago. Keep in mind this was edited in, and exported in FF8's native video settings of 320x224 and 15fps (suck)
CG Video Test - Final Fantasy 8 Iron Chef Video
320x224 - 15fps - 01:18 - 1148 frames - No Audio
Huffyuv 2.2.1 - 89,116kb
Lagarith - 58,530kb
Once again, quite nice! As seen it's not as big a ratio as before, but it's a different kind of video so thats to be expected. So, right on
The Lagarith did encode at about 60% the speed as the Huffyuv. It's also a bit slower at scrubbing/seeking than Huffyuv (which was explained in the original post). What it seems to boil down to is, if you need the space, go with Lagarith. If you need the speed, go with Huffyuv. Which... has already been said.. So I'm saying it again.. What? Ya wanna fight about it?!
So all in all, great new addition to the video codec arsenal
I'm sure I'll be using this for stuff eventually.
I made a short movie in flash that had just animated text and gradients, with a lot of different colors. I wanted to do it like this so I could confirm for sure that there is nothing lossy going on. Had I tried it with like DVD video, there's still a bit of compression already there, so it'd be hard to tell where it was coming from. Anyways, the movie was about 8.6 seconds long, 246 frames, at 30fps. I exported the movie at 720x480.
Well, the first time around, I forgot that when Flash exports to AVI, any symbol that is labeled as a Movie Clip, doesn't play. So all I got was 246 frames of black video. But the file sizes were pretty interesting to see anyways:
Flash Movie Export Test 1 - Black Video
720x480 - 30fps - 8.6 seconds - 246 frames
Uncompressed - 249,085kb
Huffyuv 2.2.1 - 62,278kb
Lagarith - 8kb
Hehehe. So, that showed me that Lagarith handles solid colors (or at least black) much better than Huffyuv.
So I went back and changed the Movie Clips to Graphics so they'd play when exported to AVI, and re-rendered, and got this.
Flash Movie Export Test 2 - Animated Text, Colors, and Gradients
720x480 - 30fps - 8.6 seconds - 246 frames
Uncompressed - 249,085kb (duh)
Huffyuv 2.2.1 - 70,997kb
Lagarith - 24,837kb
NICE
So anyways, I wanted to go ahead and see how well it worked with actual video (in this case, rendered CG, not anime). So I went ahead and recompressed my FF8 Iron Chef video from a few days ago. Keep in mind this was edited in, and exported in FF8's native video settings of 320x224 and 15fps (suck)
CG Video Test - Final Fantasy 8 Iron Chef Video
320x224 - 15fps - 01:18 - 1148 frames - No Audio
Huffyuv 2.2.1 - 89,116kb
Lagarith - 58,530kb
Once again, quite nice! As seen it's not as big a ratio as before, but it's a different kind of video so thats to be expected. So, right on
So all in all, great new addition to the video codec arsenal

