Mixing audio using SOX , sox FAIL formats: can't open input file `audio_recorded.wav': WAVE: RIFF header not found

elL picture elL · Jun 14, 2013 · Viewed 20.7k times · Source

I want to mix audio using SOX in linux. This is my script. I'm a total beginner on this thing.

    time sox --buffer 128000 --combine mix audio1.mp3 audio_recorded.wav -C 64.0 "./Mixed.mp3"
    time ffmpeg -loglevel warning -i ./Output.wav -c:a libfdk_aac -b:a 64k -map 0:0 -f segment -segment_time 10 -segment_list ./Output.m3u8 -segment_format aac './stream%03d.aac'

    cd ..

but the result is like this..

    sox FAIL formats: can't open input file `audio_recorded.wav': WAVE: RIFF header not found

    real    0m0.003s
    user    0m0.000s
    sys     0m0.002s

The audio_recorded.wav is a recorded audio file from android.

[REMOVED ANDROID CODE: no longer necessary]

UPDATE: I have tried to revise my recorder..set bit rate and sample rate same to audio1.mp3. Then I tried to mix it. This is now what happens:

    [root@app complete]# bash test_mix.sh 
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: recoverable MAD error
    sox WARN mp3-util: recoverable MAD error
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: recoverable MAD error
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: recoverable MAD error
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: recoverable MAD error
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: recoverable MAD error
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: recoverable MAD error
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: recoverable MAD error
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: recoverable MAD error
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: recoverable MAD error
    sox WARN mp3-util: recoverable MAD error
    sox WARN mp3-util: recoverable MAD error
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: recoverable MAD error
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: recoverable MAD error
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox WARN mp3-util: MAD lost sync
    sox FAIL formats: can't open input file `sound997309159.mp3': 

    real    0m0.005s
    user    0m0.002s
    sys     0m0.002s

I set the sample rate and bit rate of the recorded since when i tried mixing it in sox, it prompted me that the files dont have same channel and bit rate.

Answer

gino pilotino picture gino pilotino · Jun 14, 2013

probably the file has no header. You can specify the file type with

-t <file-type>

this is the man page: http://sox.sourceforge.net/sox.html