Download from YouTube as ".wav" instead of ".webm"

Viewed 190

I am trying to extract an audio from a YouTube Video as an .wav file. However, the script that I am running keeps giving me .webm files. The code I am using is the following:

from __future__ import unicode_literals
import youtube_dl

ydl_opts = {
    'format': 'bestaudio/best',
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'wav',
        'preferredquality': '192'
    }],
    'postprocessor_args': [
        '-ar', '16000'
    ],
    'prefer_ffmpeg': True,
    'keepvideo': True
}

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download(['https://www.youtube.com/watch?v=2Xq7iJKzhR4'])

Is there a way to change the output and keep the highest possible audio quality?

I tried setting prefer_ffmpeg': True to False & keepvideo': True to False but that did not change anything.

I would appreciate suggestions and please keep in mind that I never used Python before.

0 Answers
Related