Search code examples
pythonyt-dlpffmpeg-python

convert YT video to audio file - "ERROR: Postprocessing: audio conversion failed: Error opening output files: Encoder not found"


I am using yt_dlp with Python to load a video from Youtube as an audio-only mp3 file. Until recently this worked fine, but now I get the following error message:

ERROR: Postprocessing: audio conversion failed: Error opening output files: Encoder not found

Both yt_dlp (Version 2025.02.19) and ffmpeg (Version 7.1) are up to date. I am working on a Windows 11 system with Python 3.12.

This is the function I have written and until recently the result was an mp3 file in the output folder.

def ydl_download_video(entry, out_path= "O:\\MP3\\00 CHARTS\\NEU\\"):
    url = entry.get('ylink').strip('\n')
    artist = entry.get('artist')
    title = entry.get('title')

    ydl_opts = {
        'format': 'bestaudio/best',
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'mp3',
            'preferredquality': '192',
        }],
        'cookiefile': 'all_cookies.txt',
        'outtmpl': f'{out_path}{artist} - {title}.%(ext)s'
    }
    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        ydl.download([url])

This is the output on the screen when the function is executed.

Trying to download Track...
[youtube] Extracting URL: https://www.youtube.com/watch?v=DlMEn5UU678
[youtube] DlMEn5UU678: Downloading webpage
[youtube] DlMEn5UU678: Downloading tv client config
[youtube] DlMEn5UU678: Downloading player 7795af42
[youtube] DlMEn5UU678: Downloading tv player API JSON
[info] DlMEn5UU678: Downloading 1 format(s): 251
[download] Destination: O:\MP3\00 CHARTS\NEU\Steff Da Campo & Robbie Mendez - Cry (Just A Little).webm
[download] 100% of    2.93MiB in 00:00:00 at 9.25MiB/s   
[ExtractAudio] Destination: O:\MP3\00 CHARTS\NEU\Steff Da Campo & Robbie Mendez - Cry (Just A Little).mp3
ERROR: Postprocessing: audio conversion failed: Error opening output files: Encoder not found
ERROR: Postprocessing: audio conversion failed: Error opening output files: Encoder not found

The track is also available as a .webm file in the output folder, but is no longer converted to mp3 as usual.

Is there anyone here who has the same problem and can possibly suggest a solution?

I have updated all the affected components of my program and have already googled for a solution to my problem. Unfortunately, I have not yet found a solution to my problem.


Solution

  • Your code looks similar to the one on this Reddit thread: https://www.reddit.com/r/youtubedl/comments/1ehvoqk/yt_dlputilsdownloaderror_error_postprocessing/

    You may need to install additional mp3 support for your ffmpeg build.