This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from moviepy.editor import VideoFileClip, concatenate_videoclips | |
from datetime import datetime | |
import os | |
def extract_segment(input_path, output_path, start_time, end_time): | |
video = VideoFileClip(input_path) | |
# Extragem doar segmentul dorit | |
segment = video.subclip(start_time, end_time) | |
segment.write_videofile(output_path, codec='libx264', audio_codec='aac') | |
video.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import os | |
from pathlib import Path | |
from PIL import Image | |
import glob | |
def extract_and_compress_frames(video_path, interval_seconds=5, quality=85, target_size=(1280, 720)): | |
# Obține directorul unde se află videoclipul | |
video_dir = os.path.dirname(video_path) | |
output_folder = os.path.join(video_dir, 'images') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import os | |
from pathlib import Path | |
def extract_frames(video_path, interval_seconds=5): | |
# Obține directorul unde se află videoclipul | |
video_dir = os.path.dirname(video_path) | |
# Creează subfolderul 'images' în același director cu videoclipul | |
output_folder = os.path.join(video_dir, 'images') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
import re | |
def clean_filename(filename): | |
# Eliminăm parantezele rotunde și conținutul lor | |
cleaned = re.sub(r'\s*\([^)]*\)', '', filename) | |
# Înlocuim caracterele non-alfanumerice (exceptând spațiile și cratimele) cu underscore | |
cleaned = re.sub(r'[^a-zA-Z0-9 \-_]', '_', cleaned) | |
# Eliminăm spațiile multiple și spațiile de la început și sfârșit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from moviepy.editor import VideoFileClip, AudioFileClip, concatenate_audioclips, AudioClip, TextClip, CompositeVideoClip | |
from moviepy.config import change_settings | |
from pydub import AudioSegment | |
import openai | |
import tempfile | |
import time | |
# Configurare pentru ffmpeg | |
os.environ["PATH"] += os.pathsep + r"D:\ffmpeg-master-latest-win64-gpl-shared\bin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from moviepy.editor import VideoFileClip, AudioFileClip, concatenate_audioclips, AudioClip | |
from pydub import AudioSegment | |
import openai | |
import tempfile | |
import time | |
# Configurare pentru ffmpeg | |
os.environ["PATH"] += os.pathsep + r"D:\ffmpeg-master-latest-win64-gpl-shared\bin" | |
AudioSegment.converter = r"D:\ffmpeg-master-latest-win64-gpl-shared\bin\ffmpeg.exe" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys # <-- importăm sys pentru a putea opri scriptul cu sys.exit() | |
from moviepy.editor import VideoFileClip, ImageClip, AudioFileClip, concatenate_videoclips, concatenate_audioclips | |
import re | |
def get_video_info(clip): | |
return { | |
'durată': f"{clip.duration:.2f} secunde", | |
'dimensiune': f"{os.path.getsize(clip.filename)/(1024*1024):.1f} MB", | |
'rezoluție': f"{clip.size[0]}x{clip.size[1]}", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import re | |
from moviepy.editor import VideoFileClip, ImageClip | |
def test_files(input_directory, image_duration=5): | |
media_files = [ | |
f for f in os.listdir(input_directory) | |
if f.lower().endswith(('.mp4', '.jpg', '.png')) | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from moviepy.editor import ImageClip, concatenate_videoclips, AudioFileClip, TextClip, CompositeVideoClip | |
from pydub import AudioSegment | |
import os | |
import glob | |
from PIL import Image | |
import numpy as np | |
# Configurare cale | |
os.environ["PATH"] += os.pathsep + r"D:\ffmpeg-master-latest-win64-gpl-shared\bin" | |
os.environ['IMAGEMAGICK_BINARY'] = r"d:\Program Files\ImageMagick-7.1.1-Q16-HDRI\magick.exe" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from moviepy.editor import ImageClip, concatenate_videoclips, AudioFileClip | |
import os | |
import glob | |
from PIL import Image | |
import numpy as np | |
def create_video_from_images(image_dir, music_path, output_path, image_duration=5, music_start=93): | |
images = sorted(glob.glob(os.path.join(image_dir, "*.jp*g"))) | |
# Get first image dimensions as reference |
NewerOlder