If you only need a different container, do not re-encode. Stream copy moves the encoded audio and video packets from one container into another with no quality loss and finishes in seconds, even on a multi-gigabyte file.

The command

ffmpeg -i input.mp4 -c copy output.mkv

What it does

The -c copy flag tells FFmpeg to copy every stream byte-for-byte from the demuxer to the muxer. FFmpeg only re-packs the container: timestamps, codec private data, and the actual compressed frames are untouched. The output is mathematically identical to the input streams, so quality cannot degrade.

When to use it

Use it when the source and target containers support the same codecs and you only need a feature one container has. Common reasons: MKV supports multiple audio tracks, soft subtitles, and chapter markers in one file, which MP4 handles poorly. Remuxing is also useful for fixing a corrupt container without re-encoding the streams inside.

Requirements

Every codec in the source must be supported by the target container. MP4 typically holds H.264/H.265 and AAC; MKV accepts both plus many more. If the source has a codec MKV rejects, FFmpeg will error rather than silently drop the stream.

Things to avoid

  • Expecting this to fix playback issues caused by a bad encode. The streams are unchanged, so a bad encode is still a bad encode.
  • Assuming timestamps survive cleanly. Some players struggle with very high-resolution MKV timestamps. Add -fflags +genpts if you see glitches.
  • Using -c copy when the source and target codecs differ. FFmpeg will error, but a confused intermediate script might silently produce a broken file.
  • Forgetting that DRM, if present, is preserved by the copy. Re-encoding strips DRM, remuxing does not.