Task 016: Video codec for screencasting (off-line implementation)

Your task is to implement lossless (or near lossless) video codec usable for offline compression of screencast data (screen capture of a computer desktop). Encoder: sequence of (not very different) color raster images is at input side, output is a binary stream. Decoder converts binary stream back to sequence of raster images in the Bitmap format. You should aim for lossless compression or at least for compression with minimal distortion of reconstructed frames. You can expect simple input data, very coherent input frames, e.g. screencast from a Windows desktop.

Entropy codec

There is a standard vocabulary-based entropy codec ready for you: DeflateStream (Zlib) or a more effective buffered version BufferedDeflateStream.

Task

You have to implement a complete codec: both encoding and decoding part. You can expect flawless transmission of encoded binary stream, you need not do any form of error recovery. In typical situation there will not be extensive changes, small overwriting or shifts (translations, e.g. scrolling) can be expected.

The whole codec will be implemented in one class VideoCodec in single source file VideoCodec.cs.

Encoding could be done off-line, without any optimizations (further optimizations - motion compensation lookup - will be appreciate and awarded by bonus points). Decoder (video player) should be able to deliver middle sized images (e.g. 640x480px) with >= 10fps rate (so you have approximately 80ms time for decoding one frame).

Methods to be implemented: EncodeHeader(), EncodeFrame(), DecodeHeader() and DecodeFrame().

Ideas

You need to look for differences between adjacent frames, time to time there will be one complete (intra) frame, motion vectors (motion compensation) are assumed to be simple (partially constant motion feld). Residuls could be encoded rather simply for better speed.

Program

Simple Winforms application is ready for you. It is able to read subsequent input frames from disk files and feed them into your encoder. Decoding is done in reverse order, input binary stream is read and output frames are written to disk files in PNG format.

Additional functionality: program is able to grab windows desktop in realtime. You can enter a required speed (in Fps - Frames Per Second) and total recording time in seconds. Individual images in PNG format will be written to the given directory together with simple log-file.

Form

Bonus

Realtime encoding/decoding: either encoding in realtime (synchronously with screen capture in Windows) or realtime replay. You probably won't be able to replay the whole Windows desktop at full (original) speed, you can restrict replay to specific window.. You have to describe your efforts and optimization objectives in separate document for obtaining bonus point for this realtime part of the task. I will appreciate some additional time statistics (milliseconds for grab/encode/decode/render) and descriptin of used hardware (CPU type and speed, GPU type).

Deadline

Due to: 21. 2. 2016

Credits

Base: 25 points (functional code, reasonable performance), bonus points for realtime implementation (see above).

Project

Visual Studio project: 016videoslow.

Source file

Modify and submit the file: VideoCodec.cs

Test data

Short high-resolution sequence (1280x1024 px) is in this archive (61 MB).


Copyright (C) 2010-2016 J.Pelikán, last change: 2016-01-07 14:12:49 +0100 (Thu, 07 Jan 2016)