1

Took help from this thread : download only audio from youtube video using youtube-dl in python script

import youtube_dl #installed youtube_dl file

options = {
    'format':'bestaudio/best',
    'extractaudio':True,            #extracting audio
    'audioformat':'mp3',            #file options and format
    'outtmpl':'%(id)s.%(ext)s',     #name the file the ID of the video
    'noplaylist':True,
    'nocheckcertificate':True,
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',# Used ffmpeg for converting the file to mp3
        'preferredcodec': 'mp3',
        'preferredquality': '192',
    }]
}

with youtube_dl.YoutubeDL(options) as ydl:
    ydl.download(['https://youtu.be/BZP1rYjoBgI']) #final downloading

Python console output

Neil
  • 51
  • 4

1 Answers1

0

Most likely, you did not completely install ffmpeg; it must be in your PATH. You can check by typing ffmpeg in a terminal.

There are multiple possible solutions here:

  1. Install ffmpeg into your PATH, for example by copying the binary to /usr/bin/.

  2. Symlink the ffmpeg binary to a directory in your PATH.

  3. Set up your PATH so that it contains contains the directory where you installed ffmpeg. On Linux and macOS, this likely involved editing ~/.profile or /etc/environment and logging in again. On Windows, editing the registry works.

  4. Specify the precise ffmpeg location in your configuration by adding 'ffmpeg_location': '/replace/this/with/the/real/path/to/your/ffmpeg' to your youtube-dl configuration. Naturally this will only fix the problem for youtube-dl, not other applications relying on ffmpeg.