FFMPEG - audio delay/sync commands

Recording with shadowplay I have my mic audio recorded separately but due to the processing on my microphone it has roughly a 600ms delay. Is there a way to resync the second audio track (my mic) so it starts 600ms earlier making it in time with the video and game audio? Thanks in advance 🙂
6 Replies
HunterAP
HunterAP2y ago
Are you planning on editing the footage? You could just do that offset in the video editor directly
BrainZ
BrainZOP2y ago
I am, but my goal is to be able to make a batch file that can do it since I work with lots and lots of short clips. I already have multiple batch files for extracting audio streams, mixing them together and all sorts depending on what I need them for and it would be great to fix another problem in the process without having to open up the video editor
HunterAP
HunterAP2y ago
Ok, makes sense I haven't used shadowplay in a bit so I don't remember which audio track is for the mic (I assume it's audio track 2), the command to delay the video and game audio track by 600ms would look like this: ffmpeg -i .\YOU_FILE.mp4 -itsoffset -0.6 -i .\YOUR_FILE.mp4 -map 0:v -map 0:a:0 -map 1:a:0 -c copy .\YOUR_FILE_fixed.mp4 If you want to make a batch script to loop over all files in a folder, it'd look like this:
@echo off

mkdir fixed 2>NUL
mkdir original 2>NUL

for %%a in (*.mpv *.mkv) do (
ffmpeg -i "%%a" -itsoffset -0.6 -i "%%a" -map 0:v -map 0:a:0 -map 1:a:0 -c copy "fixed\%%~na_fixed.mp4"
mv "%%a -t "original"
)
@echo off

mkdir fixed 2>NUL
mkdir original 2>NUL

for %%a in (*.mpv *.mkv) do (
ffmpeg -i "%%a" -itsoffset -0.6 -i "%%a" -map 0:v -map 0:a:0 -map 1:a:0 -c copy "fixed\%%~na_fixed.mp4"
mv "%%a -t "original"
)
Basically it takes the video track and 1st audio track from the first input file, then takes the 2nd input file (which is just your single file again) and delays it by -600ms, then combines them together This will encode the fixed version into the folder named "fixed", and move the old version to the folder named "original"
BrainZ
BrainZOP2y ago
OK I've finally found the time to sit down with this and test it out! using the command you sent it's just made the 2 folders and nothing else unfortunately.
No description
BrainZ
BrainZOP2y ago
Here is the test video file I'm using
No description
BrainZ
BrainZOP2y ago
I changed the command line you created to search for MP4 files too since it looked like that's what the issue was but it seems to of just copied audio stream 1 to audio stream 2 so now it is just playing the game audio twice I'm gonna keep working on it and let you know If I figure out as to not waste your time! I appreciate the initial help, it's given me some ideas to work with 🙂

Did you find this page helpful?