Last active
August 10, 2017 09:26
-
-
Save stegben/dbeef64c9b24b401426cf8b29eed27ca to your computer and use it in GitHub Desktop.
download audioset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import youtube_dl | |
meta_data = ... # from somewhere | |
count = meta_data[0] | |
info = meta_data[1] | |
url = 'http://youtu.be/{}'.format(info['YTID']) | |
output_audio_path = './audio/{}.wav'.format(str(count)) | |
ydl_ops = { | |
'format': 'bestaudio/best', | |
# 'postprocessors': [{ | |
# 'key': 'FFmpegExtractAudio', | |
# 'preferredcodec': 'mp3', | |
# 'preferredquality': '192', | |
# }], | |
'outtmpl':output_audio_path, | |
'external_downloader': 'ffmpeg', | |
'external_downloader_args': ['-i', output_audio_path, '-ab', '192k', '-f', 'mp3', '-ss', str(info['start_seconds']), '-t', '10',], | |
} | |
with youtube_dl.YoutubeDL(ydl_ops) as ydl: | |
ydl.download([url]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment