I use ffmpeg
for sound conversion:
1 2 3 |
ffmpeg -i file.ogg file.mp3 ffmpeg -i file.{ogg,mp3} <span class="hljs-comment"># if only the extension changes </span> |
If your filename contains spaces don’t forget to quote it, e.g.:
1 2 |
ffmpeg -i <span class="hljs-string">"file with spaces"</span>.{ogg,mp3} |
To perform batch processing you can either use a for
loop like
1 2 |
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> *.ogg; <span class="hljs-keyword">do</span> ffmpeg -i <span class="hljs-string">"<span class="hljs-variable">$i</span>"</span> <span class="hljs-string">"<span class="hljs-variable">${i%.*}</span>.mp3"</span>; <span class="hljs-keyword">done</span> |
or – especially for many and/or large files! – GNU parallel
:
1 2 |
parallel ffmpeg -i <span class="hljs-string">"{}"</span> <span class="hljs-string">"{.}.mp3"</span> ::: *.ogg |
This last command will convert every .ogg
file in the current directory to .mp3
efficiently using your CPU(s) to perform multiple tasks in parallel.
To set the audio bitrate ffmpeg
provides the -b:a BITRATE
option, e.g. -b:a 192k
. If you want to include metadata like title, album and so on, you can use these options:
1 |
-map_metadata 0:s:0 -id3v2_version 3 -write_id3v1 1 |