Spaces:
Running
Running
programmes POC
Browse files- poc/test_moviepy.py +20 -0
- poc/test_pygame.py +28 -0
- poc/test_ytb.py +20 -0
poc/test_moviepy.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from moviepy import VideoFileClip
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
video_path = "video_source.mp4"
|
| 5 |
+
audio_output = "audio_extrait.mp3"
|
| 6 |
+
|
| 7 |
+
print("Extraction de l'audio en cours...")
|
| 8 |
+
|
| 9 |
+
try:
|
| 10 |
+
video = VideoFileClip(video_path)
|
| 11 |
+
|
| 12 |
+
if video.audio is not None:
|
| 13 |
+
video.audio.write_audiofile(audio_output, logger=None)
|
| 14 |
+
print(f"Audio extrait avec succès sous le nom : {audio_output}")
|
| 15 |
+
else:
|
| 16 |
+
print("Cette vidéo ne contient pas de piste audio.")
|
| 17 |
+
|
| 18 |
+
video.close()
|
| 19 |
+
except FileNotFoundError:
|
| 20 |
+
print(f"Fichier {video_path} introuvable.")
|
poc/test_pygame.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pygame
|
| 2 |
+
import time
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
audio_file = "audio_extrait.mp3"
|
| 6 |
+
|
| 7 |
+
if not os.path.exists(audio_file):
|
| 8 |
+
print(f"Fichier {audio_file} introuvable.")
|
| 9 |
+
exit()
|
| 10 |
+
|
| 11 |
+
pygame.mixer.init()
|
| 12 |
+
pygame.mixer.music.load(audio_file)
|
| 13 |
+
|
| 14 |
+
print("Lancement de l'audio...")
|
| 15 |
+
pygame.mixer.music.play()
|
| 16 |
+
|
| 17 |
+
iterations = 0
|
| 18 |
+
|
| 19 |
+
while pygame.mixer.music.get_busy():
|
| 20 |
+
|
| 21 |
+
if iterations % 100 == 0:
|
| 22 |
+
print(f"On enverra les commandes du robot en meme temps que le son de la vidéo sans probleme (itération {iterations})")
|
| 23 |
+
|
| 24 |
+
iterations += 1
|
| 25 |
+
time.sleep(0.01)
|
| 26 |
+
|
| 27 |
+
print("Fin de l'audio et arrêt de la boucle de contrôle.")
|
| 28 |
+
pygame.quit
|
poc/test_ytb.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import yt_dlp
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
url = 'https://www.youtube.com/watch?v=Aq5WXmQQooo'
|
| 5 |
+
output_filename = 'video_source.mp4'
|
| 6 |
+
|
| 7 |
+
ydl_opts = {
|
| 8 |
+
'format': 'best[ext=mp4]',
|
| 9 |
+
'outtmpl': output_filename,
|
| 10 |
+
'quiet': False
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
print("Téléchargement de la vidéo en cours")
|
| 14 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
| 15 |
+
ydl.download([url])
|
| 16 |
+
|
| 17 |
+
if os.path.exists(output_filename):
|
| 18 |
+
print(f"Vidéo téléchargée avec succès sous le nom : {output_filename}")
|
| 19 |
+
else:
|
| 20 |
+
print("Échec du téléchargement.")
|