
Recherche avancée
Médias (91)
-
Corona Radiata
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Lights in the Sky
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Head Down
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Echoplex
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Discipline
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Letting You
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (85)
-
Organiser par catégorie
17 mai 2013, parDans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...) -
Récupération d’informations sur le site maître à l’installation d’une instance
26 novembre 2010, parUtilité
Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer le (...) -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir
Sur d’autres sites (4482)
-
Anomalie #2022 : redirection des anciennes urls .php3
6 avril 2011, par cedric -Il y a un visiblement d’autres cas http://www.vbulletin.com/forum/project.php?issueid=11446
-
Could anyone help me understand why moviepy is rendering at 2.5 it/s ?
23 décembre 2023, par tristanI'm writing a program that uses moviepy to make those weird reddit thread videos with mc parkour playing in the background (real original ik), and everything is good except for when im rendering video which seems to consume a ton of memory and moves really... really slow, like 2.5 it/s. could anyone help ? also im a novice programmer that has no bearing on what is conventional or proper, so sorry if my code is very bad.


from moviepy.video.fx.all import resize
from moviepy.video.tools.subtitles import SubtitlesClip
from moviepy.editor import (
 CompositeVideoClip,
 AudioFileClip,
 VideoFileClip,
 ImageClip,
 TextClip
)
import random
import moviepy.config as cfg
import librosa
from imagegenerator import draw_title
from audioeditor import concatenate_audios
import soundfile as sf
import numpy as np

# Constants
VIDEO_FADE_DURATION = 0.4
SPEED_FACTOR = 1.1
TEXT_WIDTH = 600
MINIMUM_FONT_SIZE = 60
FONT_COLOR = "white"
OUTLINE_COLOR = "black"
TITLE_ANIMATION_DURATION = 0.25
ANIMATION_DURATION = 0.2

# Configure imagemagick binary
cfg.change_settings(
 {
 "IMAGEMAGICK_BINARY": "magick/magick.exe"
 }
)

# Ease-out function
def ease_out(t):
 return 1 - (1 - t) ** 2

# Overlap audio files
def overlap_audio_files(audio_path1, audio_path2):
 # Load the first audio file
 audio1, sr1 = librosa.load(audio_path1, sr=None)

 # Load the second audio file
 audio2, sr2 = librosa.load(audio_path2, sr=None)

 # Ensure both audio files have the same sample rate
 if sr1 != sr2:
 raise ValueError("Sample rates of the two audio files must be the same.")

 # Calculate the duration of audio2
 audio2_duration = len(audio2)

 # Tile audio1 to match the duration of audio2
 audio1 = np.tile(audio1, int(np.ceil(audio2_duration / len(audio1))))

 # Trim audio1 to match the duration of audio2
 audio1 = audio1[:audio2_duration]

 # Combine the audio files by superimposing them
 combined_audio = audio1 + audio2

 # Save the combined audio to a new file
 output_path = "temp/ttsclips/combined_audio.wav"
 sf.write(output_path, combined_audio, sr1)

 return output_path

# Generator function for subtitles with centered alignment and outline
def centered_text_generator_white(txt):
 return TextClip(
 txt,
 font=r"fonts/Invisible-ExtraBold.otf",
 fontsize=86,
 color=FONT_COLOR,
 bg_color='transparent', # Use a transparent background
 align='center', # Center the text
 size=(1072, 1682),
 method='caption', # Draw a caption instead of a title
 )

# Generator function for subtitles with centered alignment and blurred outline
def centered_text_generator_black_blurred_outline(txt, blur_factor=3):
 outline_clip = TextClip(
 txt,
 font=r"fonts/Invisible-ExtraBold.otf",
 fontsize=86,
 color=OUTLINE_COLOR,
 bg_color='transparent', # Use a transparent background
 align='center', # Center the text
 size=(1080, 1688),
 method='caption', # Draw a caption instead of a title
 )

 # Blur the black text (outline)
 blurred_outline_clip = outline_clip.fx(resize, 1.0 / blur_factor)
 blurred_outline_clip = blurred_outline_clip.fx(resize, blur_factor)

 return blurred_outline_clip

# Compile video function
def compile_video(title_content, upvotes, comments, tone, subreddit, video_num):
 # Set the dimensions of the video (720x1280 in this case)
 height = 1280

 # Concatenate the audios
 concatenate_audios()

 concatenated_audio_path = r"temp/ttsclips/concatenated_audio.mp3"
 title_audio_path = r"temp/ttsclips/title.mp3"

 title_audio = AudioFileClip(title_audio_path)
 concatenated_audio = AudioFileClip(concatenated_audio_path)

 # Calculate for video duration
 title_duration = title_audio.duration
 duration = concatenated_audio.duration

 # Set background
 background_path = f"saved_videos/newmcparkour.mp4"
 background = VideoFileClip(background_path)
 background_duration = background.duration
 random_start = random.uniform(0, background_duration - duration)
 background = background.subclip(random_start, random_start + duration)

 # Apply fade-out effect to both background clips
 background = background.crossfadeout(VIDEO_FADE_DURATION)

 # Generate the background image with rounded corners
 background_image_path = draw_title(title_content, upvotes, comments, subreddit)

 # Load the background image with rounded corners
 background_image = ImageClip(background_image_path)

 # Set the start of the animated title clip
 animated_background_clip = background_image.set_start(0)

 # Set the initial position of the text at the bottom of the screen
 initial_position = (90, height)

 # Calculate the final position of the text at the center of the screen
 final_position = [90, 630]

 # Animate the title clip to slide up over the course of the animation duration
 animated_background_clip = animated_background_clip.set_position(
 lambda t: (
 initial_position[0],
 initial_position[1]
 - (initial_position[1] - final_position[1])
 * ease_out(t / TITLE_ANIMATION_DURATION),
 )
 )

 # Set the duration of the animated title clip
 animated_background_clip = animated_background_clip.set_duration(
 TITLE_ANIMATION_DURATION
 )

 # Assign start times to title image
 stationary_background_clip = background_image.set_start(TITLE_ANIMATION_DURATION)

 # Assign positions to stationary title image
 stationary_background_clip = stationary_background_clip.set_position(final_position)

 # Assign durations to stationary title image
 stationary_background_clip = stationary_background_clip.set_duration(
 title_duration - TITLE_ANIMATION_DURATION
 )

 # Select background music
 if tone == "normal":
 music_options = [
 "Anguish",
 "Garden",
 "Limerence",
 "Lost",
 "NoWayOut",
 "Summer",
 "Never",
 "Miss",
 "Touch",
 "Stellar"
 ]
 elif tone == "eerie":
 music_options = [
 "Creepy",
 "Scary",
 "Spooky",
 "Space",
 "Suspense"
 ]
 background_music_choice = random.choice(music_options)
 background_music_path = f"music/eeriemusic/{background_music_choice}.mp3"

 # Create final audio by overlapping background music and concatenated audio
 final_audio = AudioFileClip(
 overlap_audio_files(background_music_path, concatenated_audio_path)
 )

 # Release the concatenated audio
 concatenated_audio.close()

 # Create subtitles clip using the centered_text_generator
 subtitles = SubtitlesClip("temp/ttsclips/content_speechmarks.srt",
 lambda txt: centered_text_generator_white(txt))
 subtitles_outline = SubtitlesClip("temp/ttsclips/content_speechmarks.srt",
 lambda txt: centered_text_generator_black_blurred_outline(txt))

 # Overlay subtitles on the blurred background
 final_clip = CompositeVideoClip(
 [background, animated_background_clip, stationary_background_clip, subtitles_outline, subtitles]
 )

 # Set the final video dimensions and export the video
 final_clip = final_clip.set_duration(duration)
 final_clip = final_clip.set_audio(final_audio)

 final_clip.write_videofile(
 f"temp/videos/{video_num}.mp4",
 codec="libx264",
 fps=60,
 bitrate="8000k",
 audio_codec="aac",
 audio_bitrate="192k",
 preset="ultrafast",
 threads=8
 )

 # Release the concatenated audio
 concatenated_audio.close()

 # Release the title audio
 title_audio.close()

 # Release the background video and image
 background.close()
 background_image.close()

 # Release the final audio
 final_audio.close()

 # Release the subtitle clips
 subtitles.close()
 subtitles_outline.close()

 # Release the final video clip
 final_clip.close()



ive tried turning down my settings, like setting it to "ultrafast" and dropping the bitrate, but nothing seems to work. the only thing I can think of now is that there is something Im doing wrong with moviepy.


-
Revision 30974 : pour la compatibilité avec Z, il faut que le plugin Menus passe après !
17 août 2009, par vincent@… — Logpour la compatibilité avec Z, il faut que le plugin Menus passe après !