Codec stands for Coder/Decoder.
Basically it is a piece of software or a driver that adds a support for certain video/audio format for your operating system. With codec, your system recognizes the format the codec is built for and allows you to play the audio/video file (=decode) or in some cases, to change another audio/video file into that format (=(en)code).
Codec is a portmanteau of either "Compressor-Decompressor" or "Coder-Decoder," which describes a device or program capable of performing transformations on a data stream or signal. Codecs can both put the stream or signal into an encoded form (often for transmission, storage or encryption) and retrieve, or decode that form for viewing or manipulation in a format more appropriate for these operations. Codecs are often used in videoconferencing and streaming media solutions.
The raw encoded form of audio and video data is often called essence, to distinguish it from the metadata information that together make up the information content of the stream and any "wrapper" data that is then added to aid access to or improve the robustness of the stream.
Most codecs are lossy, in order to get a reasonably small file size. There are lossless codecs as well, but for most purposes the almost imperceptible increase in quality is not worth the considerable increase in data size. The main exception is if the data will undergo more processing in the future, in which case the repeated lossy encoding would damage the eventual quality too much.
Many multimedia data streams need to contain both audio and video data, and often some form of metadata that permits synchronization of the audio and video. Each of these three streams may be handled by different programs, processes, or hardware; but for the multimedia data stream to be useful in stored or transmitted form, they must be encapsulated together. This function is carried out by a video file format (or container), such as *.mpg, *.avi, *.mov, *.mp4, *.rm, *.ogg or *.tta. Some of these formats are limited to containing streams conforming to a small fixed set of codecs, while others are intended to be more general purpose.
An endec is a similar (but not identical) concept for hardware.