Reputation: 71
I have two audio files A of length X and other B of length Y (X > Y). Now I want to replace the last Y part of file A with the file B.
For e.g. file A is of length 60s and file B is of length 43s. I need to replace the last 43s of file A with file B.
I hope it is clear.
Is it possible to do this using sox? How, do I need to merge them? If so then how to merge them?
Also is there any way to automate? Like I don't have to manually determine the length of both etc.
Upvotes: 0
Views: 1094
Reputation: 3301
You could concatenate both files, then remove the part that you don't need:
sox A B O trim 0 17 43
In a bash shell, this can be fully automated like so:
sox A B O trim 0 $(( $(soxi -s A) - $(soxi -s B) ))s $(soxi -s B)s
Here, soxi -s file
is used to determine the file length in samples. Another possibility, using a second sox instance in a pipe special input file:
sox "| sox A -p trim 0 -$(soxi -s B)s" B O
Upvotes: 2