Reputation: 1477
I am trying to convert a directory full of mp3's (with spaces in file names) to m4a.
To convert a single file (this works):
ffmpeg -i Traffic.mp3 -c:a libfaac -vn Traffic.m4a
The command that is failing (on OS X Mavericks):
find . -name \*.mp3 -print0 | xargs -0 ffmpeg -i {} -c:a libfaac -vn {}.m4a
Upvotes: 1
Views: 1554
Reputation: 13551
Why do you use xargs
? find -exec
is enough:
find . -name \*.mp3 -exec ffmpeg -i {} -c:a libfaac -vn {}.m4a \;
The problem is that xargs
is more similar to find -exec … +
than find -exec … \;
. It launches preferably just one instance of the command, replacing a single {}
by sequence of space separated items read from input (more or less). If you want xargs
to behave like find -exec … \;
, you need to specify -I{}
(xargs -0 -I{} ffmpeg …
).
This converts Traffic.mp3
to Traffic.mp3.m4a
. If you want to save the conversion result to Traffic.m4a
, you can
-exec
action and remove the .mp3
before appending .m4a
orxargs
after sed
ding the .mp3
extension away from find
result.I vote for the last option as it executes less processes (and shell is quite a big one, though ffmpeg
would be difinitely so large that the difference in performance is negligible).
find . -name \*.mp3 | sed 's/\.mp3$//' | xargs -I{} ffmpeg -i {}.mp3 -c:a libfaac -vn {}.m4a
Upvotes: 0
Reputation: 1477
find . -name '*.mp3' -type f -exec bash -c 'ffmpeg -i "$0" -c:a libfaac -vn "${0%.mp3}.m4a"' {} \;
Upvotes: 3