Live data from Hacker News

How does a video codec work?

github.com

41–50 of 53 posts

Re: How does a video codec work?

#41
post #10

One thing that I wish more folks did with DSP/media tech was to start with concepts instead of diving into details first. Like, "how does a video codec work?" should start with: what is the problem? (reducing the bits per second required for a video stream, since it's big) and how? (don't send superfluous detail, since it's either redundant or imperceptible). Than dive into the details of how color is represented, ho…

To be fair the article does that. The above URL just links to an anchor in the middle where it talks about codec implementation. For instance this quote from the article "We learned that it's not feasible to use video without any compression; a single one hour video at 720p resolution with 30fps would require 278GB*. Since using solely lossless data compression algorithms like DEFLATE (used in PKZIP, Gzip, and PNG),…

278GB is a bit off. The real number is higher than that, but not by too much more, but they definitely messed up on their math somewhere. 1280 horizontal pixels times 720 vertical pixels times 8 bits per pixel color channel times 3 color channels (RGB) times 30 FPS times 60 SPM (sec per min) times 60 MPH (min per hour) divided by 8 bits to convert bits to bytes and finally divided by 1,024 bytes per kilobyte gives 291,600,000KB, exactly 291.6GB.

And now days, that kind of uncompressed video is more than feasible, at least in countries with developed gigabit internet capability, as you'd need just 634mbit of bandwidth to handle an uncompressed 720p stream at 30 FPS. Local storage on even first-gen SATA drives can hit double+ that.

Storage itself? Well, we've got the cloud, right? /s

Re: How does a video codec work?

#42

If you're interested in more "hands on" or practical video codec learning, I recommend writing a H.261 decoder. Only two supported frame sizes, no B-frames, and no intra prediction (effectively a subset of JPEG) make for a simple yet possibly quite rewarding weekend project that can be completed in around 700 lines of C (my attempt). Unfortunately not much existing media is available in 261, but I think watching a vi…

I'm sold on this idea! Are there readily available documents that specify the bitstream and decoding semantics for H.261?

Re: How does a video codec work?

#43
post #42

If you're interested in more "hands on" or practical video codec learning, I recommend writing a H.261 decoder. Only two supported frame sizes, no B-frames, and no intra prediction (effectively a subset of JPEG) make for a simple yet possibly quite rewarding weekend project that can be completed in around 700 lines of C (my attempt). Unfortunately not much existing media is available in 261, but I think watching a vi…

I'm sold on this idea! Are there readily available documents that specify the bitstream and decoding semantics for H.261?

www.itu.int has H.261 and the rest of the H.* standards, they're a free download.

This is H.261:

https://www.itu.int/rec/T-REC-H.261/en

Direct link to the spec itself is here:

https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-H.26...

Re: How does a video codec work?

#44
post #10

Earlier quoted context omitted.

To be fair the article does that. The above URL just links to an anchor in the middle where it talks about codec implementation. For instance this quote from the article "We learned that it's not feasible to use video without any compression; a single one hour video at 720p resolution with 30fps would require 278GB*. Since using solely lossless data compression algorithms like DEFLATE (used in PKZIP, Gzip, and PNG),…

278GB is a bit off. The real number is higher than that, but not by too much more, but they definitely messed up on their math somewhere. 1280 horizontal pixels times 720 vertical pixels times 8 bits per pixel color channel times 3 color channels (RGB) times 30 FPS times 60 SPM (sec per min) times 60 MPH (min per hour) divided by 8 bits to convert bits to bytes and finally divided by 1,024 bytes per kilobyte gives 29…

You're mixing Si units and IEC units[1]. The article's measurement of 278 GB (sic) is really 278 GiB.

1280 horizontal resolution x 720 vertical resolution x 3 8-bit bytes per pixel x 30 frames per second x 3600 seconds per hour is 298,598,400,000 bytes per hour. 1GiB (1,024 bytes x 1,024 KiB x 1,024 MiB) is 1,073,741,824 bytes. Dividing that out gives ~278.09 GiB.

[1] https://en.wikipedia.org/wiki/Binary_prefix

Re: How does a video codec work?

#45

If you're interested in more "hands on" or practical video codec learning, I recommend writing a H.261 decoder. Only two supported frame sizes, no B-frames, and no intra prediction (effectively a subset of JPEG) make for a simple yet possibly quite rewarding weekend project that can be completed in around 700 lines of C (my attempt). Unfortunately not much existing media is available in 261, but I think watching a vi…

Very cool idea! Is your code for this online anywhere?

Sorry, no. But a search of GitHub reveals some others have.

Re: How does a video codec work?

#46

Earlier quoted context omitted.

Apple does support (and contribute to) open video standards.

sure, if by support you mean "embrace, extend, extinguish". Today, Apple is every bit as monopolistic and anti-competitive as Microsoft was during Peak Ballmer.

If that's the narrative you're focused on, you'll want to point to something else to support that.

Apple not only uses standards-based compressed media formats exclusively, but the MPEG-4 file format is the QuickTime Movie file format (which Apple contributed to the standard).

Re: How does a video codec work?

#47
This is all very cool, but what annoys me the most is that, let’s say you create video authoring software, it creates a piece of unique content and you decide to use a codec that’s licensed; you’ve got to pay royalties. If you use another it’s not supported by default. .FLAC for example or .oggv

To not be liable to lawsuits and to support your own you need to come up with your own codec, resulting in your own platform and the circle starts once again.

Why in this age can we just not all work together and make something that’s usable by everything for everyone without any restrictions.

Re: How does a video codec work?

#48

Earlier quoted context omitted.

Irrespective of love or hate, support for open video standards would be better for everyone.

Apple does support (and contribute to) open video standards.

I was replying to the parent comment who seemed to think this wasn’t the case. I use IOS but wouldn’t consider myself a ‘power user’ so either way is news to me

Re: How does a video codec work?

#49

Earlier quoted context omitted.

Not sure what you mean, a stock iPhone plays a VP8 webrtc stream with no issues?

https://www.webmfiles.org/demo-files/ Play in Chrome (Mac/Win/Linux/Android) and Firefox (Mac/Win/Linux/Android) but not Safari (Mac/iOS). Here's a few more https://commons.wikimedia.org/w/index.php?search=webm I would be nice if Apple would support open standards. It's unclear what their motive is for not supporting them.

> It's unclear what their motive is for not supporting them.

Programmers don't work for free, Apple has to pay them. Motivation works the other way, they need a motive to support some tech.

Post reply on HN