A codec defines how audio or video is encoded and decoded. A player needs an appropriate decoder to turn the compressed information into pictures or sound. Codec support can depend on the software, hardware, profile and other stream properties; recognising a filename or opening a container does not establish complete decoding compatibility.

A practical example
A television may open a media file and play its audio while leaving the picture black because the video encoding is unsupported. The file container, video codec and audio codec need to be considered separately when diagnosing that result.
A common misunderstanding
Codec names alone can be incomplete compatibility descriptions. Profiles, bit depth, resolution and other encoding details can matter even when the device lists support for the broad codec family.
Related terms
Further reading
Stable technical definition. Editorial approach