Python yt-dlp and ffmpeg error "merging of multiple formats but ffmpeg is not installed"

4.8k Views Asked by At

I am using the latest version of yt-dlp with Python 3.9.

I am trying to download a youtube video in mp4 format with outputname as the youtubeid.mp4 and with best resolution not more than 4K.

This is my Python code:

ytid = '4cDqaLxrt6Q'
url = 'https://www.youtube.com/watch?v='+ytid
output_filename = ytid+".mp4"
    
with YoutubeDL({'format': 'bestvideo[height<=?4K]+bestaudio/best', 'output': output_filename}) as ydl:
    ydl.download(url)`#TODO debug FFmpeg and check if outputname is ok

I expected to have an .mp4 file in my current working directory.

Then I installed the latest version of FFmpeg from ffmpeg-master-latest-win64-gpl.zip and put ffmpeg.exe, ffplay.exe and ffprobe.exe in Scripts python folder (where yt-dlp.exe is). I also installed ffmpeg using pip install.

The Traceback is:

[youtube] Extracting URL: https://www.youtube.com/watch?v=4cDqaLxrt6Q [youtube] 4cDqaLxrt6Q: Downloading webpage [youtube] 4cDqaLxrt6Q: Downloading android player API JSON [youtube] 4cDqaLxrt6Q: Downloading MPD manifest [youtube] 4cDqaLxrt6Q: Downloading MPD manifest [info] 4cDqaLxrt6Q: Downloading 1 format(s): 243+251 ERROR: You have requested merging of multiple formats but ffmpeg is not installed. Aborting due to --abort-on-error Traceback (most recent call last):

File "C:\Users\t\OneDrive\Documents\Python Scripts\project\main.py", line 88, in ydl.download(url)

File "C:\Users\t\anaconda3\lib\site-packages\yt_dlp\YoutubeDL.py", line 3353, in download self.__download_wrapper(self.extract_info)(

File "C:\Users\t\anaconda3\lib\site-packages\yt_dlp\YoutubeDL.py", line 3328, in wrapper res = func(*args, **kwargs)

File "C:\Users\t\anaconda3\lib\site-packages\yt_dlp\YoutubeDL.py", line 1486, in extract_info return self.__extract_info(url, self.get_info_extractor(key), download, extra_info, process)

File "C:\Users\t\anaconda3\lib\site-packages\yt_dlp\YoutubeDL.py", line 1497, in wrapper return func(self, *args, **kwargs)

File "C:\Users\t\anaconda3\lib\site-packages\yt_dlp\YoutubeDL.py", line 1594, in __extract_info return self.process_ie_result(ie_result, download, extra_info)

File "C:\Users\t\anaconda3\lib\site-packages\yt_dlp\YoutubeDL.py", line 1653, in process_ie_result ie_result = self.process_video_result(ie_result, download=download)

File "C:\Users\t\anaconda3\lib\site-packages\yt_dlp\YoutubeDL.py", line 2767, in process_video_result self.process_info(new_info)

File "C:\Users\t\anaconda3\lib\site-packages\yt_dlp\YoutubeDL.py", line 3189, in process_info self.report_error(f'{msg}. Aborting due to --abort-on-error')

File "C:\Users\t\anaconda3\lib\site-packages\yt_dlp\YoutubeDL.py", line 1007, in report_error self.trouble(f'{self._format_err("ERROR:", self.Styles.ERROR)} {message}', *args, **kwargs)

File "C:\Users\t\anaconda3\lib\site-packages\yt_dlp\YoutubeDL.py", line 947, in trouble raise DownloadError(message, exc_info)

DownloadError: ERROR: You have requested merging of multiple formats but ffmpeg is not installed. Aborting due to --abort-on-error

2

There are 2 best solutions below

0
On

You have two ways:

  1. As a workaround, check your system path in Powershell, running: $Env:Path
    Put all three executables ff* in one of the listed paths.
  2. Best way, put all three executables in a folder of your choice and then add that path in Windows env PATH. How to do that depends on your Windows version; check Settings, search in for environment variables.
0
On

If you are using conda as your Python package manager, you can install ffmpeg in the virtual environment.

Note that the conda method is different from the pip method you mentioned.

(base) C:\Users\user> conda install ffmpeg

See: https://stackoverflow.com/a/75270671/22124527


I have installed last release of FFmpeg from ffmpeg-master-latest-win64-gpl.zip and put ffmpeg.exe , ffplay.exe and ffprobe.exe in Scripts python folder.

"Put .exe in the same python script folder" does not implies "add .exe in the system path that python can find". You can try:

import sys
sys.path.append('/path/to/your/exe/file/location')