Video files are made of 2 parts: a codec and a container.
A video codec is a protocol for encoding and decoding video (the word codec comes from “enCOde / DECode”). Common codecs include H.264, MPEG-4, and DivX. A well-engineered codec has high efficiency, or ability to preserve quality while reducing file size.
The container format is a definition of how the file metadata and data are structured, excluding how the video is actually encoded (which the codec determines). The container file holds the metadata and compressed video data which is encoded using the codec. The container format is also more generally called “the format”, and is reflected in the file’s extension. Common container formats include .AVI, .MP4, and .MOV. Container formats can be paired with different codecs that influence what devices and programs the file will be compatible with.