Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have the following script to convert a big bunch of .MOD and .XM files into Wave format:

#!/bin/bash

for f in ./XM.* ./MOD.*
    do
    xmp $f -d wav -o - | ffmpeg -i - -acodec libmp3lame -ab 320k "$f.mp3"
done

But it doesn't work as expected. The program just hang up. It creates the .wav file but nothing more.(Doesn't write in it) Even the -vvv switch doesn't give any information. The strange thing is: if I prepend "strace", it's working fine.

Any ideas/workarounds?

share|improve this question
    
What if you lose the pipe and just write to a temp file and have ffmpeg encode that? –  ckhan Nov 23 '12 at 8:15
    
The problem is, that xmp doesn't respond if it's called in a shell script at all. –  Noir Nov 23 '12 at 8:56
    
Run the script with -x to display the actual commands on stderr (e.g. bash -x convert.sh or place set -x somewhere in the script before the call to xmp). Or just print the commands instead of executing them (you'll have to escape the | of course). Then try to run the printed commands directly and get back to us with the results. –  peterph Nov 24 '12 at 21:21

1 Answer 1

up vote 2 down vote accepted

Perhaps xmp gets confused because stdin is not a tty? You could try:

xmp $f -d wav -o - </dev/null | ffmpeg -i - -acodec libmp3lame -ab 320k "$f.mp3"

Also, I would imagine that the order of arguments needs to be

xmp -d wav -o - "$f" </dev/null | ffmpeg -i - -acodec libmp3lame -ab 320k "$f.mp3"

On Ubuntu 14.04 with xmp 4.0.6 and avconv instead of ffmpeg, the order needs to be with the -d wav option later, or raw gets used

xmp -o - -d wav "$f" | avconv -i - -b 320k "$f.mp3"
share|improve this answer
    
Your second idea works. Thanks a lot! –  Noir Jul 5 '13 at 8:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.