ffmpeg - How to replace / overwrite part of audio from given timestamp on?

Viewed 164

I am using ffmpeg-kit to manage audio recordings in React Native.

  • I have 2 recordings - rec_1.m4a and rec_2.m4a.
  • I only know the duration of rec_1.m4a, which is 10.0 seconds.
  • I want to overwrite rec_1.m4a with rec_2.m4a from a specific timestamp on - e.g. from 5.6 seconds.

How can I do this with ffmpeg?

There are two special cases:

  1. rec_2.m4a ends before rec_1.m4a does (in our case this means rec_2.m4a's duration is <4.4 seconds - 10.0-5.6=4.4).
  2. rec_2.m4a does not end even after rec_1.m4a does (in our case this means rec_2.m4a's duration is >=4.4 seconds).

I know I could split the files and then concatenate them. But for that I would have to know rec_2.m4a's duration, which I don't.

Edit: Figured I could use the FFprobeKit.getMediaInformationAsync() function to easily get the duration of rec_2.m4a. But it would still be nice to know if replacement is possible without this extra step.

0 Answers
Related