News for hackers. Stuff that matters.
Re:How does a video codec work? by userbinator on Saturday November 23, 2019 @12:01AM (#21612568)
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 video being decoded entirely by code you wrote is a pretty fun experience, including all the weird and amusing distortions you can see when debugging; and from there you can move on to MPEG-1 with variable frame sizes and B frames (another weekend, assuming you reuse much of the 261 exercise --- I ended up with 1k lines total to decode MPEG-1), and that has somewhat more existing media you'll be able to watch.

Then you can try H.262/MPEG-2 and enjoy the intricacies of handling interlacing as well as being able to decode DVDs and a lot of existing content; and then there's H.263 which has intra prediction... I haven't gotten past the first two largely for reasons of time and other things to play with, but IMHO getting a basic implementation of a video decoder is not that hard especially when you're working from a standard.

Re:How does a video codec work? by sparklingriver on Saturday November 23, 2019 @09:31AM (#21614260)
Very cool idea! Is your code for this online anywhere?
Re:How does a video codec work? by userbinator on Saturday November 23, 2019 @04:21PM (#21616640)
Sorry, no. But a search of GitHub reveals some others have.
Re:How does a video codec work? by nayuki on Saturday November 23, 2019 @03:45PM (#21616412)
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? by userbinator on Saturday November 23, 2019 @04:18PM (#21616623)
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...