not push
This commit is contained in:
parent
471699a82f
commit
4dc677dd74
16
src/index.py
16
src/index.py
@ -13,23 +13,23 @@ if __name__ == '__main__':
|
|||||||
import imageio
|
import imageio
|
||||||
#player = mpv.MPV(ytdl=True)
|
#player = mpv.MPV(ytdl=True)
|
||||||
#player.play("./data/VID_20230403_143809.mp4")
|
#player.play("./data/VID_20230403_143809.mp4")
|
||||||
video_file_path = "./data/VID_20230403_143809.mp4"
|
#video_file_path = "./data/VID_20230403_143809.mp4"
|
||||||
video = imageio.get_reader(video_file_path, "ffmpeg")
|
#video = imageio.get_reader(video_file_path, "ffmpeg")
|
||||||
|
|
||||||
# Get the number of frames and the frame rate
|
# Get the number of frames and the frame rate
|
||||||
num_frames = len(video)
|
#num_frames = len(video)
|
||||||
frame_rate = video.get_meta_data()['fps']
|
#frame_rate = video.get_meta_data()['fps']
|
||||||
|
|
||||||
# Calculate the duration in seconds
|
# Calculate the duration in seconds
|
||||||
duration = num_frames / frame_ratek
|
#duration = num_frames / frame_rate
|
||||||
print(duration)
|
#print(duration)
|
||||||
root = tk.Tk()
|
root = tk.Tk()
|
||||||
root.title("Slideshow")
|
root.title("Slideshow")
|
||||||
files = [
|
files = [
|
||||||
{"name": "VID_20230403_143809.mp4", "type":"video/mp4", "seconds":0},
|
{"name": "VID_20230403_143809.mp4", "type":"video/mp4", "seconds":0},
|
||||||
{"name": "egg.jpg", "type":"image/jpg", "seconds":3},
|
{"name": "egg.jpg", "type":"image/jpg", "seconds":7},
|
||||||
]
|
]
|
||||||
#SlideShow(root, files)
|
SlideShow(root, files)
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ from PIL import Image, ImageTk, Image
|
|||||||
from tkvideo import tkvideo
|
from tkvideo import tkvideo
|
||||||
import time
|
import time
|
||||||
import imageio
|
import imageio
|
||||||
|
import vlc
|
||||||
import mpv
|
import mpv
|
||||||
|
|
||||||
class SlideShow:
|
class SlideShow:
|
||||||
@ -78,12 +79,19 @@ class VideoPlayer:
|
|||||||
self.file = file
|
self.file = file
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.path = './data/' + self.file['name']
|
self.path = './data/' + self.file['name']
|
||||||
self.mpv_instance = mpv.MPV(wid=str(self.parent.canvas.winfo_id()))
|
#self.mpv_instance = mpv.MPV(wid=str(self.parent.canvas.winfo_id()))
|
||||||
print(self.mpv_instance)
|
instance = vlc.Instance()
|
||||||
player = mpv.MPV(ytdl=True)
|
player = instance.media_player_new()
|
||||||
player.play('https://youtu.be/DOmdB7D-pUU')
|
media = instance.media_new(self.path)
|
||||||
player.wait_for_playback()
|
media.parse()
|
||||||
player.metadata
|
self.time = media.get_duration()
|
||||||
|
print(self.time)
|
||||||
|
# Get the X11 window ID of the Tkinter canvas
|
||||||
|
#hwnd = str(self.parent.canvas.winfo_id())
|
||||||
|
#print(hwnd)
|
||||||
|
player.set_media(media)
|
||||||
|
player.set_xwindow(self.parent.canvas.winfo_id())
|
||||||
|
player.play()
|
||||||
|
|
||||||
#self.cap = cv2.VideoCapture(self.path)
|
#self.cap = cv2.VideoCapture(self.path)
|
||||||
|
|
||||||
@ -91,4 +99,4 @@ class VideoPlayer:
|
|||||||
#self.fps = int(self.cap.get(cv2.CAP_PROP_FPS))
|
#self.fps = int(self.cap.get(cv2.CAP_PROP_FPS))
|
||||||
#self.time = int(self.total_frames * ((int(1000/self.fps))))
|
#self.time = int(self.total_frames * ((int(1000/self.fps))))
|
||||||
|
|
||||||
self.mpv_instance.play(self.path)
|
#self.mpv_instance.play(self.path)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user