FFMPEG Merge a video that has sound with an mp3 audio file outputs audio out of sync

69 Views Asked by At

An example for further explanation: I'm recording a video singing at the same time the singer sings in a song. So, I have a video file(Me singing) and the audio file(the song).

I tried this simple command:

-i $video-i $audio-c copy -map 0:0 -map 1:0 -shortest output.mp4

But, it gives an output with the video sound muted(my voice muted).

And I want something more advanced to control the volume of each sound, and add filter to make the output sound sounds like it was recorded in a studio.. so after a long search through the documentation and similar questions, I made up this command here..

-i $video -i $audio -filter_complex "[0:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=0.8[a1]; [1:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=4[a2]; [a1][a2]amerge,pan=stereo|c0<c0+c2|c1<c1+c3[out]" -map 1:v -map [out] -c:v copy -c:a libmp3lame -shortest output.mp4

It gives a video output with audio out of sync. (My voice doesn't match the singer).

Any help would be really appreciated!

0

There are 0 best solutions below