H
H
Hector Synchrome2021-06-16 09:56:01
Python
Hector Synchrome, 2021-06-16 09:56:01

Why is there an error (ffmpeg) when using youtube-dl for python?

I want to download a video from YouTube and convert it to audio. For this I use the youtube-dl library. In my code, a simple example from the documentation . Installed packages: pip install youtube-dl, ffmpeg

from __future__ import unicode_literals
import youtube_dl
import ffmpeg



ydl_opts = {
    'format': 'bestaudio/best',
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'mp3',
        'preferredquality': '320',
    }],
    'prefer_ffmpeg': True
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download(['https://www.youtube.com/watch?v=BaW_jenozKc'])

As a result, the video is downloaded and converted to an audio file, but there are a lot of errors. What's wrong?
WARNING: BaW_jenozKc: writing DASH m4a. Only some players support this container. Install ffmpeg or avconv to fix this automatically.
ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one.
Traceback (most recent call last):
  File "C:\Users\Leоnid\PycharmProjects\converter2\venv\lib\site-packages\youtube_dl\YoutubeDL.py", line 2115, in post_process
    files_to_delete, info = pp.run(info)
  File "C:\Users\Leоnid\PycharmProjects\converter2\venv\lib\site-packages\youtube_dl\postprocessor\ffmpeg.py", line 272, in run
    filecodec = self.get_audio_codec(path)
  File "C:\Users\Leоnid\PycharmProjects\converter2\venv\lib\site-packages\youtube_dl\postprocessor\ffmpeg.py", line 166, in get_audio_codec
    raise PostProcessingError('ffprobe/avprobe and ffmpeg/avconv not found. Please install one.')
youtube_dl.utils.PostProcessingError: ffprobe/avprobe and ffmpeg/avconv not found. Please install one.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Leоnid\PycharmProjects\converter2\main.py", line 17, in <module>
    ydl.download(['https://www.youtube.com/watch?v=BaW_jenozKc'])
  File "C:\Users\Leоnid\PycharmProjects\converter2\venv\lib\site-packages\youtube_dl\YoutubeDL.py", line 2068, in download
    res = self.extract_info(
  File "C:\Users\Leоnid\PycharmProjects\converter2\venv\lib\site-packages\youtube_dl\YoutubeDL.py", line 808, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
  File "C:\Users\Leоnid\PycharmProjects\converter2\venv\lib\site-packages\youtube_dl\YoutubeDL.py", line 815, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\Leоnid\PycharmProjects\converter2\venv\lib\site-packages\youtube_dl\YoutubeDL.py", line 847, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "C:\Users\Leоnid\PycharmProjects\converter2\venv\lib\site-packages\youtube_dl\YoutubeDL.py", line 881, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "C:\Users\Leоnid\PycharmProjects\converter2\venv\lib\site-packages\youtube_dl\YoutubeDL.py", line 1692, in process_video_result
    self.process_info(new_info)
  File "C:\Users\Leоnid\PycharmProjects\converter2\venv\lib\site-packages\youtube_dl\YoutubeDL.py", line 2050, in process_info
    self.post_process(filename, info_dict)
  File "C:\Users\Leоnid\PycharmProjects\converter2\venv\lib\site-packages\youtube_dl\YoutubeDL.py", line 2117, in post_process
    self.report_error(e.msg)
  File "C:\Users\Leоnid\PycharmProjects\converter2\venv\lib\site-packages\youtube_dl\YoutubeDL.py", line 628, in report_error
    self.trouble(error_message, tb)
  File "C:\Users\Leоnid\PycharmProjects\converter2\venv\lib\site-packages\youtube_dl\YoutubeDL.py", line 598, in trouble
    raise DownloadError(message, exc_info)
youtube_dl.utils.DownloadError: ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2021-06-16
@MatewGreg

Install ffmpeg or avconv to fix this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question