Convert MPG to MP4 for Free: FFmpeg, HandBrake, VLC

Why MPG to MP4 Means a Re-Encode, Not a Rename · Prerequisites and Versions Checked · Which Tool Fits: FFmpeg, HandBrake, VLC or an Online Converter · Steps 1 to 4: Convert MPG to MP4 With FFmpeg · Steps 5 and 6: Deinterlace and Fix the Aspect Ratio · Steps 7 and 8: Audio, Sync and Multi-File DVD Recordings · Render Settings by Source Type · Steps 9 and 10: HandBrake Settings for MPG Files · Step 11: Convert With VLC or an Online Converter · Step 12: A Complete Project to Batch Convert a Folder of MPG Files · Quality Check Before You Delete the Originals · Common Pitfalls With Old MPG Files · Troubleshooting Failed MPG Conversions · Advanced Tips for Cleaner Output From Old Files · Common questions
To convert MPG to MP4, run one FFmpeg command that re-encodes the old MPEG-1 or MPEG-2 video into H.264 and the audio into AAC. You cannot rename the file or copy the streams across, which is why the quick fix that works for an MKV file usually fails here. This tutorial covers the FFmpeg route first, then HandBrake and VLC, and ends with a batch script that converts a whole folder and checks every result.
The settings target the usual MPG sources: DVD recordings, old camcorder clips, TV captures and VCD-era downloads. Most of them are interlaced and anamorphic, so a naive convert leaves combing lines or a squashed picture. HandBrake’s own documentation tells you to tick the Web Optimized checkbox for MP4 files meant for the web, and its Web Optimised page explains what that option does. Every version number and price below was checked against the vendors’ own pages on November 30, 2026.
Why MPG to MP4 Means a Re-Encode, Not a Rename
An .mpg or .mpeg file is a container, usually an MPEG program stream. Inside it you will find MPEG-1 or MPEG-2 video and audio in MP2, AC-3 or sometimes uncompressed PCM. DVD recordings, many standalone DVD recorders, older camcorders and TV tuner captures all write this layout. The video codec is the old part. MPEG-2 compresses far less efficiently than H.264, which is why a clip that fills gigabytes as MPEG-2 shrinks a great deal when it is re-encoded.
MP4 is a different kind of container. It is built around H.264, H.265 or AV1 video with AAC audio, and that is the combination browsers, phones, smart TVs and every social upload form accept without complaint. If you want the full picture of the format, the explainer on what an MP4 video file is covers the container side. For this job, the key point is simple: the container changes from program stream to MP4, and the codecs change from MPEG-2 and MP2 to H.264 and AAC.
Could you stream-copy the MPEG-2 video into an MP4 shell and skip the re-encode? The MP4 specification allows it, and FFmpeg will often write the file without an error. The result then plays in a few desktop players and fails in browsers, on iPhones and on most TVs. A file that only plays on your own machine is not a finished conversion, so this guide always re-encodes the video. The audio gets the same treatment, because AC-3 inside MP4 has patchy support and AAC works everywhere.
One cost comes with any re-encode. Lossy compression applied to lossy compression stacks artifacts, so every pass loses a little detail. You control how much with the CRF value (constant rate factor) in x264. A CRF between 18 and 20 keeps the loss invisible on standard-definition sources for almost every viewer. Keep your original .mpg after converting. Disk space is cheap, and a second encode from the original beats a re-encode of an MP4.
Two traits of MPG sources trip people up more than anything else. First, interlacing: DVD and camcorder video is often stored as alternating half-height fields, and playing it on a progressive screen shows comb teeth on every moving edge. Second, non-square pixels: a 720×480 DVD frame is stretched to 16:9 or 4:3 at playback through a sample aspect ratio flag, and a converter that drops the flag gives you a squashed picture. Both problems have clean fixes, covered in the deinterlacing section.
Prerequisites and Versions Checked
You need one converter, free disk space roughly equal to your source files and the source files on a local drive. All three tools below cost $0. The table lists the versions this tutorial is written against, with the release date where the vendor states one.

| Item | Version checked (Nov 30, 2026) | Price | Notes |
|---|---|---|---|
| FFmpeg | 9.1 “Gauss”, released November 20, 2026 | $0 | Command-line tool. The project’s own site offers source code, so most people install a prebuilt package. |
| HandBrake | 1.11.2 | $0 | GUI plus the separate HandBrakeCLI. Windows needs Microsoft .NET Desktop Runtime 10.0. macOS 10.13 or later. |
| VLC media player | 3.0.24 (Windows 64-bit installer, 44 MB) | $0 | Player with a Convert / Save wizard. No account, no paid tier. |
| Shell | bash or zsh, or PowerShell 5.1 or newer | $0 | Needed only for the batch project near the end. |
| Disk space | About the size of the source file, plus headroom | n/a | H.264 output is usually smaller than the MPEG-2 original. |
FFmpeg 9.1 “Gauss” is the newest named release on the project’s news page, dated November 20, 2026. It follows FFmpeg 8.1 “Hoare”, which is no longer the newest release. Nothing in this tutorial needs a 9.1-only feature, so any FFmpeg from the 7.x line onward runs every command shown. The one filter you want present is bwdif, and it has shipped in builds for years.
HandBrake 1.11.2 is the newest release listed on the HandBrake news page. Its release notes say it fixed a crash in two-pass lossless x265 encoding and updated the bundled FFmpeg to 8.0.2 and SVT-AV1 to 4.1.0. That matters for this job because HandBrake decodes MPEG-2 through the same FFmpeg library family, so the decode quality matches the command-line route. HandBrake has no account, no paid edition and no watermark.
Before you start, copy a few representative source files into one working folder. Pick one clip per source type you own: a DVD recording, a camcorder file, an old download. Test settings on a 30-second slice of each before you commit a long overnight batch. The trim option -t 30 in FFmpeg makes that easy, and the project near the end of this guide supports it.
Which Tool Fits: FFmpeg, HandBrake, VLC or an Online Converter
Pick FFmpeg if you have more than a handful of files or want repeatable settings. Pick HandBrake if you prefer a window with sliders and a preview. Use VLC only when it is already installed and you have one clip to convert. Use an online converter for a single short, non-sensitive clip on a machine where you cannot install anything. The table compares the four on the points that matter for MPG sources.
| Tool | Cost | Deinterlacing | Quality control | Batch work | Best for |
|---|---|---|---|---|---|
| FFmpeg | $0 | bwdif, yadif, inverse telecine | CRF, presets, two-pass | Scripts and loops | Folders of files, exact control |
| HandBrake 1.11.2 | $0 | Comb detection, decomb, yadif, bwdif | RF slider, presets | Built-in queue | Visual preview, DVD-style sources |
| VLC 3.0.24 | $0 | Checkbox in the profile editor | Bitrate only, no CRF | One file at a time | Quick one-off clip |
| Online converters | Free tiers, limits vary | Rarely offered | Size or quality presets | Usually capped | Single short clips, no install |
On the search results page for this exact query on November 30, 2026, the first results were converter sites such as CloudConvert, FreeConvert and Convertio. They work for small files. Their free tiers differ in upload size, daily conversions and queue priority, and those limits change often, so read the current limits on the site before you upload anything. You also hand your file to a third party, which rules them out for family footage you consider private.
The same decision tree applies to any legacy format. If your footage came from a Mac instead, the walkthrough on how to convert MOV to MP4 covers the remux-first logic that does not apply to MPG. For MPG, the encoder always runs, so the two settings that matter are the quality target and the deinterlacing choice.
Steps 1 to 4: Convert MPG to MP4 With FFmpeg
Step 1: Inspect the source with ffprobe. Before you encode, find out what the file holds. The command below prints codec, frame size, field order, frame rate and aspect ratio for every stream. Run it on each source type you own, because a DVD recording and a camcorder clip need different settings.
ffprobe -v error -show_entries stream=index,codec_type,codec_name,width,height,field_order,r_frame_rate,sample_aspect_ratio,display_aspect_ratio -of default=nw=1 holiday.mpg
A typical readout for an NTSC DVD recording looks like the block below. The numbers will differ for your file, but the shape is the same. Look at three lines: codec_name tells you the codec, field_order=tt means top-field-first interlaced video, and the sample aspect ratio of 32:27 means the 720×480 frame is displayed as 16:9.
index=0
codec_type=video
codec_name=mpeg2video
width=720
height=480
field_order=tt
r_frame_rate=30000/1001
sample_aspect_ratio=32:27
display_aspect_ratio=16:9
index=1
codec_type=audio
codec_name=ac3
Step 2: Install FFmpeg and confirm the version. Use your system’s package manager. Distribution repositories often trail the newest release, which is fine here, because every flag in this tutorial is old and stable. After installing, check that the build includes the x264 encoder. A build without it cannot write H.264 and you will see an unknown encoder error in step 3.
# Windows (PowerShell)
winget install Gyan.FFmpeg
# macOS (Homebrew)
brew install ffmpeg
# Debian / Ubuntu
sudo apt install ffmpeg
# Check the version and the x264 encoder
ffmpeg -version
ffmpeg -hide_banner -encoders | grep libx264
The first line of ffmpeg -version should read ffmpeg version followed by a number. The encoder search should print one line that starts with V....D libx264. FFmpeg ships under the LGPL or the GPL depending on how a build is configured, and x264 support needs a GPL build. Mainstream package-manager builds include it. If the search prints nothing, install a different build before you continue.
Step 3: Run the base conversion. This is the command most people searching for mpg to mp4 need. It re-encodes the video to H.264 at CRF 19, converts the audio to stereo AAC at 192 kb/s and moves the index to the front of the file so the MP4 starts playing before it fully downloads.
ffmpeg -i holiday.mpg -c:v libx264 -crf 19 -preset slow -pix_fmt yuv420p -c:a aac -b:a 192k -movflags +faststart holiday.mp4
Each flag has a job. -c:v libx264 picks the H.264 encoder. -crf 19 sets the quality target, where lower numbers mean higher quality and bigger files. -preset slow trades encode time for compression efficiency, and you can drop to medium when time matters more than size. -pix_fmt yuv420p forces the 4:2:0 color layout that every player decodes. -movflags +faststart relocates the MP4 index for web playback, the same job HandBrake’s Web Optimized checkbox does.
FFmpeg selects the best video stream and the best audio stream on its own when you give it one input and one output. That default is right for most MPG files. When a file carries several audio tracks, add -map 0:v:0 -map 0:a to keep them all, or -map 0:a:1 to pick the second one. The batch project later in this guide uses an optional mapping so a clip with no audio does not abort the run.
Step 4: Verify the output. A finished file is not a verified file. Probe the result and compare the duration with the source. A gap of more than about a second points to dropped packets or broken timestamps, which the audio and sync section below explains how to fix.
ffprobe -v error -show_entries format=duration:stream=codec_name,width,height,r_frame_rate -of default=nw=1 holiday.mp4
ffprobe -v error -show_entries format=duration -of csv=p=0 holiday.mpg
Then play the MP4 in a browser or on your phone, not only in the tool you converted with. Scrub to the middle and the last minute, since sync drift grows with time. If the picture shows comb lines on fast motion or the people look too wide or too thin, move on to the next section before you encode the rest of the folder.
Steps 5 and 6: Deinterlace and Fix the Aspect Ratio
Step 5: Find out whether the footage is interlaced. The field_order value from ffprobe is a hint, not proof. Some files claim to be interlaced and are not, and some film transfers hide interlaced frames. The idet filter counts how many frames look interlaced across a sample. Run it over the first 500 frames, which takes a few seconds.

ffmpeg -hide_banner -i holiday.mpg -vf idet -frames:v 500 -an -f null -
Read the last summary line that starts with Multi frame detection. It looks like TFF: 412 BFF: 0 Progressive: 61 Undetermined: 27. When TFF or BFF dwarfs Progressive, the footage is interlaced and you should deinterlace. When Progressive dominates, leave the filter off, because deinterlacing clean progressive video only softens it.
Interlaced camcorder and DVD footage
The deinterlacer used in this tutorial is bwdif. Its mode option controls whether the output keeps the original frame rate or doubles it, so check the filter documentation for the exact values before you choose.
# Same frame rate, one frame per frame pair
ffmpeg -i holiday.mpg -vf "bwdif=mode=send_frame:parity=auto:deint=interlaced" -c:v libx264 -crf 19 -preset slow -pix_fmt yuv420p -c:a aac -b:a 192k -movflags +faststart holiday.mp4
# Double frame rate for smoother motion (sports, fast pans)
ffmpeg -i holiday.mpg -vf "bwdif=mode=send_field:parity=auto:deint=interlaced" -c:v libx264 -crf 19 -preset slow -pix_fmt yuv420p -c:a aac -b:a 192k -movflags +faststart holiday_60.mp4
The option deint=interlaced tells the filter to touch only frames flagged as interlaced and to pass progressive frames through untouched. That protects mixed footage, where a camcorder switches modes mid-clip. If your FFmpeg build lacks bwdif for some reason, swap the filter name for yadif and keep the same options.
Anamorphic widescreen and square pixels
Step 6: Check the aspect ratio on a second player. libx264 preserves the sample aspect ratio flag, so most MP4s from the base command already display at the right shape. A few players and web editors ignore the flag and show the raw 720×480 grid, which looks squeezed when the source was 16:9. If you see that, bake the correct shape into the pixels. The filter below scales the width by the sample aspect ratio and resets it to 1, so a 16:9 NTSC DVD frame becomes roughly 852×480.
ffmpeg -i holiday.mpg -vf "bwdif=mode=send_frame:parity=auto:deint=interlaced,scale=trunc(iw*sar/2)*2:ih,setsar=1" -c:v libx264 -crf 19 -preset slow -pix_fmt yuv420p -c:a aac -b:a 192k -movflags +faststart holiday_square.mp4
Filter order matters. Deinterlace first, then scale. Scaling interlaced fields before deinterlacing blends the two fields together and wrecks the result. The trunc(.../2)*2 expression keeps the width even, which H.264 with 4:2:0 color requires.
Film transferred to DVD (with pulldown)
Movies on DVDs are sometimes stored with repeated fields, a process called telecine. Deinterlacing such a file works but can leave duplicate frames and a faint judder. Inverse telecine aims to restore the original film frames. Use it only when idet or HandBrake’s detection shows a repeating pattern, and test on a short slice first.
ffmpeg -i film_dvd.mpg -vf "fieldmatch,yadif=deint=interlaced,decimate" -c:v libx264 -crf 19 -preset slow -pix_fmt yuv420p -c:a aac -b:a 192k -movflags +faststart film.mp4
Steps 7 and 8: Audio, Sync and Multi-File DVD Recordings
Step 7: Choose the audio path. MPG audio arrives as MP2 (common on TV captures and camcorders), AC-3 (common on DVDs) or PCM. All three convert to AAC without trouble. The default in the base command, stereo AAC, suits almost every use. If the source is AC-3 with five or more channels and you want to keep surround, raise the bitrate and drop the stereo downmix. Otherwise, add -ac 2 so a surround track folds down to stereo and dialogue stays audible on laptop speakers.
# Stereo downmix (safest for web and phones)
ffmpeg -i in.mpg -c:v libx264 -crf 19 -preset slow -pix_fmt yuv420p -c:a aac -b:a 192k -ac 2 -movflags +faststart out.mp4
# Keep 5.1 surround
ffmpeg -i in.mpg -c:v libx264 -crf 19 -preset slow -pix_fmt yuv420p -c:a aac -b:a 384k -movflags +faststart out_51.mp4
You can copy AC-3 into MP4 with -c:a copy, and FFmpeg will write it. Do not. Browsers and many phones refuse AC-3 in MP4, so you would trade a small encode step for a file that plays silently on half your devices. AAC avoids the problem. Clips shot on phones in recent years already carry H.264 and AAC, so they usually need a remux at most. The guide to converting iPhone video to MP4 shows which of those files skip the encoder, a handy way to sort a mixed archive.
Program streams recorded from TV or by hardware recorders sometimes carry broken or missing timestamps, which causes two symptoms: audio that drifts out of sync as the clip plays, and a duration that is wrong in the output. Two flags fix most cases. -fflags +genpts asks FFmpeg to regenerate presentation timestamps on input, and -fps_mode cfr forces a constant output frame rate by duplicating or dropping frames as needed. Put -fflags +genpts before the -i because it is an input option.
ffmpeg -fflags +genpts -i tv_capture.mpg -fps_mode cfr -af aresample=async=1 -c:v libx264 -crf 19 -preset slow -pix_fmt yuv420p -c:a aac -b:a 192k -movflags +faststart tv_capture.mp4
The aresample=async=1 filter stretches or trims the audio gently to track the video clock. Add it when the sync problem is a slow drift. If the audio is simply offset by a fixed amount from the first frame, shift it with -itsoffset on a second input of the same file instead.
Step 8: Join split recordings. A DVD recording that you copied from your own unprotected disc, or from a DVD recorder, is often split into several VOB files named like VTS_01_1.VOB, VTS_01_2.VOB and so on. The concat protocol reads them as one continuous stream, so you get a single MP4 with no seams. List the files in order and separate them with a pipe. Skip VTS_01_0.VOB, which holds menus. This guide covers files you own the rights to. Commercially protected discs are encrypted, and breaking that protection is restricted by law in many countries.
ffmpeg -i "concat:VTS_01_1.VOB|VTS_01_2.VOB|VTS_01_3.VOB" -vf "bwdif=mode=send_frame:parity=auto:deint=interlaced" -c:v libx264 -crf 19 -preset slow -pix_fmt yuv420p -c:a aac -b:a 192k -movflags +faststart dvd_recording.mp4
The concat protocol works at the byte level, so it suits program streams like VOB and MPG, where joining bytes is safe. It does not suit MP4 or MKV inputs, which need the concat demuxer with a list file instead. If your recording has several separate .mpg files from one session, the same pipe syntax joins them.
Render Settings by Source Type
The table gives starting values for the usual MPG sources. Frame sizes and rates are the standard formats for each source. The CRF and audio columns are suggested starting points rather than vendor limits. Adjust CRF up by 1 or 2 if file size matters more than the last bit of detail, and down by 1 or 2 if you plan to edit the MP4 further.
| Source | Frame size | Frame rate | Deinterlace | x264 CRF | Audio |
|---|---|---|---|---|---|
| NTSC DVD recording | 720×480 | NTSC video rate, or the film rate if film | bwdif send_frame, or inverse telecine for film | 18 to 20 | AAC 192 kb/s stereo |
| PAL DVD recording | 720×576 | 25 | bwdif send_frame | 18 to 20 | AAC 192 kb/s stereo |
| MPEG-1 clip (VCD-era download) | 352×240 NTSC, 352×288 PAL | NTSC rate or 25, progressive | None | 20 to 22 | AAC 128 kb/s |
| Standard-definition camcorder MPEG-2 | 720×480 or 720×576 | NTSC rate or 25, interlaced | bwdif send_frame | 19 | AAC 192 kb/s |
| HD camcorder MPEG-2 | 1440×1080 or 1920×1080 | 25, interlaced | bwdif send_frame | 19 to 20 | AAC 192 kb/s |
| VHS or analog capture | 720×480 or 720×576 | Not listed | bwdif plus light denoise | 17 to 18 | AAC 192 kb/s |
Resist the urge to upscale. A 352×240 VCD clip scaled to 1080p is still a 352×240 clip, only blurrier and far heavier. Keep the native frame size and let the player or the platform scale it. If you must hit a specific platform size, scale once at the end of the chain with scale=-2:720:flags=lanczos and nothing else.
Preset choice is the second dial. Presets in x264 run from ultrafast to veryslow. Slower presets squeeze the same quality into a smaller file, with diminishing returns past slow. For standard-definition sources, even slow usually runs quickly on a modern desktop CPU, so there is little reason to drop to fast unless you are converting hours of footage on a laptop.
Steps 9 and 10: HandBrake Settings for MPG Files
Step 9: Convert in the HandBrake window. HandBrake 1.11.2 handles MPG files directly and gives you a preview, which makes it the friendliest route for DVD-style footage. Download it from the HandBrake site and, on Windows, install the Microsoft .NET Desktop Runtime 10.0 that the installer asks for. The project describes itself as a small team of volunteers and presents its own website as the place to download releases, so avoid mirrors that bundle extras.

- Open HandBrake and drag your .mpg file onto the window, or choose Open Source and pick the file.
- In the Presets panel, choose Fast 480p30 for an NTSC source or Fast 576p25 for a PAL one. For HD camcorder files, choose a 1080p preset instead.
- In the Summary tab, set Format to MP4 and tick Web Optimized.
- Open the Dimensions tab and leave Anamorphic on its automatic setting, so the display shape follows the source.
- Open the Filters tab. Set Interlace Detection to Default and Deinterlace to Decomb, which touches only frames that show combing.
- Open the Video tab. Keep the encoder at H.264 (x264) and set Constant Quality to RF 20 for a standard-definition source.
- Open the Audio tab. Choose AAC as the codec, Stereo as the mixdown and 160 kb/s as the bitrate.
- Use Browse to name the output, ending in .mp4, then click Start Encode.
The RF slider works like FFmpeg’s CRF, with lower numbers giving higher quality. RF 20 is a sensible start for standard-definition video, and 18 suits footage you plan to edit. The Decomb filter is HandBrake’s version of the deinterlace-only-when-needed behavior, and it is the right default for MPG files that mix progressive and interlaced sections. If you see leftover combing in the preview, switch Deinterlace to Yadif or Bwdif.
To convert several files, load each one, set its options, then use Add to Queue instead of Start Encode. HandBrake runs the queue in order and keeps going if you walk away. Save your settings as a custom preset once they look right, so the next batch takes one click per file.
Step 10: Script HandBrake from the command line. HandBrakeCLI ships as a separate download from the GUI. The command below mirrors the GUI settings from step 9, and it fits into a shell loop when you want HandBrake’s decomb logic across a folder.
HandBrakeCLI -i holiday.mpg -o holiday.mp4 -f av_mp4 -e x264 -q 20 --decomb -E av_aac -B 160 --mixdown stereo --optimize
Here -f av_mp4 picks the MP4 container, -q 20 sets RF 20, --decomb turns on the decomb filter, -E av_aac -B 160 encodes AAC at 160 kb/s and --optimize is the command-line twin of the Web Optimized checkbox. Run HandBrakeCLI --help if a flag name differs in your build, since the CLI’s own help is the authority for your installed version.
Step 11: Convert With VLC or an Online Converter
Step 11: Use VLC for a one-off clip. VLC is a player first, but its Convert / Save wizard writes MP4 files. The Windows 64-bit installer for 3.0.24 is 44 MB on VideoLAN’s download page, and VLC is free with no paid tier. The wizard gives you less control than FFmpeg or HandBrake. It has no CRF mode, so quality depends on a bitrate you set by hand.
- Open VLC and choose Media, then Convert / Save (or press Ctrl+R).
- On the File tab, click Add and choose your .mpg file, then click Convert / Save.
- In the Profile list, choose Video – H.264 + MP3 (MP4).
- Click the wrench icon next to the profile to edit it. On the Audio codec tab, change the codec to MPEG 4 Audio (AAC). On the Video codec tab, raise the bitrate well above the stock default and open Filters to tick Deinterlace if the source is interlaced. Save the profile.
- Click Browse, type a destination file name that ends in .mp4 and click Start.
VLC shows no progress window. The seek bar fills as the conversion runs, and the clip is done when it reaches the end. If the destination name lacks the .mp4 extension, VLC may write a file with no usable container, so check the name before you start. For anything beyond a quick clip, switch to HandBrake or FFmpeg and gain a quality knob that VLC lacks.
Online converters. The workflow is the same on every site: upload the .mpg, choose MP4 as the target, pick a quality or size option and download the result. Check four things before you use one. First, the upload size limit and the daily conversion count on the free tier. Second, whether the site deletes your file after conversion and how soon. Third, whether it adds a watermark or slows free users to a queue. Fourth, whether it offers any deinterlacing, since most do not and will hand back combing on interlaced footage. A browser-local converter that never uploads your file avoids the privacy problem, though your own CPU then sets the speed.
Step 12: A Complete Project to Batch Convert a Folder of MPG Files
This project turns the earlier steps into one script. For every .mpg, .mpeg and .vob file in a folder, it samples 400 frames with idet, deinterlaces only if the sample is mostly interlaced, encodes H.264 and AAC with the faststart flag, then compares the output duration with the source and writes a row to a CSV log. Set SQUARE=1 to bake square pixels into the output and TRIM=30 to encode only the first 30 seconds as a test.
#!/usr/bin/env bash
# mpg2mp4.sh - batch convert MPG, MPEG and VOB files to MP4
# usage: ./mpg2mp4.sh [source_dir] [output_dir]
# env: CRF=19 PRESET=slow SQUARE=0 TRIM=0
SRC="${1:-.}"
OUT="${2:-./mp4_out}"
CRF="${CRF:-19}"
PRESET="${PRESET:-slow}"
SQUARE="${SQUARE:-0}"
TRIM="${TRIM:-0}"
mkdir -p "$OUT"
TMP="$(mktemp)"
LOG="$OUT/conversion_log.csv"
echo "file,tff,bff,progressive,deinterlaced,src_seconds,out_seconds,status" > "$LOG"
for f in "$SRC"/*.[mM][pP][gG] "$SRC"/*.[mM][pP][eE][gG] "$SRC"/*.[vV][oO][bB]
do
if [ ! -f "$f" ]; then continue; fi
name="$(basename "$f")"
base="${name%.*}"
out="$OUT/$base.mp4"
# 1. sample the first 400 frames and count interlaced vs progressive
ffmpeg -hide_banner -nostdin -nostats -i "$f" -vf idet -frames:v 400 -an -f null - 2> "$TMP"
line="$(grep 'Multi frame detection' "$TMP" | tail -n 1)"
tff="$(echo "$line" | sed -n 's/.*TFF: *\([0-9][0-9]*\).*/\1/p')"
bff="$(echo "$line" | sed -n 's/.*BFF: *\([0-9][0-9]*\).*/\1/p')"
prog="$(echo "$line" | sed -n 's/.*Progressive: *\([0-9][0-9]*\).*/\1/p')"
tff="${tff:-0}"
bff="${bff:-0}"
prog="${prog:-0}"
# 2. build the filter chain
vf="null"
deint="no"
if [ $((tff + bff)) -gt "$prog" ]; then
vf="bwdif=mode=send_frame:parity=auto:deint=interlaced"
deint="yes"
fi
if [ "$SQUARE" = "1" ]; then
vf="$vf,scale=trunc(iw*sar/2)*2:ih,setsar=1"
fi
# 3. optional trim for test runs
trim_args=""
if [ "$TRIM" != "0" ]; then
trim_args="-t $TRIM"
fi
# 4. encode
ffmpeg -hide_banner -nostdin -nostats -y -fflags +genpts -i "$f" $trim_args \
-map 0:v:0 -map 0:a:0? -vf "$vf" \
-c:v libx264 -crf "$CRF" -preset "$PRESET" -pix_fmt yuv420p \
-c:a aac -b:a 192k -ac 2 -movflags +faststart "$out" 2> "$TMP"
rc=$?
# 5. compare durations
src_s="$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$f")"
out_s="$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$out" 2> /dev/null)"
status="ok"
if [ "$rc" -ne 0 ]; then
status="encode_failed"
elif [ "$TRIM" = "0" ]; then
status="$(awk -v a="$src_s" -v b="$out_s" 'BEGIN {
d = a - b
if (0 > d) d = -d
if (d > 1.5) print "check_duration"
else print "ok"
}')"
fi
echo "$name,$tff,$bff,$prog,$deint,$src_s,$out_s,$status" >> "$LOG"
echo "$name -> $status (deinterlaced: $deint)"
done
rm -f "$TMP"
echo "Log written to $LOG"
Save it as mpg2mp4.sh, run chmod +x mpg2mp4.sh and start with a test pass, for example TRIM=30 ./mpg2mp4.sh ./old_clips ./test_out. Check the three or four test outputs on a phone and a browser. When they look right, run the script without TRIM on the full folder. Windows users can run the same script in WSL or Git Bash, or use the PowerShell version below.
# mpg2mp4.ps1 - batch convert MPG, MPEG and VOB files to MP4
# usage: .\mpg2mp4.ps1 -Src .\old_clips -Out .\mp4_out -Crf 19
param(
[string]$Src = ".",
[string]$Out = ".\mp4_out",
[int]$Crf = 19,
[string]$Preset = "slow",
[int]$Trim = 0
)
New-Item -ItemType Directory -Force -Path $Out | Out-Null
$tmp = New-TemporaryFile
$log = Join-Path $Out "conversion_log.csv"
"file,tff,bff,progressive,deinterlaced,src_seconds,out_seconds,status" | Set-Content $log
Get-ChildItem -Path $Src -File | Where-Object { $_.Extension -match '^\.(mpg|mpeg|vob)$' } | ForEach-Object {
$f = $_.FullName
$outFile = Join-Path $Out ($_.BaseName + ".mp4")
ffmpeg -hide_banner -nostdin -nostats -i $f -vf idet -frames:v 400 -an -f null - 2> $tmp.FullName
$line = Select-String -Path $tmp.FullName -Pattern "Multi frame detection" | Select-Object -Last 1
$tff = 0
$bff = 0
$prog = 0
if ($line -match 'TFF:\s*(\d+)\s*BFF:\s*(\d+)\s*Progressive:\s*(\d+)') {
$tff = [int]$Matches[1]
$bff = [int]$Matches[2]
$prog = [int]$Matches[3]
}
$vf = "null"
$deint = "no"
if (($tff + $bff) -gt $prog) {
$vf = "bwdif=mode=send_frame:parity=auto:deint=interlaced"
$deint = "yes"
}
$ffArgs = @("-hide_banner", "-nostdin", "-nostats", "-y", "-fflags", "+genpts", "-i", $f)
if ($Trim -gt 0) { $ffArgs += @("-t", "$Trim") }
$ffArgs += @("-map", "0:v:0", "-map", "0:a:0?", "-vf", $vf,
"-c:v", "libx264", "-crf", "$Crf", "-preset", $Preset, "-pix_fmt", "yuv420p",
"-c:a", "aac", "-b:a", "192k", "-ac", "2", "-movflags", "+faststart", $outFile)
ffmpeg @ffArgs 2> $tmp.FullName
$rc = $LASTEXITCODE
$srcS = ffprobe -v error -show_entries format=duration -of csv=p=0 $f
$outS = ffprobe -v error -show_entries format=duration -of csv=p=0 $outFile
$status = "ok"
if ($rc -ne 0) {
$status = "encode_failed"
} elseif ($Trim -eq 0 -and [math]::Abs([double]$srcS - [double]$outS) -gt 1.5) {
$status = "check_duration"
}
"$($_.Name),$tff,$bff,$prog,$deint,$srcS,$outS,$status" | Add-Content $log
Write-Host "$($_.Name) -> $status (deinterlaced: $deint)"
}
Remove-Item $tmp.FullName -Force
Write-Host "Log written to $log"
After a run, the log looks like the sample below. The values are illustrative, and yours will differ. Read the status column first. Anything other than ok deserves a look in a player before you delete the original. Rows with deinterlaced=yes should be spot-checked on a fast pan, and rows with check_duration usually point to the timestamp fixes from step 7.
file,tff,bff,progressive,deinterlaced,src_seconds,out_seconds,status
beach_2004.mpg,398,0,2,yes,761.2,761.2,ok
birthday.mpeg,0,0,400,no,1204.5,1204.5,ok
tv_capture.mpg,371,12,17,yes,3601.9,3598.1,check_duration
VTS_01_1.VOB,401,0,0,yes,1048.3,1048.3,ok
The project handles the common cases and nothing exotic. It reads only the first audio track, downmixes to stereo and skips subtitle streams. The advanced tips below show how to extend it for hardware encoding, surround audio and noisy analog captures. If you want to compare other codec choices before you commit a whole library, the export and codecs section collects the format guides in one place.
Quality Check Before You Delete the Originals
A conversion log tells you the encode finished. It does not tell you the picture is right. Spend ten minutes on a manual pass for one file per source type, since a wrong setting repeats across every file in that group. Treat the checklist as a gate: nothing moves to the trash until every item passes on a device other than the one you converted on.
- Motion. Find a fast pan or a walking person and step through it frame by frame. Comb lines mean the deinterlacer did not run. Ghosting or doubled edges mean it ran on progressive footage or used the wrong field order.
- Shape. Check that faces look natural and circles look round. A squeezed picture means the aspect ratio flag was lost, so use the square-pixel filter from step 6.
- Sync. Watch a clap, a door slam or a spoken sentence at the start, the middle and the last minute. A growing gap points to the timestamp fix from step 7.
- Audio. Confirm both channels play and that dialogue sounds clear after any surround downmix.
- Duration. Compare the logged source and output seconds. A gap above about a second means a damaged stretch of the source or a dropped segment.
- Second device. Play the file on a phone and in a browser tab. A file that opens in your converter but not in Chrome or Safari used the wrong codec or pixel format.
Then decide what to archive. For family footage with no second copy, keep the original .mpg on cold storage such as an external drive and use the MP4 for everyday viewing and sharing. For footage you have already backed up elsewhere, the MP4 alone may be enough. If you may edit the clip later, convert it again from the original at a lower CRF, because editing an MP4 that came from a lossy MPG compounds the quality loss at every generation.
Common Pitfalls With Old MPG Files
These six mistakes account for most bad MPG conversions. Each one produces a file that looks fine for the first ten seconds and fails later.
- Stream-copying the MPEG-2 video.
-c copywrites an MP4 quickly, and the file then fails in browsers and on phones. Always re-encode the video to H.264. - Skipping deinterlacing. Interlaced footage converted as if it were progressive shows horizontal combing on every moving edge. Run idet first and deinterlace when the counts say so.
- Deinterlacing progressive video. The opposite mistake softens a clean picture. Use
deint=interlacedin bwdif, or HandBrake’s Decomb, so the filter acts only on frames that need it. - Scaling before deinterlacing. Resizing interlaced frames blends the fields and bakes the damage in. Deinterlace first, scale last.
- Upscaling SD to 1080p. This adds file size, not detail. Keep the native frame size unless a platform demands a specific one.
- Deleting the original too soon. A bad batch is only fixable when the .mpg still exists. Keep originals until you have played every output at least once on a second device.
A seventh trap sits in the file name. FFmpeg decides the output container from the extension you type, so out.mp4 gives MP4 and a misspelled extension gives an error. VLC, by contrast, can write a file with no usable container when you forget the extension. Type the .mp4 yourself every time.
Troubleshooting Failed MPG Conversions
Find the symptom in the list, apply the fix and re-run a 30-second test slice before you convert the whole file.
- Unknown encoder libx264. Your FFmpeg build lacks x264. Install a GPL build from your package manager, then confirm with
ffmpeg -encodersthat libx264 is listed. - Horizontal comb lines on moving objects. The footage is interlaced. Add
-vf "bwdif=mode=send_frame:parity=auto:deint=interlaced"or turn on Decomb in HandBrake. - People look too wide or too thin. The sample aspect ratio was ignored by your player. Add
scale=trunc(iw*sar/2)*2:ih,setsar=1after the deinterlace filter. - Audio drifts out of sync over time. The source has broken timestamps. Add
-fflags +genptsbefore the input,-fps_mode cfron the output and-af aresample=async=1for the audio. - Output has no sound. The mapped audio stream may be missing or in a codec FFmpeg did not pick. Run ffprobe, find the audio stream index and map it with
-map 0:a:0. If you copied AC-3, re-encode to AAC. - Output duration is wrong or the file ends early. A damaged stretch of the program stream stopped the decode. Add
-err_detect ignore_errbefore the input and compare durations again. - Motion looks jerky after deinterlacing. You used send_frame on fast action. Switch to
mode=send_fieldfor a doubled frame rate, or accept the original rate for talking-head footage. - Unsupported pixel format or odd width errors. H.264 with 4:2:0 color needs even dimensions. Keep
-pix_fmt yuv420pand use thetrunc(.../2)*2width expression whenever you scale. - Windows says HandBrake needs a runtime. Install the Microsoft .NET Desktop Runtime 10.0 that the HandBrake installer names, then reopen the app.
- The MP4 plays on the desktop but stutters on a phone. The profile or level is too high for the device. Add
-profile:v high -level 4.0for 1080p sources or-level 3.1for 720p and below. - VLC output is tiny or blocky. The stock profile bitrate is low. Edit the profile, raise the video bitrate and convert again.
If none of these match, probe the source with ffprobe and read the stream list again. A file that looks like an MPG by name sometimes holds a different codec, such as MPEG-4 Part 2 from a digital still camera, and that one needs no special handling beyond the same re-encode. When a file refuses to open at all, try VLC to confirm the data is intact before you suspect the converter.
Advanced Tips for Cleaner Output From Old Files
Use a hardware encoder when speed matters. NVIDIA, Intel, AMD and Apple silicon all expose H.264 encoders through FFmpeg. They finish faster than x264 and produce larger files at the same visible quality, so they suit bulk jobs more than archives. Swap the video codec flags and keep the rest of the command.
# NVIDIA
ffmpeg -i in.mpg -c:v h264_nvenc -rc vbr -cq 21 -b:v 0 -c:a aac -b:a 192k -movflags +faststart out_nvenc.mp4
# Intel Quick Sync
ffmpeg -i in.mpg -c:v h264_qsv -global_quality 21 -c:a aac -b:a 192k -movflags +faststart out_qsv.mp4
# Apple silicon or Intel Mac
ffmpeg -i in.mpg -c:v h264_videotoolbox -q:v 60 -c:a aac -b:a 192k -movflags +faststart out_vt.mp4
Choose H.265 for archives. HEVC shrinks files further than H.264 at equal quality, at the cost of weaker playback support in browsers. Add the hvc1 tag so Apple devices recognize the file. Stay with H.264 for anything you plan to upload or share.
ffmpeg -i in.mpg -vf "bwdif=mode=send_frame:parity=auto:deint=interlaced" -c:v libx265 -crf 22 -preset medium -tag:v hvc1 -pix_fmt yuv420p -c:a aac -b:a 192k -movflags +faststart out_hevc.mp4
Clean noisy analog captures. VHS and cheap TV tuner captures carry grain that eats bitrate. A light hqdn3d denoise before encoding lets the same CRF produce a smaller, cleaner file. Keep the strength low, because heavy denoising turns skin into wax. Chain it after the deinterlacer: bwdif=mode=send_frame:parity=auto:deint=interlaced,hqdn3d=2:1:3:3.
Crop black bars. Letterboxed or pillarboxed captures waste pixels. Run ffmpeg -i in.mpg -vf cropdetect -frames:v 300 -f null - and read the suggested crop values from the log, then add them as a crop=w:h:x:y filter ahead of the scale step.
Hit a target file size with two passes. When a platform enforces a size cap, CRF is the wrong tool because it cannot predict the final size. Two-pass encoding at a set bitrate can. Calculate the video bitrate as target size in kilobits divided by duration in seconds, minus the audio bitrate, then run both passes.
ffmpeg -y -i in.mpg -c:v libx264 -b:v 1800k -pass 1 -an -f null /dev/null
ffmpeg -i in.mpg -c:v libx264 -b:v 1800k -pass 2 -c:a aac -b:a 128k -movflags +faststart out_2pass.mp4
On Windows, replace /dev/null with NUL in the first pass. Once your MP4s exist, the same toolbox converts other formats too. The walkthrough on turning a GIF into MP4 uses the same faststart and pixel format flags, so the habits from this guide carry over directly.
Common questions
What is the fastest free way to change an MPG into an MP4?
Run one FFmpeg command: ffmpeg -i in.mpg -c:v libx264 -crf 19 -c:a aac -movflags +faststart out.mp4. FFmpeg costs $0 and runs on Windows, macOS and Linux. HandBrake is the quickest option if you prefer a window to a terminal.
Can I convert MPG to MP4 without losing quality?
Not strictly. MPEG-2 and H.264 are both lossy, so any re-encode discards some detail. At CRF 18 to 20 the loss is invisible to nearly every viewer on standard-definition footage. Keep the original .mpg if you need a perfect master.
Why does my converted MP4 show horizontal lines on moving objects?
The source was interlaced and the converter did not deinterlace it. Add the bwdif filter in FFmpeg or switch on Decomb in HandBrake, then convert again from the original file.
Is MPG the same as MPEG-2?
No. MPG is a file extension for a container, usually an MPEG program stream. The video inside can be MPEG-1 or MPEG-2, and DVD-era files often hold MPEG-2. Run ffprobe and read the codec_name line to see which one you have.
Does HandBrake convert MPG to MP4?
Yes. HandBrake 1.11.2 opens .mpg files directly, offers an MP4 output format with a Web Optimized option and costs $0. Choose a 480p or 576p preset for DVD-style sources, set Decomb in the Filters tab and start the encode.
Can VLC convert MPG to MP4?
Yes, through Media, then Convert / Save, using the Video – H.264 + MP3 (MP4) profile. Edit the profile to use AAC audio and a higher video bitrate. VLC has no constant-quality mode, so FFmpeg and HandBrake give better control.
Should I use H.264 or H.265 for the output?
Use H.264 for anything you will share, upload or play on unknown devices. Use H.265 for personal archives where smaller files matter and you control the players.
Are online MPG to MP4 converters safe for private videos?
They send your file to a third-party server, so skip them for private footage. For a single short public clip they are fine. Read each site’s file-retention and size limits before you upload.
More from the Vipid blog
- HandBrake Video Compressor: Settings That Shrink Files
- Reduce Video File Size [2026]: 3 Codecs, 4 Tools
- MP4 vs MOV [2026]: 2 Containers, 1 Real Difference
- How to Turn Live Photo Into Video: iPhone, Mac and FFmpeg
- How Do Green Screens Work? Key a Clip in FFmpeg and Resolve
- Vipid intro themes resolution, length and frame rate per theme
- Promo themes product and channel promos
- Sample videos finished Vipid intros
- Vipid intro maker make a custom intro in the browser
Jonah Reyes
Jonah Reyes is the Editing & Export Editor at Vipid. He covers editing software, export settings and codecs, and the video specs of YouTube, Shorts, TikTok and Reels, plus OBS and screen recording. He builds Vipid’s spec tables from the platforms’ own documentation and re-checks them every 60 to 90 days, so the numbers in a guide match what the upload dialog actually accepts.


