Better sound, same picture
How to replace the audio in a video with a separate audio recording

Short answer
Put the recorder track on the video with the free Koldflux Add audio to video tool, set to Replace, but first cut the track so it starts where the video starts. The tool has no offset control, so the alignment happens before it. Find the clap time in both files, subtract, and trim the recorder file by the difference. In our test the untrimmed track put the clap 1.402 s after the flash. Trimmed, it sat 0.007 s after, the same as the camera's own sound, and the picture's checksum did not change.
Key takeaways
- The tool does not move the new sound. Put an untrimmed recorder track through the tool and the clap lands late: 1.402 s after the flash in our run, which matches the head start the recorder had. Trim first.
- The offset is one subtraction: the clap time in the recorder file minus the clap time in the camera file. Here 4.409 s minus 3.007 s is 1.402 s, so you cut 1.402 s off the front of the recorder track.
- After the trim, the clap sat 0.007 s after the flash in the output. The camera's own, unreplaced sound measured +0.007 s against its own flash, so +0.007 s is the method's own offset on our constructed clap. With a real clap the offset will differ, and anything under about 0.04 s is not resolved.
- If the recorder started after the camera, you pad the front with silence instead of cutting. In our test the recorder started 1.0 s late (offset -0.998 s), with 998 ms of silence added by the adelay filter. The result again measured +0.007 s.
- The picture is not touched. The decoded-copy checksum of the video stream was the same before and after in our runs, and the sound in the output is the recorder's: above 4 kHz (command below) it read -39.2 dB, the same as the recorder file, against -55.1 dB for the camera track.
Lining the two tracks up
Find the clap time in each file, then subtract. Use the script below (it prints the time of the loudest sound in the first 30 seconds, so keep the clap as the loudest thing in that window), or read the peak from the waveform in any audio editor.
- Find the clap in the camera file: run find-clap.py on it and note the time.
- Find the clap in the recorder file the same way.
- Subtract the camera time from the recorder time. A positive result means the recorder started earlier. Cut that much off the front of the recorder track.
- Open the trimmed track and the video and listen to the clap once before you go on.
Run on November 24, 2026 with ffmpeg 6.1.1. find-clap.py printed 3.007 s for camera.mp4 and 4.409 s for recorder.wav, so the offset is 1.402 s. The -ss before -i cuts the input at that point. The ffmpeg manual says that when transcoding, the extra segment between the nearest seek point and the position "will be decoded and discarded"; it says the extra part is kept when doing stream copy, which is why our command re-encodes the sound (to WAV) and does not copy it. Both runs are in commands.log. The trimmed track was 20.598 s long (ffprobe), against 20 s of video. Check this length before you use the track: it should not be shorter than the picture. ffmpeg accepts a negative -ss number without a warning (exit 0 in our edge run and a 22 s file), so check the sign of your subtraction.
Without ffmpeg you can trim the start with the Koldflux Cut audio tool: enter your offset as the start time. Its page says the cut lands on the nearest 26 ms frame for MP3 and that other formats are saved as MP3 (Koldflux tool page, read November 24, 2026). Untested for this job, so check the clap again after the cut.
python3 find-clap.py camera.mp4
python3 find-clap.py recorder.wav
ffmpeg -ss 1.402 -i recorder.wav -c:a pcm_s16le recorder-trimmed.wav
ffprobe -v error -show_entries format=duration -of csv=p=0 recorder-trimmed.wav
How do you put the recorder sound on the video?
With the clap aligned, the swap itself is the ordinary Replace job, and the guide on adding audio to a video covers its steps, so they are not repeated here. In short: open the Koldflux Add audio to video tool, choose the camera file and the trimmed recorder file, pick Replace, leave the volume at 100% and download the MP4.
The tool page says the picture is copied without re-encoding and that the result is as long as the video, so longer audio is cut at the end (Koldflux tool page, read November 24, 2026). The camera file was 20 s and the trimmed recorder track 20.598 s, so the tool cut the extra 0.598 s at the end, as its page says, and the output came out at 20.000 s.
The live tool was driven in headless Chromium: Replace, volume 100, camera.mp4 plus recorder-trimmed.wav. It finished in 0.4 s and the output kept the camera's 20.000 s. The output's sound track was AAC at about 179.7 kbps (the tool page gives about 191 kbps for its own test files; the test file is speech, and the gap is unexplained).
The same job in ffmpeg, for the command line, is the first command below. It gave clap 3.007 s and flash 3.000 s. It differs from the tool in one way: -shortest ends the output at the shorter input, so a recorder track shorter than the picture cuts off the end of the picture. Trimming the front makes the track shorter, so this can happen. In our edge run a recorder track cut to 12 s gave a 12.000 s output from the 20 s video. The second command adds -af apad, which pads the sound with silence so the picture sets the length: the same 12 s track then gave 20.000 s, and the picture checksum matched the original. The tool page says the result is as long as the video; the tool with a short track was not run.
ffmpeg -i camera.mp4 -i recorder-trimmed.wav -map 0:v -map 1:a -c:v copy -c:a aac -b:a 192k -shortest replaced.mp4ffmpeg -i camera.mp4 -i recorder-trimmed.wav -map 0:v -map 1:a -c:v copy -af apad -c:a aac -b:a 192k -shortest replaced.mp4When the recorder started after the camera
Then the subtraction comes out negative, and there is nothing at the front of the recorder track to cut. Pad the front with silence instead. In our edge test the recorder started 1.0 s after the camera: its clap was at 2.009 s against the camera's 3.007 s, an offset of -0.998 s, so the fix is 998 ms of silence in front.
The ffmpeg manual describes adelay as: "Delay one or more audio channels. Samples in delayed channel are filled with silence." With all=1 the one delay is applied to every channel. The padded file through the tool measured +0.007 s too (replaced-late.mp4 in test-results.txt).
ffmpeg -i recorder-late.wav -af "adelay=998:all=1" -c:a pcm_s16le recorder-late-padded.wavHow do you check the result with numbers?
Do not rely on one listen. Our check had three parts: where the clap is against the flash, whether the picture changed, and whether the sound is really the recorder's. Each has a control with a known answer, so we could see whether the method itself is off. The flash measurement is test-only: we added one white frame to the test video, and flash.py finds it. Real footage has no such frame, and flash.py then stops with "no frame brighter than 230" (commands.log). On your own footage, play the clap with the picture: find the frame where the hands meet and see whether the clap in the output's waveform sits on it. That check was not run here.
| File | Clap | Flash | Clap minus flash |
|---|---|---|---|
| Camera's own sound (control, nothing replaced) | 3.007 s | 3.000 s | +0.007 s |
| Recorder track, not trimmed (control) | 4.402 s | 3.000 s | +1.402 s |
| Recorder track, trimmed 1.402 s (tool) | 3.007 s | 3.000 s | +0.007 s |
| Recorder started late, padded 998 ms (tool) | 3.007 s | 3.000 s | +0.007 s |
Our test only: the flash is a white frame we added.
Measured on November 24, 2026 (test-results.txt). The clap is the loudest sample of an 8 kHz decode, found by find-clap.py; the flash is the first frame whose average brightness is above 230, found by flash.py. In the camera file the flash is at 3.000 s and the clap at 3.0 s by construction, so the first row is the control: the method reads +0.007 s where the true answer is 0. A 25 fps frame is 40 ms and the clap is 12 ms long, so differences under about 0.04 s are below what this method can resolve. The clap column is the time measured in each output file. In the untrimmed output it read 4.402 s, against 4.409 s for recorder.wav itself; the 7 ms gap is not explained, and it is within the 12 ms length of the clap.
Picture: the third command in the block below prints a checksum of the video stream as stored. It was ffa0902db6dd99b459917d49d9afae06 for camera.mp4, replaced.mp4 and untrimmed.mp4. The padded output was not checksummed. The tool page reports the same thing for its own tests: identical checksum in 9 of 9 runs (Koldflux tool page, read November 24, 2026).
Sound: the camera track in our test was low-passed at 3 kHz, so the mean level above 4 kHz is a fingerprint (the command is in the last block below). It read -55.1 dB in camera.mp4, -39.2 dB in recorder.wav and -39.2 dB in replaced.mp4, so the output carries the recorder's sound.
python3 find-clap.py replaced.mp4
python3 flash.py replaced.mp4
ffmpeg -v error -i replaced.mp4 -map 0:v:0 -c copy -f md5 -ffmpeg -i replaced.mp4 -af highpass=f=4000,volumedetect -vn -f null -How the scripts handle bad input
Both scripts stop with a message instead of a guess, and they print no paths other than the one you gave, with two rougher cases: a video with no audio stream shows ffmpeg's own error text, and a non-number as the seconds argument of find-clap.py shows a Python error. Each script was run on the standard edge inputs (commands.log); you can expect this:
- A missing file, an empty file and a silent file each exit with code 1 and say which of the three it is.
- A file with a non-ASCII name (tested with a Cyrillic one) works.
- A text file with Windows line breaks named .wav gives a clear ffmpeg error that the audio could not be read.
- If the peak is not clearly louder than the rest (under 1.5 times), find-clap.py warns you to check by ear. On our test files the clap was well above that.
- flash.py stops with a message when no frame is brighter than 230, for example in a video that has no flash.
#!/usr/bin/env python3
"""Print the time of the loudest sound (the clap) in the first N seconds of an audio or video file.
Usage: python3 find-clap.py <file> [seconds=30]
Needs ffmpeg on the PATH. Prints: <seconds with 3 decimals> and a confidence ratio."""
import os, struct, subprocess, sys
RATE = 8000 # decode to 8 kHz mono: 0.125 ms per sample, enough for a clap
def main():
if len(sys.argv) < 2:
sys.exit("usage: python3 find-clap.py <file> [seconds]")
path = sys.argv[1]
limit = float(sys.argv[2]) if len(sys.argv) > 2 else 30.0
if not os.path.isfile(path):
sys.exit("find-clap: file not found: " + path)
if os.path.getsize(path) == 0:
sys.exit("find-clap: file is empty: " + path)
cmd = ["ffmpeg", "-v", "error", "-i", path, "-t", str(limit), "-vn", "-ac", "1", "-ar", str(RATE), "-f", "s16le", "-"]
res = subprocess.run(cmd, capture_output=True)
if res.returncode != 0 or len(res.stdout) < 2:
sys.exit("find-clap: ffmpeg could not read audio from " + path + ": " + res.stderr.decode("utf-8", "replace").strip()[:200])
n = len(res.stdout) // 2
samples = struct.unpack("<%dh" % n, res.stdout[: n * 2])
peak = max(range(n), key=lambda i: abs(samples[i]))
peak_v = abs(samples[peak])
if peak_v == 0:
sys.exit("find-clap: the file is silent in the first %.0f seconds" % limit)
# loudest sample at least 0.5 s away from the peak, to say how clear the clap is
guard = RATE // 2
other = max((abs(samples[i]) for i in range(n) if abs(i - peak) > guard), default=1) or 1
print("%.3f s (peak %.1f times the loudest sound elsewhere)" % (peak / RATE, peak_v / other))
if peak_v / other < 1.5:
print("warning: the peak is not clearly louder than the rest; check by ear or on a waveform", file=sys.stderr)
main()
What are the limits of this test?
What this page does and does not show:
- The files are constructed. The speech is a public-domain LibriVox reading, the clap is a synthetic 12 ms burst of noise and the flash is one white frame. The camera track was made worse on purpose (low-passed at 3 kHz, quieter, with added noise). This is not real camera footage, and a real hand clap is less clean.
- We say nothing about clock drift. Our files are 20 s and 22 s. Two devices with separate clocks can slowly move apart over a long recording, and that is not measured here. If it matters to you, put a second clap near the end and compare.
- Only WAV recorder files were run. If your recorder writes MP3 or another format, convert a copy first and check the result the same way.
- The measuring resolution is about 12 ms for the clap and 40 ms for a frame at 25 fps, so only the 1.402 s difference is clearly resolved. The +0.007 s is the method's offset, not proof that the sync is exact to the millisecond.
- A trim past the end of the recorder file leaves nothing: in our edge run, -ss 30 on a 22 s file wrote a 272-byte file with no audio. Check the trimmed file's length before you use it.
- The flash check works only because we added a white frame to the test video; real footage has none, and we did not test a replacement for it.
- What a podcast host or video platform does with the file afterwards is not covered; no accounts or devices were used.
Do it in your browser
Free Koldflux tools, no account needed.
Add audio to a video (free, runs in your browser)Cut audio (free, runs in your browser): trim the recorder track
Questions people ask
How do I replace video audio with a separate audio recording?
Find the clap in both files, subtract the camera time from the recorder time, trim the recorder track by that amount, then use the Koldflux Add audio to video tool in Replace mode. The tool runs in your browser and has no offset control, so the alignment is done before it.
Does the Koldflux tool let me nudge the audio by a fraction of a second?
No. It places the new sound at the start of the video. That is why this page trims or pads the recorder track first. In our test the untrimmed track put the clap 1.402 s after the flash.
What if the recorder started after the camera?
Add silence to the front of the recorder track instead of cutting. We padded 998 ms with ffmpeg's adelay filter and the clap then measured +0.007 s against the flash, the same as the camera's own sound.
Will replacing the audio change the video quality?
The picture is copied without re-encoding. In our two tool runs the checksum of the stored video stream matched the original file's, and the tool page reports a matching checksum in its own 9 of 9 tests.
I have no clap. Can I still sync?
Any sharp sound both devices heard works, for example a door or a dropped book. We tested only a clap. Without one you would match a word by ear, which is untested.
Will the sound drift out of sync on a long recording?
Untested here: the files were 20 and 22 seconds. Clap at the start and again at the end, and compare the two offsets before you trust a long file.
Related
More guides on this topic
Sources and how we checked
- Koldflux test log: clap and flash times, controls, checksums, levels (our measurement, November 24, 2026) (checked 2026-11-24)
- Koldflux command log: every published command with its exit code and an edge case (checked 2026-11-24)
- Koldflux find-clap.py: the clap-finding script used on this page (checked 2026-11-24)
- Koldflux flash.py: the flash-finding script used on this page (checked 2026-11-24)
- Koldflux tool runs in headless Chromium (tool-run.cjs) (checked 2026-11-24)
- FFmpeg documentation: ffmpeg tool, the -ss option and seeking (checked 2026-11-24)
- FFmpeg filters documentation: adelay (checked 2026-11-24)
- Internet Archive: Captain John Crane, 1800-1815 by Thomas Wallace Knox, LibriVox recording read by Tom Hirsch, chapter 1 Who and What I am (Public Domain Mark 1.0; the test speech) (checked 2026-11-24)
- Koldflux Cut audio tool page (26 ms frame and MP3 output; not tested here; read November 24, 2026) (checked 2026-11-24)
- Koldflux Add audio to video tool page (its own test numbers; read November 24, 2026) (checked 2026-11-24)
We built a 20 s test video (a 1280 × 720 test pattern at 25 fps with one white frame at 3.000 s) and gave it a degraded camera track made from a LibriVox public-domain speech excerpt with a synthetic 12 ms noise clap at 3.0 s. The recorder track is the same speech, clean, with the clap at 4.4 s (a head start of 1.400 s), plus a variant that started 1.0 s late. We measured the clap time with find-clap.py and the flash time with flash.py, trimmed with ffmpeg 6.1.1, ran the live Koldflux Add audio to video tool in headless Chromium (Replace, volume 100) and measured each output. Controls: the camera's own sound against its own flash, an untrimmed recorder track through the same tool, the checksum of the video stream, and the level above 4 kHz (highpass at 4 kHz, then volumedetect). The flash is a white frame we added; the Cut audio tool was not run. Every published command was run on the test file and on an edge input, logged in commands.log.