I can create an mp3 of a YouTube video with the following command:

youtube-dl --extract-audio --audio-format mp3 http://www.youtube.com/watch?v=rtOvBOTyX00

It creates an mp3 with the following filename:

Christina Perri - A Thousand Years [Official Music Video]-rtOvBOTyX00.mp3

I don't need the video ID part (rtOvBOTyX00) at the end and would like to have just the following:

Christina Perri - A Thousand Years [Official Music Video].mp3

Is this achievable with youtube-dl's options? If not, what's the next best solution?

4 Answers 4


Try the command

youtube-dl --extract-audio --audio-format mp3 --output "%(uploader)s%(title)s.%(ext)s" http://www.youtube.com/watch?v=rtOvBOTyX00
  • That gives ERROR: Error in output template: unsupported format character 't' (0x74) at index 1 (encoding: 'UTF-8'). May 30, 2015 at 7:36
  • Still the same error. Did you try the command and does it work for you? May 30, 2015 at 7:41
  • No, but this is from man youtube-dl I'm seraching for a fix
    – Maythux
    May 30, 2015 at 7:42
  • @JosephJohn check it now
    – Maythux
    May 30, 2015 at 7:46
  • It still gives an error youtube-dl: error: Cannot download a video and extract audio into the same file! Use "/%(uploader)s/%(title)s.%(ext)s" instead of "/%(uploader)s/%(title)s" as the output template. But Ben's answer works fine! May 30, 2015 at 7:47

As you could reed in the youtube-dl manpage the corresponding option would be -o :

youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" http://www.youtube.com/watch?v=rtOvBOTyX00
  • Excellent. This does exactly what I need. I'd tried the same command but I'd used %(title).%(ext)s instead. Thank you! May 30, 2015 at 7:46
  • 4
    Could you tell me what the s is for? I checked the manpage, but the page doesn't seem to explain that. May 30, 2015 at 7:48
  • 1
    Yes the lowercase s is part of the "special sequence" without the percentage the brackets and the 's' it would try to take the text after the -o as the literal filename.
    – Ben
    May 30, 2015 at 7:51
  • @Maythux I didn't - on the one hand you added the %uploader which wasn't requested, and on the other you added '/' where they shouldn't be. Espacally the first '/' before the uploader makes it an absolute path what you definetly won't want.
    – Ben
    May 30, 2015 at 7:53
  • 2
    s indeed... World's most unnecessary delimiter.
    – Tom
    May 22, 2016 at 14:09

You can specify name by using argument --output and then specifying the name in the following syntax in place of specific_name

youtube-dl https://www.youtube.com/watch?v=iuJDhFRDx9M -x --audio-format mp3 --output "specific_name.%(ext)s"

Escape your percent signs, so %(title)s becomes %%(title)s. I had this issue myself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.