How to Fix MP4 Audio Out of Sync Without Guessing

November 08, 2026 · MP4.now Editorial · MP4 Troubleshooting

Separate constant offsets from drift, variable frame rate and broken timestamps; give measurable fixes.

How to Fix MP4 Audio Out of Sync Without Guessing

Identify the Sync Problem Before Applying a Fix

MP4 audio-video misalignment falls into three categories: constant offset, progressive drift, and broken timestamps. Each requires a different repair. Applying the wrong fix—such as shifting audio on a file that drifts—corrects one point while breaking the rest.

Constant Offset

Audio and video are misaligned by the same interval from start to finish. This occurs when a capture device starts one stream before the other, or when a muxing tool applies an unintended delay.

Measurement: Open the file in a frame-accurate player (VLC with the time extension, MPC-HC, or a nonlinear editor). Locate a transient event—a door slam, hand clap, or hard cut. Record the video frame timestamp and the corresponding audio timestamp. Subtract one from the other.

Example: video shows the clap at 00:00:12.500, audio plays it at 00:00:12.633. The offset is +133 ms (audio is late). Repeat the measurement at three points: 10%, 50%, and 90% of the total duration. If the offset is identical at all three, the problem is a constant offset.

Drift

Sync degrades progressively. Audio starts aligned but falls behind or runs ahead as playback continues. Drift indicates mismatched playback rates between the audio and video streams, common in long recordings from phones, consumer cameras, or separate audio recorders with independent clocks.

Measurement: Measure the offset at 10% and 90% of the file duration using the transient method above. If the start offset is 0 ms and the end offset is +500 ms over a 30-minute file, the drift rate is approximately 16.7 ms per minute. The rate may be linear or variable; linear drift is correctable. Variable drift (non-uniform rate change across the file) indicates a more severe capture problem and may not be fully recoverable.

Broken or Missing Timestamps

The MP4 container stores presentation timestamps (PTS) for each frame and audio packet. Corruption, truncation, or improper concatenation can produce timestamps that jump backward, duplicate, or contain large gaps. Playback symptoms include audio that stutters, jumps, or plays at the wrong speed while video appears normal.

Measurement: Run two checks with FFprobe.

Check stream-level metadata:

ffprobe -v error -select_streams v -show_entries stream=time_base,duration,nb_frames -of default=noprint_wrappers=1 input.mp4

Compare the declared duration against the frame count. If nb_frames / duration does not match the expected frame rate, timestamps are suspect.

Inspect packet timestamps for the audio stream:

ffprobe -v error -select_streams a -show_entries packet=pts_time -of csv=p=0 input.mp4 | head -40

Look for PTS values that decrease (backward jumps) or gaps larger than twice the expected packet interval. Either pattern confirms timestamp damage.

Variable Frame Rate: A Separate Drift Mechanism

MP4 files conform to ISO Base Media File Format (ISO/IEC 14496-12), which stores a timescale and duration per track. The specification permits variable frame rate (VFR): each video frame can have a different duration. Screen recordings, phone cameras, and game captures frequently produce VFR. When a player assumes constant frame rate (CFR) and synchronizes audio against a fixed video clock, the mismatch creates drift that resembles a rate problem but originates in the video track's non-uniform timing.

Detection: Extract frame durations and count distinct values:

ffprobe -v error -select_streams v -show_entries frame=pts_time,duration_time -of csv=p=0 input.mp4 | awk -F, '{print $2}' | sort -n | uniq -c

If the output lists more than one duration, the file is VFR. For example, durations of 0.033s and 0.050s indicate frames recorded at both 30 fps and 20 fps.

Limitation: Converting VFR to CFR requires dropping or duplicating frames to fit a uniform grid. Motion in originally low-fps segments may appear jerky after conversion. There is no lossless round-trip from VFR to CFR.

Fixes with Verifiable Results

Fix 1: Constant Offset—Shift Without Re-encoding

Apply a fixed delay to the audio track using FFmpeg's -itsoffset. This adjusts timestamps only; both streams are copied without re-encoding, preserving quality.

Shift audio later by 133 ms:

ffmpeg -i input.mp4 -itsoffset 0.133 -i input.mp4 -map 0:v -map 1:a -c copy output.mp4

Use a negative value to shift audio earlier. After running, re-measure the offset at the same transient event used for diagnosis. Confirm the offset is now zero (or within one frame duration). This fix works only for constant offsets. Applying it to a drifting file aligns the start but worsens the end.

Fix 2: Linear Drift—Resample Audio to Match Video Duration

If the offset is zero at the start and nonzero at the end, stretch or compress the audio track to match the video track's duration. This re-encodes audio; video is copied.

Calculate the speed factor: divide the video duration by the audio duration. For a 30-minute file where audio is 500 ms longer, the factor is (1800 - 0.5) / 1800 ≈ 0.999722. Audio must play slightly faster.

Apply with the atempo filter (range 0.5–2.0):

ffmpeg -i input.mp4 -map 0:v -map 0:a -af "atempo=0.999722" -c:v copy output.mp4

For factors outside 0.5–2.0, chain multiple atempo instances (e.g., atempo=2.0,atempo=1.5 for 3× speed). For better quality on large adjustments, use the rubberband filter:

ffmpeg -i input.mp4 -map 0:v -map 0:a -af "rubberband=pitch=1:tempo=0.999722" -c:v copy output.mp4

After processing, measure the offset at 90% of the file. If residual error exceeds one frame duration, recalculate the factor from the new measurements and iterate.

Fix 3: Broken Timestamps—Regenerate or Rebuild

When PTS values are corrupt, attempt to regenerate them from frame order:

ffmpeg -fflags +genpts -i input.mp4 -c copy output.mp4

This works only if frames are intact and in correct sequence. If sync remains broken, extract raw elementary streams and remux into a clean container with an explicit frame rate:

ffmpeg -i input.mp4 -map 0:v -c copy video.h264
ffmpeg -i input.mp4 -map 0:a -c copy audio.aac
ffmpeg -r 30 -i video.h264 -i audio.aac -c copy output.mp4

The -r flag imposes a constant frame rate assumption. Original timestamp data is discarded. Use this only after +genpts fails, and verify sync at multiple points in the output.

Fix 4: Variable Frame Rate—Convert to CFR

Force a constant output frame rate while handling variable input timestamps:

ffmpeg -i input.mp4 -vsync vfr -r 30 -c:v libx264 -preset fast -c:a copy output.mp4

-vsync vfr instructs FFmpeg to process variable-rate input. -r 30 sets the target CFR. Video is re-encoded; audio is copied. Test sync at 10%, 50%, and 90% of the output. If a constant offset remains, combine with Fix 1 by adding an -itsoffset value.

What Cannot Be Recovered

Some sync defects originate in the recording process and cannot be repaired from the file alone:

  • Independent audio and video clocks: When audio and video are captured on separate devices without a common clock, drift is inherent and often non-linear. No single speed factor corrects it.
  • Dropped video frames during recording: If the camera skipped frames while audio continued uninterrupted, the audio track is longer than the video track. No timestamp manipulation can reconstruct missing visual data.
  • Corrupt audio samples: Gaps, static, or missing segments in the audio stream require audio restoration before remuxing. Timestamp fixes cannot replace absent sound data.

Validation

After applying any fix, export three short segments (first 10 seconds, middle 10 seconds, last 10 seconds) and check sync in at least two different players that display frame-level timecodes. Do not rely on a single application's playback behavior. If the file will be delivered to a platform (YouTube, Vimeo, broadcast), test the exported segments in that platform's preview environment before processing the full file.

Technical basis for How to Fix MP4 Audio Out of Sync Without Guessing

Structural claims in this guide are grounded in the primary MP4 technical reference.