HydrogenAudio

Hydrogenaudio Forum => General Audio => Topic started by: nico_van_wijk on 2017-11-08 15:54:13

Title: SOX: Merge 2 audiofiles and trim with the length of an audiofile
Post by: nico_van_wijk on 2017-11-08 15:54:13
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?
 
Title: Re: SOX: Merge 2 audiofiles and trim with the length of an audiofile
Post by: DVDdoug on 2017-11-08 16:07:35
Why fight the command line???    Try Audacity or some other Windows/GUI audio editor.

Or, maybe you can trim after merging?
Title: Re: SOX: Merge 2 audiofiles and trim with the length of an audiofile
Post by: nico_van_wijk on 2017-11-08 19:18:48
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....
Title: Re: SOX: Merge 2 audiofiles and trim with the length of an audiofile
Post by: nico_van_wijk on 2017-11-08 20:48:50
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....