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

Command to download file as an mp3 #15653

Closed
bollywoodfan opened this issue Feb 19, 2018 · 3 comments
Closed

Command to download file as an mp3 #15653

bollywoodfan opened this issue Feb 19, 2018 · 3 comments

Comments

@bollywoodfan
Copy link

@bollywoodfan bollywoodfan commented Feb 19, 2018

#youtube-dl download mp3 only
Example
youtube-dl --audio-format 'mp3' https://www.youtube.com/watch?v=QCjk_NPsIqU

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Feb 19, 2018

--audio-format FORMAT Specify audio format: "best", "aac", "flac", "mp3", "m4a", "opus", "vorbis", or "wav"; "best" by default; No effect without -x

No effect without -x

@dstftw dstftw closed this Feb 19, 2018
@bollywoodfan
Copy link
Author

@bollywoodfan bollywoodfan commented Feb 19, 2018

Thanks for your prompt response.

I am doing the same as you mention however final file is mp4
youtube-dl --audio-format 'mp3' https://www.youtube.com/watch?v=QCjk_NPsIqU

I am trying to download files as mp3..I also tried following example to download mp3... however it created wem file.. what changes I need to make so that output will be high quality mp3.

from future import unicode_literals
import youtube_dl

class MyLogger(object):
def debug(self, msg):
pass

def warning(self, msg):
    pass

def error(self, msg):
    print(msg)

def my_hook(d):
if d['status'] == 'finished':
print('Done downloading, now converting ...')

ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
'logger': MyLogger(),
'progress_hooks': [my_hook],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://www.youtube.com/watch?v=BaW_jenozKc'])

@Hrxn
Copy link

@Hrxn Hrxn commented Feb 19, 2018

No effect without -x

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.