I have function like this (got it form some website long ago):
function flv2mp3() {
ffmpeg -y -i "$1" -acodec libmp3lame "$(echo -n "$1" | sed -e 's/\.[^\.]*$//').mp3"
}
and I'm trying to call that function in loop:
find . -name 'Rage*' -not -name '*.mp3' -print0 | \
while read -d '' -r file; do
flv2mp3 "$file";
done
but got wierd result, it seems that it's after first invocation I 've got something like this:
stream #1:
keyframe=1
duration=0.023
dts=94.923 pts=94.923
size=388
stream #1:
keyframe=1
duration=0.023
dts=94.946 pts=94.946
size=381
Enter command: <target>|all <time>|-1 <command>[ <argument>]
and it waiting for input, what's going on? I can call flv2mp3 function without the loop just fine and it covert video to mp3.
I've also tried to put this:
flv2mp3 "$(echo -n $file | sed 's%./%%')"
because the files have ./
at the beginning but got the same results.
find
command finding the correct things? Try it by itself and change-print0
to-print
. – Kusalananda Sep 23 '17 at 19:15${1%.*}
to strip an extension off from the first command line argument. – Kusalananda Sep 23 '17 at 19:42