Convert audio download with youtube-dl to flac?

Urasam picture Urasam · Mar 16, 2017 · Viewed 11.2k times · Source

Is it possible to download a YouTube video as e.g. mp3 and then convert it to flac with ffmpeg? I can specify the arguments that ffmpeg shall use after the download with --postprocessor-args but I don't know how to get the file name there.

--postprocessor-args "-i downloadedfile.xxx -c:a flac downloadedfile.flac"

This would be the argument I want to use. Is this possible?

Answer

anon picture anon · Mar 16, 2017

Starting with youtube-dl 2017.03.16 - or right now if you check out the git repository - you can simply pass in --extract-audio --audio-format flac, as in:

youtube-dl -x --audio-format flac  https://www.youtube.com/watch?v=BaW_jenozKc

(-x is short for --extract-audio.)