0

youtube-dl.utils.DownloadError: ERROR: audio conversion failed: file: mp3 invalid argument

The above error appears with following parameters, running youtube-dl on Python 3.6 on Windows 7, FFmpeg and libmp3lame installed.

ydl_opts = {                                                
"format": "bestaudio/best",
"extractaudio": True,
"outtmpl": fetch_name + "%(ext)s",
"noplaylist": True,
"nocheckcertificate": True,
"postprocessors": [{
    "key": "FFmpegExtractAudio",
    "preferredcodec": "mp3",
    "preferredquality": "192",
}],
"progress_hooks": [hook]
}

fetch_name is for example C:\Path\File. [hook] just displays download messages. I've searched here and on internet but can't find this error.

Random Davis
  • 6,662
  • 4
  • 14
  • 24
Cristina
  • 1
  • 1
  • 2

3 Answers3

2

Try adding a "." to the end of the outtmpl. The error magically goes away.

I haven't checked, but I suspect this is an error with youtube-dl, where it expects a file extension to replace.

I don't know if bumping a dead question is frowned upon in here, but I thought I'd give light to this, since I was being bothered with the same issue.

anon
  • 21
  • 2
0
options={
        'writethumbnail':True,
        'format':'bestaudio/best',
        'keepvideo':False,
        'outtmpl.':filename,
        'postprocessors':[{'key': 'FFmpegExtractAudio',
            'preferredcodec': 'mp3',
            'preferredquality': '192'},
            {'key': 'EmbedThumbnail',},]
    }

This piece of script might help you. It worked for me very well.

Gokul
  • 31
  • 1
  • 6
-1

I traced back the arguments you have in your code and found this file, which in turn traces back to the list of postprocessors.

As you can see the post processor is named FFmpegExtractAudioPP where as you have used FFmpegExtractAudio. May be this is where you are getting it wrong.

hashcode55
  • 5,622
  • 4
  • 27
  • 40
  • as you can see in [the source of how the CLI option `-x` is handled by youtube-dl itself](https://github.com/ytdl-org/youtube-dl/blob/2791e80b60e1ca1c36b83ca93be35e7e5418a1c3/youtube_dl/__init__.py#L259), the postprocessor's `key` has no `PP` at the end. – ewen-lbh May 25 '20 at 17:45