I'm trying to make an application which downloads a video using Pytube, after getting it from a search using youtube-search-python, then playing the video using Kivy's video player. Everything works fine, except for playing the video. Here is my code:
from pytube import YouTube
from kivy.app import App
from youtubesearchpython import VideosSearch
from kivy.uix.videoplayer import VideoPlayer
videosSearch = VideosSearch('心臓を捧げよ!', limit = 1)
for i in range(1):
download_link = videosSearch.result()['result'][i]['link']
yt = YouTube(download_link)
yt.streams.get_highest_resolution().download()
video = (yt.title) + '.mp4'
class Player(VideoPlayer):
player = VideoPlayer(source= video, state = 'play')
class VideoApp(App):
def build(self):
return Player()
if __name__ == '__main__':
VideoApp().run()
and here is my output:
[INFO ] [Logger ] Record log in C:\Users\Shahzad\.kivy\logs\kivy_23-03-30_14.txt
[INFO ] [Kivy ] v2.1.0
[INFO ] [Kivy ] Installed at "C:\ProgramData\miniconda3\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.10.9 | packaged by conda-forge | (main, Jan 11 2023, 15:15:40) [MSC v.1916 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\ProgramData\miniconda3\python.exe"
[INFO ] [Logger ] Purge log fired. Processing...
[INFO ] [Logger ] Purge finished!
[INFO ] [Factory ] 189 symbols loaded
[INFO ] [ImageLoaderFFPy] Using ffpyplayer 4.4.0
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_ffpyplayer
[INFO ] [Text ] Provider: sdl2
[INFO ] [VideoFFPy ] Using ffpyplayer 4.4.0
[INFO ] [Video ] Provider: ffpyplayer(['video_ffmpeg'] ignored)
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.6.0 Compatibility Profile Context 23.3.1.230305'>
[INFO ] [GL ] OpenGL vendor <b'ATI Technologies Inc.'>
[INFO ] [GL ] OpenGL renderer <b'AMD Radeon(TM) Vega 3 Graphics '>
[INFO ] [GL ] OpenGL parsed version: 4, 6
[INFO ] [GL ] Shading version <b'4.60'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [Base ] Start application main loop
[ERROR ] [Image ] Error loading <【MAD】『心臓を捧げよ!』で振り返る 進撃の巨人 Season 2.mp4>
[INFO ] [GL ] NPOT texture support is available
I installed ffpyplayer after seeing that worked for some people with a slightly different error. Doing so caused me to get audio, but still no video.
Try replacing:
return Player()
with:
return VideoPlayer(source= video, state = 'play')
and eliminate the Player
class.