0

So I want to download the youtube video as "song.m4a", however when I run the following code it gives "song.m4a.webm". How can I fix this?

from __future__ import unicode_literals
import youtube_dl
import os

##Function to download file from youtube
def getYoutube(url):
    ydlOps = {'format': 'bestaudio/best','postprocessors': [{'key': 'FFmpegExtractAudio','preferredcodec': 'm4a','preferredquality': '192',}],'outtmpl':f"{os.getcwd()}/song.m4a"}
    with youtube_dl.YoutubeDL(ydlOps) as ydl:
        ydl.download([url])

1 Answers1

0

I did test your code and on my case it output song.m4a

I think the problem is related to ffmpeg. Or you are missing a codec.

Check this youtube-dl python script postprocessing error: FFMPEG codecs aren't being recognized or post your