Disclaimer: I don't understand ffmpeg and mostly just copy commands
I have two webm video files. Their duration is off by about a second.
I converted these to mp4 and everything was fine:
ffmpeg -acodec libopus -i 1.webm -r 10 -cpu-used 5 -c:v libx264 -crf 20 -c:a aac -strict experimental -loglevel error 1.mp4
I then extracted the audio from each video and everything was fine. By fine, I mean, when I playback the audio files by themselves they match the timings on the original video. I used this command to extract the audio:
fmpeg -i 1.mp4 -map 0:a -vn -acodec copy 1audio.m4a
I now have two audio tracks and I want to combine them into one, I want to "overlay" them, AND I want to keep the timings the same as they were.
BUT, whenever I try and combine the audio the timings are off. The "seconds" don't match the original single audio files.
I have tried these commands to merge the audio:
ffmpeg -i 1audio.m4a -i 2audio.m4a -filter_complex "[0:a][1:a]amerge=inputs=2[a]" -map [a] -c:a libfdk_aac mergedaudio.m4a
ffmpeg -i 2audio.m4a -i 1audio.m4a -filter_complex amix=inputs=2:duration=first mergedaudio.m4a
ffmpeg -i 1audio.m4a -i 2audio.m4a -filter_complex amerge -ac 2 -c:a libfdk_aac -vbr 4 mergedaudio.m4a
All the above command have resulted in a merged audio file... but the timings are off.
What am I doing wrong?