MORE ffmpeg MAGIC

convert audio from/to various formats

TL;DR

Couple of days later this was posted, Rober tooted me that may be I was reinventing the wheel 😂

youtube-dl --extract-audio --audio-format mp3 -o '%(title)s.%(ext)s'

pretty easy huh?

Anyway if you want to learn a couple of things, here's the original article

Woot?

Scenario

You just want the audio of a given video source

$ youtube-dl -F https://awesomevideosourcedotcom/watch?v=idvideohere

gives you all video AND audio formats available for that url, with an id for each one.

formatos

Note on the left side the id of any option available, and under resolution those tagged as audio only.

You now can download that specific format and it'll be stored on your working directory.

$ youtube-dl -f id https://awesomevideosourcedotcom/watch?v=idvideohere

ffmpeg handy as usual

so you may have downloaded some webm or m4a (containers) but want to use some specific audio format. Here ffmpeg (and bash scripting) make their magic.

you need to check if that desired codec is available on your system and install it if is not.

$ ffmpeg -codecs help

each codec has its own options available.

Now asume we have downloaded a bunch of files with webm or m4a extension

webm

we can iterate on them to convert all using the same options and NOT changing compresion/qualty

for f in *.webm; do ffmpeg -i "$f" -vn -y  "${f%}.ogg"; done

or in a single file

ffmpeg -i input_file.webm -vn -y  output_file.ogg"    

m4a

same procedure, now using mp3

for f in *.m4a; do ffmpeg -i "$f" -acodec libmp3lame -ab 256k "${f%.m4a}.mp3"; done

you can just keep bitrate or, as shown on this example, recode to 256k or any other desired bitrate.

Sources

Read this, it may help you with useful information and tips.

bytefreaks.net

ubuntuforums (yep, still up)