I have a series of wav-files and I want to remove all the trailing and preceding silent space. The procedure itself is not the problem, although I may want to revisit that later.
My problem is with the bash script with which I'm doing it.
I've written many bash scripts and I think I have covered many of the pitfalls, but here I don't know what's happening.
It's a simple loop and the ffmpeg command is somehow influencing the variable in my bash script. I've never seen this before.
I the current folder I have a list of wav-files and they consist of 4 numbers and then "dot wav"
0000.wav
0001.wav
0002.wav
0003.wav
I collect these wav-files using the command find and put these in a file in a temporary folder.
If I cat this file it shows up nice...
./0000.wav
./0001.wav
./0002.wav
If I then use it in a "while read SOUND ; do" loop it runs fine too.
Only when I use the ffmpeg command in it and use "SOUND" as a parameter, something strange happens.
Here's the script and the output.
If I comment the remaining "ffmpeg line" it loops nice.
I'm hoping someone will give me an "ahaa! moment"
cat /usr/local/sbin/remsilence
Code:
#!/bin/bash
EXT=wav
TMPDIR=`mktemp -t -d ${0//*\/}.XXXXXXXXXX`
find -maxdepth 1 -type f -name \*.${EXT} | grep "${EXT}$" | sort >${TMPDIR}/sounds
rm -r OUTPUT 2>/dev/null
mkdir OUTPUT
cutfile()
{
echo "${SOUND}"
ffmpeg -loglevel fatal -y -i ${SOUND} -af silenceremove=1:0:-96dB ${TMPDIR}/begincut.${EXT}
#ffmpeg -loglevel fatal -y -i ${TMPDIR}/begincut.${EXT} -af areverse ${TMPDIR}/reversed.${EXT} || return 1
#ffmpeg -loglevel fatal -y -i ${TMPDIR}/reversed.${EXT} -af silenceremove=1:0:-96dB ${TMPDIR}/revcut.${EXT} || return 1
#ffmpeg -loglevel fatal -y -i ${TMPDIR}/revcut.${EXT} -af areverse ${TMPDIR}/finished.${EXT} || return 1
#mv "${TMPDIR}/finished.${EXT}" "OUTPUT/`filename ${SOUND}`"
}
head -n5 ${TMPDIR}/sounds
while read SOUND ; do
cutfile
done<${TMPDIR}/sounds
rm -r ${TMPDIR}
remsilence
Code:
./0000.wav
./0001.wav
./0002.wav
./0003.wav
./0004.wav
./0000.wav
/0001.wav
./0002.wav
/0003.wav
./0004.wav
/0005.wav
./0006.wav
/0007.wav
./0008.wav
/0009.wav
./0010.wav
Why it is deleting the preceding period?????