What is a codec? What is a format?
A codec is a compression standard. Raw video or audio is compressed when encoding, and decompressed (decoded) on playback. MP3 is an audio codec – a compression standard that MP3 players know how to decode, and MP3 encoders know how to encode. There are hundreds of codecs out there; some of the more important ones are H.264, HEVC, MPEG-2, Theora, VP8, VP9, JPEG2000, DivX, XviD, and the WMV family (video) and MP3, AAC, Vorbis, and the WMA family (audio).
A format is a file container that holds one or more codecs – video, audio, or even data. The container format contains information about the video, audio, and data tracks that it holds. Some example container formats are mov (Quicktime), mp4, ogg, and avi.