An .mp4 file doesn't tell you which codec it uses. Learn how containers (MP4, MKV, WebM) differ from codecs (H.264, HEVC, AV1), and how to check with ffprobe.
This is the most common point of confusion for people learning codecs. Before the question "What codec is this mp4 file?" even makes sense, you have to know that mp4 is not a codec.
A codec (what you learned in Chapters 5-9) is the algorithm that actually compresses video and audio. A container is the "envelope," or file format, that holds the compressed data (plus subtitles, metadata, chapters, and so on). mp4 is only an envelope. Inside it you might find H.264, HEVC, or AV1. Audio codecs such as AAC and Opus for the audio track are covered in Chapter 12, and the inner structure of MP4 in Chapter 16.
"The file won't open" can have two completely different causes. ① The container can't be read (the parser doesn't understand the file structure at all). ② The container can be read, but the codec inside can't be decoded (there is no hardware or software decoder for one of the codecs from Chapters 5-9). The diagnosis is completely different for each, so codec engineers always use ffprobe to check the container and the codec separately.
ffprobe -v error -show_entries \
stream=codec_name,codec_type,width,height,pix_fmt \
-of default=noprint_wrappers=1 input.mp4
# Example output:
# codec_type=video
# codec_name=hevc ← the codec
# width=3840
# height=2160
# pix_fmt=yuv420p10le ← chroma format + bit depth from Chapter 1A file format that bundles compressed media and metadata. A separate concept from the codec.
The international standard container structure that MP4 and others are built on.
An individual stream inside a container (video, audio, subtitles, and so on).
When an mp4 file won't play, which two causes must you tell apart?