while-loop stops looping

From: Roeland Ordelman (ordelman_at_cs.utwente.nl)
Date: 03/23/04


Date: Tue, 23 Mar 2004 10:41:26 +0100

Hello all,

given the shell script below (it converts a bunch of mp3 files to
wav), the while loop DOES loop when I only echo filenames, but DOES
NOT loop when the conversion program 'ffmpeg' is executed: it
processes only one single file and then stops. So, only echoing gives:

processing 000003.mp3
done
processing 000004.mp3
done
processing 000005.mp3
done
processing 000006.mp3
done
processing 000007.mp3
done
processing 000008.mp3
done
processing 000008.mp3
done
all done

After uncommenting the conversion program I get:

processing 000003.mp3
Input #0, mp3, from '000003.mp3':
  Duration: 00:41:27.3, bitrate: 64 kb/s
  Stream #0.0: Audio: mp3, 44100 Hz, mono, 64 kb/s
Output #0, wav, to '000003.wav':
  Stream #0.0: Audio: pcm_s16le, 16000 Hz, mono, 256 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop encoding
size= 77729kB time=2487.3 bitrate= 256.0kbits/s
0
done
all done

ffmpeg seems to work okay, at least it does not give any error messages and
the conversion has been accomplished succesfully. While debugging, all
mp3 files have been converted to wav now, but I am puzzled about this
behavior. Has anyone an idea what might go wrong? I looks like if the
find job is killed by ffmpeg, how can that be? By the way, I run this
script on linux with suse8.2.

#############################################
#!/bin/sh

DIR=$HOME/whatever
DATA=$DIR/data

find $DATA -follow -name "*.mp3" -print |\
while read i
do
  base=$DATA/`basename $i .mp3`
  if [ ! -s $base.wav ]
  then
    echo "processing $i"
    ffmpeg -i $i -ab 16 -ar 16000 -ac 1 $base.wav
    echo $?
    echo "done"
  fi
done
echo "all done"

-- roeland



Relevant Pages

  • Re: about audacity and sound recording on Linux
    ... How did you transfer the WAV? ... I would like to export a number of wav files to mp3 files. ... call a script that converts all wav files in a directory to mp3 files. ... BTW, if you want to do all recording and converting on the fly, you ...
    (Debian-User)
  • Re: fourier analysis/MP3 to WAV format conversion
    ... is it possible to do convert MP3 files to WAV ones? ... frequency with a low amplitude right next to a frequency with a high ... but I would be very surprised if your speech data ... If you're doing the coding then definitely convert to wav first though, ...
    (comp.dsp)
  • Re: saving music projects to the hard drive
    ... up multiple wav and mp3 files for burning to a music CD. ... from here what I do is burn the cd, rip the cd to a single wav file, ... tracks around on the time line to overlap them as you like, ...
    (rec.audio.pro)
  • Re: Sting sings Dowland
    ... live performance of this material. ... wav and mp3 files and in view of the intense interest here ... I have not got the skills for that. ...
    (rec.music.early)
  • Re: Software MP3 Looper?
    ... It handles mp3 as well as .wav and a few other common file types. ... loop particular sections of a song, you can also slow it down, or record ...
    (alt.guitar)