"fmpeg" has no attribute "input"
Asked Answered
D

5

8

I had previously built this youtube downloader but when I tested it recently; it stopped working.

from pytube import YouTube
import ffmpeg
import os

raw = 'C:\ProgramData\ytChache'

path1 = 'C:\ProgramData\ytChache\Video\\'
path2 = 'C:\ProgramData\ytChache\Audio\\'

file_type = "mp4"

if os.path.exists(path1 and path2):
    boo = True
else:
    boo = False

while boo:

    url = str(input("Link : "))
    choice = int(input('Enter 1 for Only Audio and Enter 2 For Both Audio and Video \n: '))

    video = YouTube(url)
    Streams = video.streams

    if choice == 1:
        aud = Streams.filter(only_audio=True).first().download(path2)

    elif choice == 2:
        resol = str(input("Resolution : "))
        vid = Streams.filter(res=resol, file_extension=file_type).first().download(path1)
        aud = Streams.filter(only_audio=True).first().download(path2)

        file = video.title + '.mp4'
        # location = path1
        # location2 = path2
        rem = os.path.join(path1, file)
        rm = os.path.join(path2, file)

        video_stream = ffmpeg.input(path1, video.title + '.mp4')
        audio_stream = ffmpeg.input(path2, video.title + '.mp4')
        ffmpeg.output(audio_stream, video_stream, video.title + '.mp4').run()
        os.remove(rem)
        os.remove(rm)

    else:
        print('Invalid Selection')

if not boo:
    os.mkdir(raw)
    os.mkdir(path1)
    os.mkdir(path2)

so it gives an error saying:

Traceback (most recent call last):
  File "E:\dev files\YouTube Video Downloader\Video Downloader.py", line 39, in <module>
    video_stream = ffmpeg.input(path1 + video.title + '.mp4')
AttributeError: module 'ffmpeg' has no attribute 'input'

I can't figure out what happened. I think it may have something to do about the versions of ffmpeg or something??

Dolley answered 25/9, 2022 at 7:57 Comment(0)
V
21

try:
pip install ffmpeg-python

instead of:
pip install ffmpeg

looks like your problem

Victorinavictorine answered 25/9, 2022 at 8:0 Comment(0)
S
1

Adding to the answer of @user14741746, take care of installing ffmpeg-python, be aware that there is another package called python-ffmpeg, as per the comment here.
Correct:

pip install ffmpeg-python

Incorrect:

pip install ffmpeg
pip install python-ffmpeg

That is, unless you are trying to install one of these two packages on purpose.

Swartz answered 30/11, 2023 at 4:31 Comment(0)
F
1

try using anaconda conda install ffmpeg

Ferrite answered 15/4 at 11:39 Comment(0)
D
0

If you're on macOs, you can also try to install ffmpeg through brew. It helped me to resolove such issue.

brew install ffmpeg
Donee answered 11/8, 2023 at 6:37 Comment(0)
M
0

especially when you are using venv the correct command is:

pip install ffmpeg-python

In my case worked on Ubuntu

Mania answered 2/5 at 13:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.