Compression is important as audio, video and image files generally take up a large amount of storage space compared to other data types. Compression reduces the number of bits in total required to represent the same information. This increases transfer speed and allows more data to be stored in a similar space. Compression is done via a CODEC (compression-decompression), which is an algorithm used by an application to save and open a file. Both the software opening the file and the software encoding the file must possess the codec.

All types of compression can be classified into lossy and lossless compression.

Lossless data compression replaces a recurrent sequence of data with a symbol. Hence, the data can be expanded when it is decompressed without loss of information or quality.

Lossy data compression permanently removes data from a file, which affects the quality of the media displayed. Although data is lost, the human perception of the quality is not altered significantly.

Image files often use compression techniques such as JPEG (see image on right) for lossy compression, or TIFF or PNG for lossless.

JPEGs compress bitmap images based on the fact that many images contain data invisible to the eye, such as small colour changes. An image is analyzed, and areas with little to no texture are grouped as a similar colour. For example, the blue sky would be grouped as a shade of blue. Lossy compression works by replacing a repeated sequence of bits with a symbol, for example every time 1011010111011001 occurred in a sequence, it might be replaced with "%", thereby reducing the total size of the file. The size of the data being compressed should be more than the data symbol representing it.

Lossless compression is good for high quality images for example when sending a book to print or using a projector, but lossy compression works for most monitors or webpage viewing.

Audio files are recorded as WAV files. These files have no compression, and play sound back exactly as it was recorded, however because the human ear can only hear sounds within a certain frequency range, there is a lot of unnecessary data. Therefore, MP3 CODECs are used, as they eliminate all unhearable frequencies and can reduce the size of a waveform file to (in ideal cases) to 1/10 of the file's original size. MIDI (Musical Instrument Digital Interface) is a codec created specifically for writing music, and cannot be used for recording.

Using applications to write the musical score, MIDI files record the instructions for how to play back the music rather than the actual sounds created by the playing of the music and is therefore much more compressed than non-MIDI files. Audio is recorded using a microphone and recording software, which turn analogue sound waves into digital sound bars of different pitch and amplitude. The quality of sound is determined by the sampling rate and sample size, or how often a measurement is taken and the quality (byte size) of that measurement.

Video is either in PAL format or NTSC format. NTSC is used by America and Japan, and has a frame rate of 30 fps (frames per second), while PAL is used in Australia with 24fps. Commonly used video CODECs include Mpeg 2, which is used on DVDs, MPEG 4 and AVI which are commonly used on PCs. The audio component of video data is often compressed as MP3 files and sent with the video. Video compression works based on the principle of converting the images to YCbCr? format, similar to RGB with different colours, as these represent the luma and chroma signals better, as one of these channels can be represented with less resolution than the other optically.