Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: SOX: Merge 2 audiofiles and trim with the length of an audiofile  (Read 2385 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

SOX: Merge 2 audiofiles and trim with the length of an audiofile

I try for a number of evenings to trim an audiofile with the length of an other audiofile. Nothing works to me.

This is the situation, I have two audio files:

file1.mp3 30 sec
file2.mp3 15 sec

I will merge both files with SOX and the new file must have the length of file2.mp3. I used the command prompt of Windows 10 and windows 7 and uses sox v14.4.2.

I've tried:

    sox - m file1.mp3 file2.mp3 output.mp3 trim 0 "|sox --i -D file2.mp3"


This give me the error sox FAIL trim: error parsing position 2.

The syntax to use the file length of file2.mp3 is wrong. Does anybody know how I can do this? Or isn't not possible in with the DOS command prompt?
 

 

Re: SOX: Merge 2 audiofiles and trim with the length of an audiofile

Reply #1
Why fight the command line???    Try Audacity or some other Windows/GUI audio editor.

Or, maybe you can trim after merging?

Re: SOX: Merge 2 audiofiles and trim with the length of an audiofile

Reply #2
Why fight the command line???    Try Audacity or some other Windows/GUI audio editor.

Or, maybe you can trim after merging?

I use Visual Basic 6 to control SOX in a DOS cmd box. I can Trim after merging, but I still have to know automatic how long the file length is of file2.mp3.

I think there's a possibility to use the command "sox --i d" to find the time and directly use it in an other sox command, but I don't know how....

Re: SOX: Merge 2 audiofiles and trim with the length of an audiofile

Reply #3
I can write the time length of file2.mp3 to a txtfile on the harddisc and then read the file.

Something like:
Code: [Select]
sox --i -D file2.mp3 > length.txt

But there must be an beter way....