How to convert multiple files to mp3 in Thunar custom actions?
I have added a simple command avconv -i %f %f.mp3
to Thunar's custom actions to convert a selected media file to mp3 (in the same folder and with the same name).
What would be the command that can be added in the same way that would allow selecting multiple files or an entire folder to convert them to mp3 (with the source's folder and name)?
I expect them to be converted one by one (not in parallel, that is, not all at the same time) - but I was wandering if that could be done with one context menu command after selecting multiple files.
It looks like avconv does not support multiple files per input (see comment under here), I am not asking necessarily for a command that includes avconv
, but for any other solution.
It depends a little, on how Thunar handles multiple files. Basically, you can use parallel
(website) to handle a lot of files.
sudo apt-get install parallel
So I would start with the following:
parallel avconv -i '{}' '{}.mp3' ::: %F
By default, it only does one job at a time. If you want to use multiple CPU cores in parallel, try parallel -j 4 ...
for 4 jobs in parallel. Also check out man parallel
.
In order to run it in Thunar's custom actions, this should be embedded like so:
xfce4-terminal -e "parallel avconv -i '{}' '{}.mp3' ::: %F"
To convert to other audio formats supported by avconv
, just replace mp3
with that - but: take into consideration other issues like:
flv
andmp4
files containaac
audio and converting that to other audio formats may entail unwanted results - more here. If theaac
file has about 95 kbps bitrate converting directly tomp3
would work, because the default bitrate for themp3
would be 192kbps, which is a good option (according to here). If theaac
file has a different bitrate, themp3
should be modified accordingly.aac
is a lossy format, and converting it to other formats should be considered in the context of the larger issue that converting between lossy formats is not recommendable. Even more, converting from a lossy format to a lossles one is pointless.a better option than converting
aac
tomp3
would be to just extract theaac
audio into am4a
container, as described here.
This will not stand as accepted answer.
Initially I was not thinking about a GUI. But, this is a way of doing it too. It will not convert directly, but will add selected files to Soundconverter list. (The main advantage is that supplementary settings are at hand.)
The command to be added to custom actions is
/usr/bin/soundconverter %F
Appearance conditions: video and audio.