19 ms·
H.264 is Magic
- deleted 10y ago[deleted]
- LASR 10y agoThank you! I hope you now share my feeling of awe over this technical wonder.
- willvarfar 10y agoExcellent! :) It would be really cool to further extend it showing actually how the various tiles are encoded and between frames, something along the lines of: http://jvns.ca/blog/2013/10/24/day-16-gzip-plus-poetry-equals-awesome/ http://jvns.ca/blog/2013/10/24/day-16-gzip-plus-poetry-equal... H.265 can even do deltas between blocks in the same frame, IIRC, and is excellent for still image compression too.
- CuGi 10y agoExcuse me, i would like my account back.
- amelius 10y ago> discard information which will contain the information with high frequency components. Now if you convert back to your regular x-y coordinates, you'll find that the resulting image looks similar to the original but has lost some of the fine details. I would expect also the edges in the image to become more blurred, as edges correspond to high-frequency content. However, this only seems to be slightly the case in the example images.
- LASR 10y agoYou're right! The images that I am using are zoomed cropped sections of a much larger image of the entire Apple home page.
- shoggs 10y agoThis is probably because in the sample image you have clean vertical edges. It's pretty easy to represent these edges with a waveform.
- LordDragonfang 10y agoYou can see exactly that with the speaker grill and the text (This type of transformation is notoriously bad at compressing images of text, and is why you shouldn't use jpg for pictures of text) In this context, the edges of, say, the macbook are not "high frequency" content, since they only feature one change (low to high luminosity) in a given block rather than several (high-low-high-low-high) like for the grill.
- amelius 10y agoYou should have a look at the Fourier transform of a step-function. It has high frequency components.
- hal9000xp 10y agoJust yesterday, I've read this one: http://web.cs.ucla.edu/classes/fall03/cs218/paper/H.264_MPEG4_Tutorial.pdf http://web.cs.ucla.edu/classes/fall03/cs218/paper/H.264_MPEG... How does DCT work: https://www.youtube.com/watch?v=Q2aEzeMDHMA& https://www.youtube.com/watch?v=Q2aEzeMDHMA&
- szemet 10y agoI thought I'll learn something special about H.264, but all information here is high level and generic. For example if you replace H.264 with a much older technology like mpeg-1 (from 1993) every sentence stays correct, except this: "It is the result of 30+ years of work" :)
- phire 10y agoAlso the fleeting mention of b-frames, which mpeg-1 doesn't have. And I believe mpeg-1 doesn't use 16×16 macroblocks. Still, it's a good overview of generic video compression.
- szemet 10y agohttps://en.wikipedia.org/wiki/MPEG-1#B-frames https://en.wikipedia.org/wiki/MPEG-1#B-frames https://en.wikipedia.org/wiki/MPEG-1#Macroblocks https://en.wikipedia.org/wiki/MPEG-1#Macroblocks
- striking 10y agoSure, but also keep in mind that the technology hasn't changed much over time. Even HEVC, which causes extreme gains in compression on high-res video with minimal loss in quality, is still mostly the same algorithm as H.264 but with larger blocks, slightly more flexible coding units rather than frame-wide interpolation changes, and 35 rather than 9 directions recognized for predictions.
- BEEdwards 10y ago"This post will give insight into some of the details at a high level - I hope to not bore you too much with the intricacies." Did you miss the third paragraph? As someone who knew nothing about it before, I found it lived up to it's goal.
- iainmerrick 10y agoI think they just mean it shouldn't be "H.264 is magic", it should just be "video compression is magic" or some such. That irked me a little bit too.
- userbinator 10y agoThe lossy transform is important, but I think what's actually most important in video compression is getting rid of redundancy --- H.264 actually has a lossless mode in which that transform is not used, and it still compresses rather well (especially for noiseless scenes like a screencast.) You can see the difference if you compare with something like MJPEG which is essentially every frame independently encoded as a JPEG. The key idea is to encode differences; even in an I-frame, macroblocks can be encoded as differences from previous macroblocks, and with various filterings applied: https://www.vcodex.com/h264avc-intra-precition/ https://www.vcodex.com/h264avc-intra-precition/ This reduces the spatial redundancies within a frame, and motion compensation reduces the temporaral redundancies between frames. You can sometimes see this when seeking through video that doesn't contain many I-frames, as all the decoder can do is try to decode and apply differences to the last full frame; if that isn't the actual preceding frame, you will see the blocks move around and change in odd ways to create sometimes rather amusing effects, until it reaches the next I-frame. The first example I found on the Internet shows this clearly, likely resulting from jumping immediately into the middle of a file: http://i.imgur.com/G4tbmTo.png http://i.imgur.com/G4tbmTo.png That frame contains only the differences from the previous one. As someone who has written a JPEG decoder just for fun and learning purposes, I'm probably going to try a video decoder next; although I think starting from something simpler like H.261 and working upwards from there would be much easier than starting immediately with H.264. The principles are not all that different, but the number of modes/configurations the newer standards have --- essentially for the purpose of eliminating more redundancies from the output --- can be overwhelming. H.261 only supports two frame sizes, no B-frames, and no intra-prediction. It's certainly a fascinating area to explore if you're interested in video and compression in general.
- logicallee 10y agoThis is really interesting and the imgur picture you linked (with your explanation) explains it really clearly! But when seeking, why wouldn't any local media playback seek backwards and reconstruct the full frame? It's not like the partial frame after seeking is useful - I'd rather wait 2 seconds while it scrambles (i mean "hurries up") to show me a proper seek, wouldn't everyone? What was your Internet search for finding that imgur frame? What is this effect called?
- afghanPower 10y agoA real fun read. Had an assignment a couple of weeks ago where we used the most k most significant singular values of matrices (from picture of Marilyn M.) to compress the image. H.264 is on a whole other level, though ;)
- bananicorn 10y agoNow the Question is - Manson or Monroe - and which one would be easier to compress? ;)
- woliveirajr 10y agoI love how you can edit photos from people to correct some skin imperfections without loosing the touch that the image is real (and not that blurred, plastic look) when you decompose it in wavelets and just edit some frequencies. Don't know in photoshop, but in Gimp there's a plugin called "wavelet decomposer" that does that.
- avian 10y agoI guess this is the plugin you are talking about? Interesting. http://registry.gimp.org/node/11742 http://registry.gimp.org/node/11742
- woliveirajr 10y agoExactly that. There was a question about retouching photos some while ago (http://photo.stackexchange.com/questions/48999/how-do-i-take-flattering-photos-of-people-with-acne-scarring http://photo.stackexchange.com/questions/48999/how-do-i-take...) that using wavelets was a good use of it.
- zeveb 10y agoWell, that's the most awesome thing I've seen in a long time! Thanks for sharing.
- deleted 10y ago[deleted]
- spacehacker 10y agoThe part about entropy encoding only seems explain run-length encoding (RLE). Isn't the interesting aspect of making use of entropy in compression rather to represent rarer events with longer longer code strings? The fair coin flip is also an example of a process that cannot be compressed well at all because (1) the probably of the same event happening in a row is not as high as for unfair coins (RLE is minimally effective) and (2) the uniform distribution has maximal entropy, so there is no advantage in using different code lengths to represent the events. (Since the process has a binary outcome, there is also nothing to gain in terms of code lengths for unfair coins.)
- vcool07 10y agoThis was a good and interesting read. Is h.264 an open standard ?
- shocks 10y agoDoesn't look like it; https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC > H.264 is protected by patents owned by various parties. A license covering most (but not all) patents essential to H.264 is administered by patent pool MPEG LA.[2] Commercial use of patented H.264 technologies requires the payment of royalties to MPEG LA and other patent owners. MPEG LA has allowed the free use of H.264 technologies for streaming internet video that is free to end users, and Cisco Systems pays royalties to MPEG LA on behalf of the users of binaries for its open source H.264 encoder.
- 0x09 10y agoIt is an open standard. Anyone can purchase and implement it, and it was developed by ISO. The technologies are not royalty free in the US. Don't conflate the two. * Edit: I emphasize this mainly because the terms have a specific meaning in standards jargon but also because it places the blame for software patent abuses on the wrong parties (the standards developers rather than the lawyers and legislators).
- gcp 10y agoblame for software patent abuses on the wrong parties (the standards developers) Uh, anyone familiar with the MPEG process will assure you that the companies involved love (let me restate that: PREFER) to bring in technology on which they own the patents so they get a good cut of the resulting patent pool. Sometimes this is even done even though it technically makes no sense. Best example: hybrid filter-bank in MP3. The process also provides no protection or discouragement from patents from semi-involved industry partners appearing later on, etc. This difference in approach is a stark contrast to the IETF, which is why Opus work, and future AV1 work are happening under the IETF rather than the MPEG groups.
- 10y ago
- Savageman 10y agoI wonder if across a lot of videos, the frequency domain representations look similar and if instead of masking in a circle we could mask with other (pre-determined) shapes to keep more information (this would require decoders to know them, of course). Or maybe this article is too high-level and it's not possible to "shape" the frequencies.
- LASR 10y agoIt's certainly possible to use any arbitrary shape. The way it really works is that there is a quantization matrix - which essentially is a configurable mask for your frequency domain signal. Yes, I've dumbed it down in the article to a simple circle to illustrate the point.
- eutectic 10y agoAnyone who likes this would probably also enjoy the Daala technology demos at https://xiph.org/daala/ https://xiph.org/daala/ for a little taste of some newer, and more experimental, techniques in video compression.
- dao- 10y agoNote that Daala has been discontinued in favor of AV1: https://en.wikipedia.org/wiki/AOMedia_Video_1 https://en.wikipedia.org/wiki/AOMedia_Video_1 Previously Daala was presented as a candidate for NETVC but apparently this didn't go anywhere? https://en.wikipedia.org/wiki/NETVC https://en.wikipedia.org/wiki/NETVC
- eutectic 10y agoThe demos are still neat, and some of the ideas are being used in AV1.
- ZeroGravitas 10y agoI'm not sure if there's been an official announcement, but I had assumed that AV1 was going to be adopted/ratified as NETVC so that it's got a standards body rubber stamp, as well as the practical adoption/support from browser vendors, GPU manufacturers, streaming sites etc.
- TD-Linux 10y agoA lot of Daala tools are now being copied into AV1, the largest being PVQ: https://aomedia-review.googlesource.com/#/c/3220/ https://aomedia-review.googlesource.com/#/c/3220/
- mbebenita 10y agoDaala continues to be research platform for new ideas. New techniques are a lot easier to prototype in Daala than in more mature code bases.
- amelius 10y agoWhat are directions for the future? Could neural networks become practically useful for video compression? [1] [1] http://cs.stanford.edu/people/eroberts/courses/soco/projects/2000-01/neural-networks/Applications/imagecompression.html http://cs.stanford.edu/people/eroberts/courses/soco/projects...
- p0nce 10y agoPerhaps for intra-prediction. I wouldn't hold my breathe.
- deleted 10y ago[deleted]
- jerf 10y agoSuppose I have a table of 8-digit numbers that I need to add and subtract for various reasons. Do I A: have a child, train them how to read numbers, add, and subtract, and then have the child do it or B: use a calculator purpose built to add and subtract numbers? Neural nets are always expensive to train. You'd better be getting something from them that you can't get some other way.
- gugagore 10y agoYes, you don't need the machinery of learning when you already have an algorithm you're happy with. Adding a table of numbers, I don't think anyone hopes to do much better than we already do with our circuits and computer architectures. With video compression, I think most would agree that there might be better architectures/algorithms that we haven't stumbled upon yet. Whether specifically "neural networks" will be the shape of a better architecture, I don't know. But almost surely some meta-algorithm that can try out tons of different parameters/data-pipeline-topologies for something that vaguely resembles h.264 might find something better than h.264. Neural nets are expensive to train. But so is designing h.264.
- Ajedi32 10y agoGoogle has been experimenting with image compression using AI for a while now: https://research.googleblog.com/2016/09/image-compression-with-neural-networks.html https://research.googleblog.com/2016/09/image-compression-wi...
- markatkinson 10y agoDamn, lost me during the frequency part.
- Koshkin 10y agoSometimes it's just easier to learn the math. (I am not kidding.)
- iplaw 10y agoH.265 gets you twice the resolution for the same bandwidth, or the same resolution for half the bandwidth.
- AndrewUnmuted 10y agoNo, it doesn't. Though that may have been the goal, HEVC has only thus far achieved an improvement of around 25%, not 50%.
- keldaris 10y agoIn my anecdotal experience, h265 gets me 50-60% improvements in file sizes at the same quality for fairly low quality targets and the gains drop off rather quickly as you increase the quality. For videos where you don't care about the quality all that much, it's superb.
- ksec 10y agoH.265 gets you half the file size for ten times more in royalty fees, or saving 50% of bandwidth for 1000% more in royalty.
- iplaw 10y agoHilarious!
- _puk 10y agoDo you have a reference for that? I was under the impression that the first 100,000 units are free, and then 20c per unit afterwards to a max of $25m. H264 drops to 10c per unit after 5m units, to a max of $6.5m. You need to be shipping 125 million units annually to hit the full $25m. Yes it's more, but it's not quite ten times. And notably if the chip maker pays the royalties, then the content creators don't need to (though that was excepted indefinitely with H264). Parts regurgitated from a quick google for reference [1] [1] http://www.theregister.co.uk/2014/10/03/hevc_patent_terms_thrashed_out_but_look_whos_not_at_the_codec_party_microsoft_and_google/ http://www.theregister.co.uk/2014/10/03/hevc_patent_terms_th...
- molind 10y agoWow, now tell me how H.265 works!
- adilparvez 10y agoRelated, how h265 works: http://forum.doom9.org/showthread.php?t=167081 http://forum.doom9.org/showthread.php?t=167081 This is a great overview and the techniques are similar to those of h264. I found it invaluable to get up to speed when I had to do some work on the screen content coding extensions of hevc in Argon Streams. They are a set of bit streams to verify hevc and vp9, take a look, it is a very innovative technique: http://www.argondesign.com/products/argon-streams-hevc/ http://www.argondesign.com/products/argon-streams-hevc/ http://www.argondesign.com/products/argon-streams-vp9/ http://www.argondesign.com/products/argon-streams-vp9/
- alexandrerond 10y agoVery well explained. But I could have understood it all without the bro-approach to the reader. You see where I am going with this? Get it? See where I am going? Ok!
- alexk307 10y agoMaybe I'm in the minority here but I think it adds a bit of color to an otherwise dry topic to write about.
- nothrabannosir 10y agoI remember loving this style when I was a novice, e.g. Beej's networking tutorial. Not a big fan anymore, either, but certainly valuable for (part of) the target audience, I think.
- deleted 10y ago[deleted]
- ComodoHacker 10y agoToday you need tricks like that to get Twitter-generation people to read even half of that amount of text.
- rimbombante 10y agoArticles like this are what makes HN great, and not all those repeated links to the visual studio 1.7.1.1.0.1.pre02-12323-beta3 changelog.
- algesten 10y ago"See how the compressed one does not show the holes in the speaker grills in the MacBook Pro? If you don't zoom in, you would even notice the difference. " Ehm, what?! The image on the right looks really bad and the missing holes was the first thing I noticed. No zooming needed. And that's exactly my problem with the majority of online video (iTunes store, Netflix, HBO etc). Even when it's called "HD", there are compression artefacts and gradient banding everywhere. I understand there must be compromises due to bandwidth, but I don't agree on how much that compromise currently is.
- dosshell 10y ago>No zooming needed Isn't the images above the text a zoomeed version? >Here is a close-up of the original...
- exprA 10y agoThere's another false claim like that a bit below. I can only assume that the author is close to legally blind, or uses a VGA-res display to watch the page.
- coryfklein 10y agoOf course while reading the article you are going to be very conscious of detail and image quality because that is the subject matter of the post. However if that MacBook Pro image was placed on the side of an article where the primary content was the text you were reading, you'd glance at the image and your brain would fill in the details for you. You probably wouldn't notice the difference in that context. For most use cases, there likely is very little functional difference between the two images. At least, that was how I understood it.
- VikingCoder 10y agoUgh. Comparing the file size difference between a lossless PNG and a LOSSY H.264 video of a STATIC PAGE is absurd. Calling it "300 times the amount of data," when it's a STATIC IMAGE is insulting in the extreme. It really doesn't matter if the rest of the article has insights, because you lost me already.
- arbitrage 10y agoIt's a very high level example of the concept, which admittedly is absurd, but drives home the point for people who might not be familiar with the scope of the numbers involved.
- 1maginary 10y agoHe clarifies right after that he got to those numbers because he used a lossless vs lossy encoder. Really should've kept reading
- VikingCoder 10y ago"right after that". No he didn't explain "right after that." He rambled on and on, and even after all of that, he STILL doesn't bring up JPG. It's an inherently stupid comparison to make. You can't polish a turd.
- LASR 10y agoThanks for the feedback! Sorry if I was unclear. The comparison with PNG is very intentional to illustrate the vast difference in the compression efficiencies involved. I do state the difference clearly here though: > This concept of throwing away bits you don't need to save space is called lossy compression. H.264 is a lossy codec - it throws away less important bits and only keeps the important bits. > PNG is a lossless codec. It means that nothing is thrown away. Bit for bit, the original source image can be recovered from a PNG encoded image.
- mozumder 10y agoSo what's the final car weight? It looks like you stopped at the Chroma subsampling section..
- LASR 10y ago6.5 Ounces! or 0.4 lbs. Thanks for the feedback! I added the final weight into the conclusion.
- FunctionalGuy 10y ago"Uncompressed" video has been stored, even before computers, as YUV (or some variant), not RGB as this author states. It makes me doubt everything else he says.
- kakarot 10y agoYa'll wanna get the most out of your H.264 animu rips? Check out Kawaii Codec Pack, it's based on MPC and completely changed my mind about frame interpolation. http://haruhichan.com/forum/showthread.php?7545-KCP-Kawaii-Codec-Pack http://haruhichan.com/forum/showthread.php?7545-KCP-Kawaii-C...
- voltagex_ 10y agoa) offtopic b) Leave codec packs in 2000 where they belong. They are a great malware vector and also good at messing with settings they shouldn't. >KCP utilizes the following components: MPC-HC - A robust DirectShow media player. madVR - High quality gpu assisted video renderer. Included as an alternative to EVR-CP. xy-vsfilter / XySubFilter(future) - Superior subtitle renderer. LAV-Filters - A package with the fastest and most actively developed DirectShow Media Splitter and Decoders. (Optional) ReClock - Addresses the problem of audio judder by adapting media for smooth playback OR utilized for bit perfect audio. I'm actually using MPC-HC and AC3Filter to deal with some files where I couldn't hear the centre channel on VLC (on stereo speakers). Everything else isn't really needed.
- kakarot 10y agooh crap it's the topic police. I use it specifically for madVR and interpolating frames for high-quality low FPS anime. It looks really great. The best I've found for this particular purpose. Be nice.
- john111 10y agoCan someone explain how the frequency domain stuff works? I've never really understood that, and the article just waves it away with saying it's like converting from binary to hex.
- raverbashing 10y agoIt's the Fourier transform basically. There were even some past links on HN that explained it nicely so you might check those first (Though for images it's in 2D, not 1D which is more commonly done)
- jerf 10y agoThe search keyword to learn about it is Fourier Transform: https://en.wikipedia.org/wiki/Fourier_transform https://en.wikipedia.org/wiki/Fourier_transform Along with the Wikipedia article and the obvious Internet search, there's a lot of good stuff that has been on HN: https://hn.algolia.com/?query=fourier%20transform&sort=byPopularity&prefix&page=0&dateRange=all&type=story https://hn.algolia.com/?query=fourier%20transform&sort=byPop...
- rayiner 10y agoIt's a bad analogy. Binary and hex are just different formats for representing the same number. Spatial domain and frequency domain are different views of a complex data set. In the spatial domain, you are looking at the intensity of different points of the image. In the frequency domain, you are looking at the frequencies of intensity changes in patterns in the image. A good way to develop an intuition for the fourier space is to look at simple images and their DFT transforms: http://web.cs.wpi.edu/~emmanuel/courses/cs545/S14/slides/lecture10.pdf http://web.cs.wpi.edu/~emmanuel/courses/cs545/S14/slides/lec... (3/4 of the way through the slide deck). This analysis of a "bell pepper" image and its transform is also helpful: https://books.google.com/books?id=6TOUgytafmQC&pg=PA116&lpg=PA116&dq=dft+image+intensity+changes&source=bl&ots=m8lUh6N0ms&sig=dXNH4GYn39FVen9nZ7pv30zss5k&hl=en&sa=X&ved=0ahUKEwicnYfFpI_QAhWs6YMKHcoqBOIQ6AEIRjAG#v=onepage&q=dft%20image%20intensity%20changes&f=false https://books.google.com/books?id=6TOUgytafmQC&pg=PA116&lpg=.... As for why you want to do this: throwing away bits in the spatial domain eliminates distinctions between similar intensities, making things look blocky. In the frequency domain, however, you can throw away high-frequency information, which tends to soften patterns like the speaker grills in the MBP image that the human eye isn't that sensitive to to begin with.
- notlisted 10y agoWell done. The only thing that could make this better is an interactive model/app for me to play around with. The frequency spectrum can probably be used while retouching images as well. A video on youtube led me to Joofa Mac Photoshop FFT/Inverse FFT plugins [1] which was worth a try. I was unable to register it, as have others. Then I came across ImageJ [2], which is a really great tool (with FFT/IFFT). Edit: if anyone checks out ImageJ, there's a bundled app called Fiji [3] that makes installation easier and has all the plugins. If anyone has other apps/plugins to consider, please comment. [1] http://www.djjoofa.com/download http://www.djjoofa.com/download [2] https://imagej.nih.gov/ij/download.html https://imagej.nih.gov/ij/download.html [3] http://fiji.sc/ http://fiji.sc/
- 0x09 10y agoI published a set of utilities that I developed for playing and to help myself learn about frequency analysis here, you might find them interesting: https://github.com/0x09/dspfun https://github.com/0x09/dspfun
- 11thEarlOfMar 10y agoDo H.264 and WebRTC have different use cases? Or do they compete directly?
- eddieh 10y agoLet's say you want to video chat with someone using only web browsers, you would establish a direct peer-to-peer connection with WebRTC and then you could stream H.264 video to each other. I'd say WebRTC and H.264 compliment each other. However, the shared stream or data need not be H.264.
- amluto 10y agoNice article! The motion compensation bit could be improved, though: > The only thing moving really is the ball. What if you could just have one static image of everything on the background, and then one moving image of just the ball. Wouldn't that save a lot of space? You see where I am going with this? Get it? See where I am going? Motion estimation? Reusing the background isn't motion compensation -- you get that by encoding the differences between frames so unchanging parts are encoded very efficiently. Motion compensation is when you have the camera follow the ball and the background moves. Rather than encoding the difference between frames itself, you figure out that most of the frame moved and you encode the different from one frame to a shifted version of the blocks from a previous frame. Motion compensation won't work particularly well for a tennis ball because it's spinning rapidly (so the ball looks distinctly different in consecutive frames) but more importantly because the ball occupies a tiny fraction of the total space so it doesn't help that much. Motion compensation should work much better for things like moving cars and moving people.
- erydo 10y agoYour example seems to assume translation only. I wonder how difficult/useful it would be to identify other kinds of time-varying characteristics (translation, rotation, scale, hue, saturation, brightness, etc) of partial scene elements in an automated way. Along the same lines, it would be interesting to figure out an automated time-varying-feature detection algorithm to determine which kinds of transforms are the right ones to encode. Do video encoders already do something like this? It seems like a pretty difficult problem since there are so many permutations of applicable transformations.
- kutkloon7 10y ago"This concept of throwing away bits you don't need to save space is called lossy compression." What a terrible introduction of lossy compression. This would mean that if I empty the thrash bin on my desktop, it's lossy compression. The concept of going through all compression ideas that are used is pretty neat though.
- Jweb_Guru 10y ago> This would mean that if I empty the thrash bin on my desktop, it's lossy compression. It is.
- lostgame 10y agoAbsolutely love this: 'Suppose you have some strange coin - you've tossed it 10 times, and every time it lands on heads. How would you describe this information to someone? You wouldn't say HHHHHHHHH. You would just say "10 tosses, all heads" - bam! You've just compressed some data! Easy. I saved you hours of mindfuck lectures.' This is a really great, simple way to explain what is otherwise a fairly complex concept to the average bear. Great work.
- chrisseaton 10y agoThat's only one half of the problem - you now have an alphabet five times the size so you have actually increased the size of the message! You also need to explain how to encode this efficiently to explain compression.
- deanCommie 10y agoNot really - the knowledge of what an alphabet can be universally agreed upon and doesn't need to be transmitted with the data. The metaphor here is that software and hardware-based decoding can now be much more powerful because the hardware is more powerful than it used to be. And of course the truth is you would just transmit "H_10" with the universally agreed upon knowledge that "H" is "Heads" and "_" is number of times.
- chrisseaton 10y ago> you would just transmit "H_10" with the universally agreed upon knowledge that "H" is "Heads" and "_" is number of times. Yes I get that the alphabet is already agreed upon. But if I only transmit H or T (uncompressed) that's just one bit needed per symbol. So I can transmit HHHHHHHHH in ten bits. If I introduce this simplified compression to the system and add 0-9 to the alphabet, that now needs four bits per symbol, so the message H10 is 12 bits long (which is longer than uncompressed). And HTHTHTHTHT would be forty bits so if the message doesn't repeat simply it's now four times larger! See what I mean? It's not successfully compressed anything. The solution to this is easy and is Huffman coding, but it doesn't make sense to show it for a ten bit message as it won't work well, and in the trite explanation of compression of 'just the symbol and then the number of times it's repeated' this isn't mentioned, so it's only half the story and people will still be puzzled because they will see that your message contains MORE entropy after 'compression', not LESS!
- mtw 10y agoEven better H.265 with 40-50% bit rate reduction compared with H.264, at the same visual quality!
- olegkikin 10y agoBut much higher hardware requirements for both encoding and decoding. Encoding is like 8x slower too.
- imaginenore 10y ago> "If you don't zoom in, you would even notice the difference." First of all, I think he meant "you would NOT even notice". Second of all, that's the first thing I noticed. That PNG looks crystal clear. The video looks like overcompressed garbage.
- mentioned_edu 10y agoNice
- problems 10y agoReally cool stuff, one thing though seems a little odd: > Even at 2%, you don't notice the difference at this zoom level. 2%! I'm not supposed to see that major streakiness? The 2% difference is extremely visible, even 11% leaves a noticably bad pattern on the keys (though I'd probably be okay with it in a moving video), only the 30% difference looks acceptable in a still image.
- andrewvijay 10y agoWell explained. I was thinking of reading about h264 and this is an amazing starter. Thanks Sid!
- dirtbox 10y agoI like this video explaining the difference between H.264 and H.265 https://www.youtube.com/watch?v=hRIesyNuxkg https://www.youtube.com/watch?v=hRIesyNuxkg Simplistic as it is, it touches on all the main differences. The only problem with H.265 is the higher requirements and time needed for encoding and decoding.
- the8472 10y ago> Chroma Subsampling. Sadly, this is what makes video encoders designed for photographic content unsuitable for transferring text or computer graphics. Fine edges, especially red-black contrasts start to color-bleed due to subsampling. While a 4:4:4 profile exists a lot of codecs either don't implement it or the software using them does not expose that option. This is especially bad when used for screencasting. Another issue is banding, since h.264's main and high profiles only use 8bit precision, including for internal processing, and the rounding errors accumulate, resulting in banding artifacts in shallow gradients. High10 profile solves this, but again, support is lacking.
- wmil 10y agoThis is also the bane of powerpoint presentations. Many TVs only support 4:2:0, so red on black text quickly becomes an smudgey mess.
- astrange 10y agoIt's easy to make a 4:2:0 upscaler that doesn't color bleed. Everyone just uses nearest-neighbor, which sucks, and then blames the other guy.
- shabbyrobe 10y agoHow would you make a 4:2:0 upscaler that doesn't color bleed?
- astrange 10y ago50% solution: bicubic or bilinear. 90% solution: EEDI3. (kinda slow) 99% solution: use the full resolution Y plane for edge-direction.
- the8472 10y agoI don't think that can accurately restore the details that have been created by subpixel-AA font rendering. But if you have source/subsampled/interpolated comparisons that show 99% identical results i would be interested to see them. Of course all that is useless if you don't have control over the output device. Just having the ability to record 4:4:4 makes the issue go away as long as the target can display it, no matter what interpolation they use.
- dluan 10y agoBy the way, this is an incredible example of scientific writing done well. It's very tangible jelly-like feeling that the author clearly has for the topic, conveyed well to the readers. This whole thread is people excited about a video codec!
- titanomachy 10y ago> This whole thread is people excited about a video codec That's not really a weird thing on HN though. Video codecs are exactly the kind of thing that we get excited about.
- LASR 10y agoThank you! It means a lot to me. Yes, I try to convey my sense of excitement about technology to other people.
- nojvek 10y agoThis is a really well written article. Exactly why I love HN. Sometimes you get this nice technical intros into fields you thought were black magic.
- neo2006 10y agoThe comparison doe not make any sense, and no h264 is not magic!!: - The guy is comparing a lossless format PNG to H264 which is a lossy video format, that is not fair. - he is generating a 5 frame video and compared to 1 frame image, only the I-frame at the begining of the video matter in that case al the others are derived from it, P-Frame. - What is the point of having that comparaison we already have images format comparable to the size of a H264 I-frame and using the same science (entropy coding, frequency domain, intra frame MB derivation...)?
- mcherm 10y agoDid you read the article? The point you are making here is PRECISELY the point that the author was making in the article: that a lossy format can be far, far smaller. He then goes into the details (from a high-level point of view) of what kinds of losses H264 incurs.
- some1else 10y agoTry scrubbing backwards. H264 seeking only works nice if you're fast-forwarding the video. Actually, that is kind of magical.
- AWildDHHAppears 10y agoRight at the beginning, he says uncompressed video is "RGB". This has never been true, even before computers. Uncompressed video is YUV or one of the variants.
- mherrmann 10y agoI recently experienced this as follows: https://www.sublimetext.com https://www.sublimetext.com has an animation which is drawn via JavaScript. In essence, it loads a huge .png [1] that contains all the image parts that change during the animation, then uses <canvas> to draw them. I wanted to recreate this for the home page of my file manager [2]. The best I could come up with was [3]. This PNG is 900KB in size. The H.264 .mp4 I now have on the home page is only 200 KB in size (though admittedly in worse quality). It's tough to beat a technology that has seen so much optimization! 1: http://www.sublimetext.com/anim/rename2_packed.png http://www.sublimetext.com/anim/rename2_packed.png 2: https://fman.io https://fman.io 3: https://www.dropbox.com/s/89inzvt161uo1m8/out.png?dl=0 https://www.dropbox.com/s/89inzvt161uo1m8/out.png?dl=0
- hrjet 10y agoYou could give FLIF [1] a try. With the help of Poly-FLIF [2] you can render it in the browser. Don't forget to try the lossy mode, it gives better compression with negligible loss in quality. 1: http://flif.info http://flif.info 2: https://github.com/UprootLabs/poly-flif/ https://github.com/UprootLabs/poly-flif/
- cogwheel 10y agoMB is 1024 * 1024 * bytes not 1000 * 1000 * bytes. Unless you're a HDD/SSD manufacturer.
- garaetjjte 10y agoMiB (mebibyte) is 1024 * 1024 bytes.
- deleted 10y ago[deleted]
- imperialdrive 10y agoGreat Write-up, thank you for your time and effort!
- optimuspaul 10y agoI enjoyed this for the most part and even learned a little. But it started out very simple terms and really appealing to the common folk. But then about halfway through the tone changed completely and was a real turn off to me. It's silly but this "If you paid attention in your information theory class" was the spark for me. I didn't take any information theory classes, why would I have paid attention? I don't necessarily think it was condescending, but maybe, it's just that the consistency of the writing changed dramatically. Anyway super interesting subject.
- syastrov 10y agoAn enjoyable, short and to the point article with many examples and analogies. But my favorite part was this: "Okay, but what the freq are freqX and freqY?"
- ludwigvan 10y agoWhat is the latest in video compression technology after H264 and H265? The article discusses lossy compression in broad terms, but have we reaped all the low hanging fruit? Can we expect some sort of saturation just like we have with Moore's law where it gets harder and harder to optimize videos?
- andrey_utkin 10y agoToo trivial, too general, too pompous. I'd downvote.
- wizkkidd 10y agotime to move on H.265
- wizkkidd 10y agotime to move on: h.265
- wizkkidd 10y agotime to make move on: h.265
- el0j 10y agoThe PNG size seems to be misrepresented. The actual PNG is 637273 bytes when I download it, and 597850 if I recompress it to make sure we're not getting fooled by a bad PNG writer. So instead of the reported 916KiB we're looking at 584KiB. This doesn't change the overall point, but details matter. $ wget https://sidbala.com/content/images/2016/11/FramePNG.png --2016-11-04 22:08:08-- https://sidbala.com/content/images/2016/11/FramePNG.png Resolving sidbala.com (sidbala.com)... 104.25.17.18, 104.25.16.18, 2400:cb00:2048:1::6819:1112, ... Connecting to sidbala.com (sidbala.com)|104.25.17.18|:443... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [image/png] Saving to: ‘FramePNG.png’ FramePNG.png [ <=> ] 622.34K --.-KB/s in 0.05s 2016-11-04 22:08:08 (12.1 MB/s) - ‘FramePNG.png’ saved [637273] $ pngout FramePNG.png In: 637273 bytes FramePNG.png /c2 /f5 Out: 597850 bytes FramePNG.png /c2 /f5 Chg: -39423 bytes ( 93% of original)
- nartsbtaa 10y agoWhy even compare PNG and H.264 to begin with? PNG is a lossless compression format. A better comparison would be something lossy like JPG, which could easily shrink the size to ~100 kB. The point still stands, but at least it's a more relevant comparison.
- i336_ 10y agoI found this explanation of Xiph.org's Daala (2013) very interesting and enlightening in terms of understanding video encoding: https://xiph.org/daala/ https://xiph.org/daala/ Related: BPG is an open source lossless format for images that uses HEVC under the hood, and is generally better than PNG across the board: http://bellard.org/bpg/ http://bellard.org/bpg/ For a runner-up lossless image format unencumbered by H265 patents (completely libre), try http://flif.info/ http://flif.info/.
- necessity 10y agos/magic/lossy
- monochromatic 10y agoThis is great as a high-level overview... except that it's way too high-level. These are all extremely well-known techniques. Is there any modern video compression scheme that doesn't employ them? In other words, why is H.264 in particular magical?
- aaron695 10y agoH.265/HEVC vs H.264/AVC: 50% bit rate savings verified http://www.bbc.co.uk/rd/blog/2016/01/h-dot-265-slash-hevc-vs-h-dot-264-slash-avc-50-percent-bit-rate-savings-verified http://www.bbc.co.uk/rd/blog/2016/01/h-dot-265-slash-hevc-vs...
- umbs 10y ago"1080p @ 60 Hz = 1920x1080x60x3 => ~370 MB/sec of raw data." I apologize if this is trivial. What does 1920 in above equation represent?
- kayoone 10y ago1920x1080 is the typical resolution of 1080p Full HD, is that you mean?
- boundlessdreamz 10y ago1080p is 1920x1080 px Btw question is trivial but don't feel apologetic about asking questions. None of us know everything and in a field we don't know, our questions will be trivial.
- xyproto 10y agoCopyrighted and patented magic.
- el0j 10y agoIf the author truly wants 'magic', how about we take a 64KiB demo that runs for 4 minutes. That's 64KiB containing 240 seconds of video, and your H.264 had to use 175 for only five seconds on video. We can conclude that 64KiB demos are at least 48 times as magical as H.264.
- bjn 10y agoWell written article.
- mohdz4939 10y agoI need hacker
- mohda786921 10y agoI need hacker