4 видео можно выбрать с помощью 4 кнопок. Не выполняйте также процесс переноса, но во время процесса переноса он переносится кадр за кадром, это не работает гладко. Есть ли у кого-нибудь опыт в этом плане?
Я установил свойства vlc на минимум
В коде можно перематывать вперед и назад на 1 секунду, из-за чего оно превращается в кадр, но когда я ввожу низкое значение, видео не воспроизводится плавно.
from gpiozero import Button, RotaryEncoder
import subprocess
import os
import time
# Düğmeler ve rotary encoder (encoder'ın butonu dahil) için pin tanımlamaları
buttons = [Button(22, bounce_time=0.1), Button(23, bounce_time=0.1),
Button(24, bounce_time=0.1), Button(25, bounce_time=0.1)]
encoder = RotaryEncoder(18, 17, max_steps=1) # Max steps ile her adımda 1 komut gönder
encoder_button = Button(27) # Rotary encoder'in buton pinini belirtin
video_paths = ['mp4', 'mp4',
'mp4', 'mp4']
current_video_process = None
current_video_index = -1 # Hiçbir video başlamamış
last_command_time = 0
command_interval = 0.2 # Komutlar arası minimum süre (saniye)
def play_video(video_index):
global current_video_process, current_video_index
video_path = video_paths[video_index]
if current_video_index == video_index:
return # Aynı video zaten oynatılıyorsa bir şey yapma
if current_video_process:
current_video_process.terminate()
current_video_process.wait()
if os.path.exists(video_path):
current_video_process = subprocess.Popen(
['vlc', '--intf', 'rc', '--rc-unix', '/tmp/vlc.sock', '--fullscreen', '--no-video-title-show', video_path],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
current_video_index = video_index
else:
print(f"Error: '{video_path}' dosyası bulunamadı.")
def change_video():
for i, button in enumerate(buttons):
if button.is_pressed:
play_video(i)
def pause_or_play():
if current_video_process:
current_video_process.stdin.write(b"pause\n")
current_video_process.stdin.flush()
def rewind_or_forward():
global last_command_time, command_interval
current_time = time.time()
if current_time - last_command_time > command_interval:
delta = encoder.steps
if delta != 0:
# Hassasiyeti artırmak için sarma miktarını azalttık
command = b"seek +1\n" if delta > 0 else b"seek -1\n"
current_video_process.stdin.write(command)
current_video_process.stdin.flush()
last_command_time = current_time
for button in buttons:
button.when_pressed = change_video
encoder_button.when_pressed = pause_or_play
encoder.when_rotated = rewind_or_forward
input("Programı sonlandırmak için ENTER'a basın...")
Подробнее здесь: https://stackoverflow.com/questions/784 ... a-player-u
Закрепление видео вперед и назад с помощью поворотного кодера в медиаплеере VLC с использованием Raspberry Pi 5 [закрыто ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение