Check the structures you've learned directly with ffprobe, and sort out the limits of remuxing, which changes only the container without re-encoding.
The ffprobe output format can differ slightly between versions. Run it yourself in the same environment to check.
ffprobe -v trace input.mp4 2>&1 | grep -E "type:'(ftyp|moov|mdat)'"
# If moov appears before mdat, faststart has been applied to the file.
# If mdat comes first, moov is at the end of the file.If you compare the PTS and DTS columns in the packet list, you can see the reordering from the previous lesson with your own eyes. In a file with B-frames, PTS looks jumbled when read in DTS order, and in a file without them the two columns come out almost the same. You can do this on your own PC without uploading the file, and for simple information you can also use the File Info Inspector.
Remuxing means repackaging into a different container without touching the compressed streams. With no decoding or encoding, it is fast and loses no quality. In FFmpeg you do it with -c copy.
# Copy the video and audio streams as they are into an MP4 (SRT subtitles are converted to MP4 text subtitles)
ffmpeg -i input.mkv -map 0:v -map 0:a -map 0:s? -c copy -c:s mov_text output.mp4
# For web use, add faststart too
ffmpeg -i input.mkv -c copy -movflags +faststart output.mp4① Attachments in an MKV (such as fonts) and some tracks may not carry over to MP4. Even if you try to bring everything along with -map 0, you get an error if the target can't accept it. ② When you've remuxed HEVC from an MKV to an MP4 and it won't open on Apple devices, adding -tag:v hvc1 is widely known to fix it in some cases. ③ If the audio codec doesn't match the target container or device, it's better to re-encode only the audio (Audio container compatibility). ④ If the source's timestamps are irregular, they stay that way after remuxing and can show up as sync problems.
This site's MKV→MP4 Lossless Remux Checker reads a file's tracks, judges whether they can be moved with -c copy, and builds the command for you. The file is not uploaded to a server. If subtitles keep drifting, also see the Subtitle Sync Fixer, and the FFmpeg Command Builder helps you put commands together.
A container is a structure that records ① which tracks there are, ② where the samples are, and ③ when to show them. MP4 does this with boxes and the moov index, fMP4 with per-fragment indexes, MKV with EBML elements, and TS with 188-byte packets and PIDs, each in its own way. Changing only this structure while leaving the codec data alone is remuxing; if the codec data itself has to change, it is re-encoding.
Changing only the container while leaving the compressed streams as they are. In FFmpeg it is -c copy.
The FFmpeg mode (-c copy) that moves packets over as they are, without decoding or encoding. There is no quality loss.
A text subtitle format that can be held in an MP4. Used when converting SRT and similar formats to put them in.
The analysis tool that ships with FFmpeg. It prints container, stream, and packet information.
What is the right approach for moving H.264 video from an MKV into an MP4 with no quality loss?