9
votes

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?

1
youtube-dl is open source. Why not try and add the conversion function in it ? - BioGenX
Forgot about that one haha. I might try it later today, but maybe it's possible without a modification - Urasam

1 Answers

22
votes

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.)