Ice Cr3aM
Ice Cr3aM

Reputation: 109

ffmpeg was not found. How do i fix this?

So im trying to make a simple discord music bot, which is halted right now due to this problem. The issue is that everytime i try to play a music through youtube_dl library, it pops up with the prompt: "ffmpeg was not found".

This is the main.py


import discord
import os
import asyncio
import youtube_dl
import ffmpeg

token = 'NzY5NTUzNDcwNjAwMTE4Mjgz.G3Dzce.XYKNAyLfBPg0ug5XPKssV-9EvsFjBlCMeM43ag'

client = discord.Client()

block_words = ['foo', 'bar', 'baz', 'quux', 'http://', 'https://']

voice_clients = {}
yt_dl_opts = {'format': 'bestaudio/best'}
ytdl = youtube_dl.YoutubeDL(yt_dl_opts)

ffmpeg_options = {'options': '-vn'}


@client.event
async def on_ready():
    print(f'Bot has logged in as {client.user}')

@client.event
async def on_message(msg):
    if msg.author != client.user:
        if msg.content.lower().startswith('?hi'):
            await msg.channel.send(f'Hi, {msg.author.display_name}')

@client.event
async def on_message(msg):
    if msg.author != client.user:
        for text in block_words:
            if "OTR" not in str(msg.author.roles) and text in str(msg.content.lower()):
                await msg.delete()
                return
        print("Not Deleting...")

@client.event
async def on_message(msg):
    if msg.content.startswith('?play'):
        try:
            url = msg.content.split()[1]

            voice_client = await msg.author.voice.channel.connect()
            voice_clients[voice_client.guild.id] = voice_client

            loop = asyncio.get_event_loop()
            data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))

            song = data['url']
            player = discord.FFmpegPCMAudio(song, **ffmpeg_options)
        except Exception as err:
            print(err)
client.run(token)

Upvotes: 10

Views: 99352

Answers (1)

L. von W.
L. von W.

Reputation: 451

FFMPEG is an audio and video manipulation tool, the error ffmpeg was not found means that you don't have FFMPEG installed.

If your OS is linux, then sudo apt install ffmpeg should do the trick.

If your OS is windows, you can download FFMPEG from the official download page: https://ffmpeg.org/download.html#build-windows.

If your OS is MacOS, you can also download it from the official download page: https://ffmpeg.org/download.html#build-mac.

Note that if you downloaded the executable from the website, you'll have to manually move it to your script's directory (or add it to PATH).

This error does NOT have anything to do with Youtube. Youtube cannot stop you from downloading videos, and it cannot stop you from using a video manipulation tool.

Upvotes: 11

Related Questions