Convert MPG to MKV — Free Online Tool
Convert MPG files to MKV by re-encoding the legacy MPEG-1/2 video stream with the modern H.264 codec and wrapping everything in Matroska's flexible, open-standard container. This is ideal for modernizing old VCD, DVD-rip, or broadcast footage into a format that supports subtitles, multiple audio tracks, and far better compression efficiency.
to
FFmpeg Command
Copy this command to run the same conversion locally with FFmpeg on your desktop. Download FFmpeg
Drop your MPG file here
or click to browse
Free — no uploads, no signups. Your files never leave your browser.
Settings
Note: Browser-based encoding uses approximate quality targets. For precise CRF compression, copy the FFmpeg command above and run it on your desktop.
Estimated output:
Conversion Complete!
DownloadHow It Works
MPG files store video encoded with MPEG-1 or MPEG-2 and audio typically encoded as MP2 — formats from the 1990s designed for VCDs, DVDs, and broadcast pipelines. Because MKV's default video codec is H.264 (libx264) rather than MPEG-2, the video stream must be fully re-encoded — this is not a simple remux. FFmpeg decodes each MPEG-2 frame and re-encodes it using the H.264 encoder at CRF 23, a perceptually transparent quality level for most content. The MP2 audio is simultaneously transcoded to AAC at 128k, which is broadly compatible and more efficient than MP2 at equivalent bitrates. The result is an MKV file that is typically significantly smaller than the source MPG while unlocking Matroska features like subtitle track support, chapter markers, and multiple audio streams that the MPG container cannot carry.
What Each Flag Does
| Flag | What it does |
|---|---|
ffmpeg
|
Invokes the FFmpeg tool, which handles all decoding, re-encoding, and container muxing for this conversion. This command runs directly in your browser via FFmpeg.wasm and can also be run identically on your desktop FFmpeg installation. |
-i input.mpg
|
Specifies the source MPG file. FFmpeg will automatically detect whether it is an MPEG-1 or MPEG-2 program stream and select the appropriate decoder (mpeg1video or mpeg2video) along with the MP2 or AAC audio decoder for the contained audio stream. |
-c:v libx264
|
Instructs FFmpeg to re-encode the MPEG-2 (or MPEG-1) video stream using the H.264 encoder. This is a full transcoding step — every frame is decoded from MPEG-2 and re-compressed with H.264's far superior inter-frame prediction and entropy coding, resulting in smaller files at equivalent visual quality. |
-c:a aac
|
Transcodes the MPG's MP2 audio track to AAC, the default audio codec for MKV output. AAC achieves better audio quality than MP2 at the same bitrate and is natively supported by virtually all modern playback devices and software. |
-crf 23
|
Sets the Constant Rate Factor for the H.264 encoder to 23, which is the libx264 default and produces visually transparent quality for most standard-definition MPEG-2 broadcast or DVD source material. Lower values (e.g., 18) produce larger files with higher fidelity; higher values (e.g., 28) produce smaller files with more compression. |
-b:a 128k
|
Sets the AAC audio bitrate to 128 kilobits per second. This is a well-established threshold for perceptually transparent stereo audio with AAC and is appropriate for the voice and music content typically found in MPG broadcast or DVD recordings. Increase to 192k if the source MP2 audio was encoded at a high bitrate and audio fidelity is a priority. |
output.mkv
|
Specifies the output file. The .mkv extension tells FFmpeg to use the Matroska container muxer, which wraps the newly encoded H.264 video and AAC audio streams into a single flexible MKV file with full support for subtitles, chapters, and metadata that the source MPG format could not carry. |
Common Use Cases
- Archiving old VCD rips or DVD recordings stored as MPG files into a modern, smaller format without visible quality loss for long-term storage.
- Preparing legacy broadcast or television capture files (MPG from capture cards) for playback in modern media players like VLC or Plex, which handle MKV/H.264 natively and efficiently.
- Adding subtitle tracks to a converted video — MPG cannot carry subtitle streams at all, but the resulting MKV can hold SRT, ASS, or PGS subtitles alongside the video.
- Reducing the file size of large MPEG-2 encoded MPG recordings before uploading to a video platform or sharing over the internet, since H.264 typically achieves similar quality at half the bitrate of MPEG-2.
- Converting MPG footage from older camcorders or DVD authoring tools into MKV so it can be imported into video editing software that struggles with MPEG-2 program streams.
- Consolidating a multi-episode DVD rip stored as separate MPG files into MKV containers where chapter markers can be embedded for easier navigation.
Frequently Asked Questions
Because MPEG-2 in MPG is already a lossy format, converting to H.264 involves a generation of re-encoding loss — you cannot recover detail that was already discarded. However, using the default CRF 23 setting with libx264 produces visually transparent results for the vast majority of standard-definition and interlaced broadcast content typically found in MPG files. If you are archiving original source material and quality is critical, consider lowering the CRF value to 18 or below for higher fidelity at the cost of a larger file.
H.264 (libx264) is a dramatically more efficient codec than MPEG-2. For equivalent perceptual quality, H.264 typically requires roughly half the bitrate of MPEG-2, which was designed in the early 1990s before modern compression techniques existed. The audio change from MP2 to AAC also contributes modest additional savings. The MKV container itself adds negligible overhead, so nearly all size reduction comes from the superior compression of H.264 and AAC.
By default, this conversion passes the interlaced MPEG-2 frames through to the H.264 encoder, which can encode interlaced content. However, if you plan to play the file on modern displays or streaming platforms, you may want to add a deinterlace filter (such as -vf yadif) to the FFmpeg command to produce progressive output. Interlaced H.264 in MKV can cause combing artifacts on progressive screens and may not be supported well by all players.
MPG (MPEG program streams) carry very limited metadata compared to modern containers — typically just basic stream timing and system headers. FFmpeg will transfer whatever metadata exists, but do not expect rich tag preservation since MPG simply does not store title, artist, or chapter data. The MKV container is fully capable of holding extensive metadata, so you can add tags and chapter markers to the output after conversion.
The -crf flag controls H.264 quality on a scale from 0 (lossless) to 51 (worst). Lower values produce higher quality and larger files. The default of 23 is a good general-purpose starting point for MPEG-2 source content. For archival-quality output from a DVD source, use -crf 18. For a smaller file where some additional quality loss is acceptable — such as web streaming — try -crf 28. You can also change -b:a 128k to a higher value like -b:a 192k if the original MPG had high-quality MP2 audio worth preserving more faithfully.
Yes. On Linux or macOS, you can run a shell loop: for f in *.mpg; do ffmpeg -i "$f" -c:v libx264 -c:a aac -crf 23 -b:a 128k "${f%.mpg}.mkv"; done. On Windows Command Prompt, use: for %f in (*.mpg) do ffmpeg -i "%f" -c:v libx264 -c:a aac -crf 23 -b:a 128k "%~nf.mkv". This is especially useful for converting an entire DVD rip or archive of MPG recordings in one operation. The in-browser tool processes files individually, so the FFmpeg command shown on this page is the practical solution for batch jobs.
Technical Notes
MPG (MPEG program stream or MPEG transport stream) is a rigid, broadcast-oriented container with almost no extensibility — it cannot carry subtitles natively, has no chapter support, and is limited to a single video and audio stream in most implementations. The MPEG-2 video codec it uses, while still technically valid, is inefficient by modern standards and widely considered a legacy format. Converting to MKV with H.264 addresses all of these limitations: Matroska is an open, extensible container that can hold arbitrary numbers of video, audio, subtitle, and attachment tracks, plus full chapter and metadata support. The libx264 encoder used here is a highly mature, well-optimized H.264 implementation with excellent quality-per-bit characteristics. One important caveat for MPG sources: MPEG-2 program streams sometimes contain slight timing irregularities or non-standard stream multiplexing from older authoring tools, which can cause FFmpeg to emit warnings during processing — these are generally harmless and the output will play correctly. If your MPG originates from a VCD source encoded with MPEG-1 rather than MPEG-2, FFmpeg detects and handles this automatically; the same command applies. AAC audio at 128k is perceptually comparable to MP2 at 192k for typical voice and music content found in broadcast MPG recordings.