
Recherche avancée
Médias (91)
-
Les Miserables
9 décembre 2019, par
Mis à jour : Décembre 2019
Langue : français
Type : Textuel
-
VideoHandle
8 novembre 2019, par
Mis à jour : Novembre 2019
Langue : français
Type : Video
-
Somos millones 1
21 juillet 2014, par
Mis à jour : Juin 2015
Langue : français
Type : Video
-
Un test - mauritanie
3 avril 2014, par
Mis à jour : Avril 2014
Langue : français
Type : Textuel
-
Pourquoi Obama lit il mes mails ?
4 février 2014, par
Mis à jour : Février 2014
Langue : français
-
IMG 0222
6 octobre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Image
Autres articles (85)
-
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...) -
Gestion des droits de création et d’édition des objets
8 février 2011, parPar défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;
Sur d’autres sites (10591)
-
Increasing Website Traffic : 11 Tips To Attract Visitors
25 août 2023, par Erin — Analytics Tips, Marketing -
Why is my .mp4 file created using cv2.VideoWriter not syncing up with the audio when i combine the video and audio using ffmpeg [closed]
27 décembre 2024, par joeS125The aim of the script is to take text from a text file and put it onto a stock video with an ai reading the text. Similar to those reddit stories on social media with parkour minecraft in the background.


import cv2
import time
from ffpyplayer.player import MediaPlayer
from Transcription import newTranscribeAudio
from pydub import AudioSegment

#get a gpt text generation to create a story based on a prompt, for example sci-fi story and spread it over 3-4 parts
#get stock footage, like minecraft parkour etc
#write text of script on the footage
#create video for each part
#have ai voiceover to read the transcript
cap = cv2.VideoCapture("Stock_Videos\Minecraft_Parkour.mp4")
transcription = newTranscribeAudio("final_us.wav")
player = MediaPlayer("final_us.mp3")
audio = AudioSegment.from_file("final_us.mp3")
story = open("Story.txt", "r").read()
story_split = story.split("||")
fps = cap.get(cv2.CAP_PROP_FPS)
frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
video_duration = frame_count / fps # Duration of one loop of the video
fourcc = cv2.VideoWriter_fourcc(*"mp4v")
audio_duration = len(audio) / 1000 # Duration in seconds
video_writer = cv2.VideoWriter(f"CompletedVideo.mp4", fourcc, fps, (1080, 1920))

choice = 0#part of the story choice
part_split = story_split[choice].split(" ")
with open("Segment.txt", "w") as file:
 file.write(story_split[choice])
start_time = time.time()
length = len(part_split) - 1
next_text = []
for j in range(0, length):
 temp = part_split[j].replace("\n", "")
 next_text.append([temp])
index = 0
word_index = 0
frame_size_x = 1080
frame_size_y = 1920
audio_duration = len(audio) / 1000 # Duration in seconds
start_time = time.time()
wait_time = 1 / fps
while (time.time() - start_time) < audio_duration:
 cap.set(cv2.CAP_PROP_POS_FRAMES, 0) # Restart video
 elapsed_time = time.time() - start_time
 print(video_writer)
 if index >= len(transcription):
 break
 while cap.isOpened():
 # Capture frames in the video 
 ret, frame = cap.read()
 if not ret:
 break
 audio_frame, val = player.get_frame()
 if val == 'eof': # End of file
 print("Audio playback finished.")
 break
 if index >= len(transcription):
 break
 
 if frame_size_x == -1:
 frame_size_x = frame.shape[1]
 frame_size_y = frame.shape[0]

 elapsed_time = time.time() - start_time

 # describe the type of font 
 # to be used. 
 font = cv2.FONT_HERSHEY_SIMPLEX 
 trans = transcription[index]["words"]
 end_time = trans[word_index]["end"]
 if trans[word_index]["start"] < elapsed_time < trans[word_index]["end"]:
 video_text = trans[word_index]["text"]
 elif elapsed_time >= trans[word_index]["end"]:
 #index += 1
 word_index += 1
 if (word_index >= len(trans)):
 index += 1
 word_index = 0
 # get boundary of this text
 textsize = cv2.getTextSize(video_text, font, 3, 6)[0]
 # get coords based on boundary
 textX = int((frame.shape[1] - textsize[0]) / 2)
 textY = int((frame.shape[0] + textsize[1]) / 2)
 
 cv2.putText(frame, 
 video_text, 
 (textX, textY), 
 font, 3, 
 (0, 255, 255), 
 6, 
 cv2.LINE_4)
 
 # Define the resize scale
 scale_percent = 50 # Resize to 50% of the original size
 # Get new dimensions
 width = 1080
 height = 1920
 new_size = (width, height)

 # Resize the frame
 resized_frame = cv2.resize(frame, new_size)
 video_writer.write(resized_frame)
 cv2.imshow('video', resized_frame)
 cv2.waitKey(wait_time)
 if cv2.waitKey(1) & 0xFF == ord('q'): 
 break
cv2.destroyAllWindows()
video_writer.release()
cap.release()




When I run this script the audio matches the text in the video perfectly and it runs for the correct amount of time to match with the audio (2 min 44 sec). However, the saved video CompletedVideo.mp4 only lasts for 1 min 10 sec. I am unsure why the video has sped up. The fps is 60 fps. If you require any more information please let me know and thanks in advance.


I have tried changing the fps, changing the wait_time after writing each frame. I am expecting the CompletedVideo.mp4 to be 2 min 44 sec long not 1 min 10 sec long.


-
What is Multi-Touch Attribution ? (And How To Get Started)
2 février 2023, par Erin — Analytics Tips