ffmpeg, how to avoid audio drift when muxing audio and video

I use scrcpy to mirror my Android screen to my PC. I have to capture the audio via bluetooth.

The result is two files. One .mkv and one .aac. They are both of equal length, possibly a second or two out.

I mux them together, but the audio always drifts.

I mux them together with the following command, $show is the bash variable for the video file.

ffmpeg -i $show.mkv -ss -00:00:02 -i $show.aac -c:v copy -c:a copy -shortest $show.muxed.mkv

The -ss sets the audio start time. I generally have to play around with this on a vid by vid basis. I can generally match the audio and video perfectly at the beginning of the file, but the audio will always drift over the course of the video.

Read more here: Source link