Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to extract audio only using YoutubeDL class? #5984

Closed
chrismv48 opened this issue Jun 14, 2015 · 2 comments
Closed

How to extract audio only using YoutubeDL class? #5984

chrismv48 opened this issue Jun 14, 2015 · 2 comments

Comments

@chrismv48
Copy link

@chrismv48 chrismv48 commented Jun 14, 2015

I want to simply extract the audio in MP3 format from youtube links, but I can't figure out how to do this without calling youtube-dl from the command line with the --extract-audio option. Is there a way to do this within the YoutubeDL class similar to examples given here?

Here's what I have so far, but it still creates an mp4 file.

import youtube_dl

# download using optimal audio settings
ydl_opts = {
    'format': 'bestaudio/best',
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'mp3',
        'preferredquality': '192',
    }],
    'quiet': True,
    'restrictfilenames': True}

ydl = youtube_dl.YoutubeDL(ydl_opts)
ydl.download(['https://www.youtube.com/watch?v=Pnt2cy5MWyw'])
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jun 14, 2015

I've just answered you on stackoverflow.
Post the output of script execution with quiet set to False.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Jun 17, 2015

Closing since it seems that it's solved in stack overflow.

@jaimeMF jaimeMF closed this Jun 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.