
Recherche avancée
Médias (1)
-
1 000 000 (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
Autres articles (84)
-
Le profil des utilisateurs
12 avril 2011, parChaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...) -
Configurer la prise en compte des langues
15 novembre 2010, parAccéder à la configuration et ajouter des langues prises en compte
Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...) -
Les tâches Cron régulières de la ferme
1er décembre 2010, parLa gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
Le super Cron (gestion_mutu_super_cron)
Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)
Sur d’autres sites (11997)
-
error with ffmpeg, when trying to upload a video
14 juillet 2021, par JamesI recently downloaded a script, which is similar to a social network. And all items in this script related to publish, for example. The button to publish images, video and polls are included. However the video upload button has a problem, the host I'm hosting this site doesn't accept ffmpeg conversion, and so far so good because in the script if there isn't you can leave the ffmpeg field (in the adm panel) empty , and I did that, the problem is that when I try to upload a video, I always get an error saying that it was not possible to relazie the operation, I went to take a look at the script to process the video, and found that it uploads because the video goes to the uploads folder, but it doesn't deliver anything to the bank and doesn't even preview the video on the publish page, that is, the ffmpeg code is running even with the host not allowing it, giving an error soon.


I've tried to do everything like deleting the ffmpeg part of the code, trying to change the input names and many other small attempts like changing some name there or here, but the error still persists.


The code is right below, could someone tell me what I can change in this code so that it uploads the normal video ? (this host allows video uploading, but without ffmpeg). And what could be wrong with him ?


I tested it on localhost but everything worked fine


the whole code


<?php 

if (empty($cl['is_logged'])) {
 $data = array(
 'code' => 401,
 'data' => array(),
 'message' => 'Unauthorized Access'
 );
}

else {
 $post_data = $me['draft_post'];
 $media_type = fetch_or_get($_POST["type"], false);

 if (empty($media_type) || in_array($media_type, array("image", "video")) != true) {
 $data['code'] = 400;
 $data['message'] = "Media file type is missing or invalid";
 $data['data'] = array();
 }

 else {
 if ($media_type == "image") {
 if (not_empty($_FILES['file']) && not_empty($_FILES['file']['tmp_name'])) {
 if (empty($post_data)) {
 $post_id = cl_create_orphan_post($me['id'], "image");
 $post_data = cl_get_orphan_post($post_id);

 cl_update_user_data($me['id'], array(
 'last_post' => $post_id
 ));
 }
 
 if (not_empty($post_data) && $post_data["type"] == "image") {
 if (empty($post_data['media']) || count($post_data['media']) < 10) {
 $file_info = array(
 'file' => $_FILES['file']['tmp_name'],
 'size' => $_FILES['file']['size'],
 'name' => $_FILES['file']['name'],
 'type' => $_FILES['file']['type'],
 'file_type' => 'image',
 'folder' => 'images',
 'slug' => 'original',
 'crop' => array('width' => 300, 'height' => 300),
 'allowed' => 'jpg,png,jpeg,gif'
 );

 $file_upload = cl_upload($file_info);

 if (not_empty($file_upload['filename'])) {
 
 $img_id = cl_db_insert(T_PUBMEDIA, array(
 "pub_id" => $post_data["id"],
 "type" => "image",
 "src" => $file_upload['filename'],
 "time" => time(),
 "json_data" => json(array(
 "image_thumb" => $file_upload['cropped']
 ),true)
 ));

 if (is_posnum($img_id)) {
 $data['message'] = 'Media file uploaded successfully';
 $data['code'] = 200;
 $data['data'] = array(
 "media_id" => $img_id, 
 "url" => cl_get_media($file_upload['cropped']),
 "type" => "Image"
 );
 }
 }
 else {
 $data['code'] = 400;
 $data['message'] = "Something went wrong while saving a uploaded media file. Please check your details and try again";
 $data['data'] = array();
 }
 }
 else {
 $data['code'] = 400;
 $data['message'] = "You cannot attach more than 10 images to a post";
 $data['data'] = array();
 }
 }
 else {
 cl_delete_orphan_posts($me['id']);
 cl_update_user_data($me['id'],array(
 'last_post' => 0
 ));

 $data['code'] = 500;
 $data['message'] = "An error occurred while processing your request. Please try again later.";
 $data['data'] = array();
 }
 }
 else {
 $data['code'] = 500;
 $data['message'] = "Media file is missing or invalid";
 $data['data'] = array();
 }
 }

 else if($media_type == "video") {
 if (not_empty($_FILES['file']) && not_empty($_FILES['file']['tmp_name'])) {
 if (empty($post_data)) {
 $post_id = cl_create_orphan_post($me['id'], "video");
 $post_data = cl_get_orphan_post($post_id);

 cl_update_user_data($me['id'],array(
 'last_post' => $post_id
 ));
 }

 if (not_empty($post_data) && $post_data["type"] == "video") {
 if (empty($post_data['media'])) {
 $file_info = array(
 'file' => $_FILES['file']['tmp_name'],
 'size' => $_FILES['file']['size'],
 'name' => $_FILES['file']['name'],
 'type' => $_FILES['file']['type'],
 'file_type' => 'video',
 'folder' => 'videos',
 'slug' => 'original',
 'allowed' => 'mp4,mov,3gp,webm',
 );

 $file_upload = cl_upload($file_info);
 $upload_fail = false;
 $post_id = $post_data['id'];

 if (not_empty($file_upload['filename'])) {
 try {
 require_once(cl_full_path("core/libs/ffmpeg-php/vendor/autoload.php"));

 $ffmpeg = new FFmpeg(cl_full_path($config['ffmpeg_binary']));
 $thumb_path = cl_gen_path(array(
 "folder" => "images",
 "file_ext" => "jpeg",
 "file_type" => "image",
 "slug" => "poster",
 ));

 $ffmpeg->input($file_upload['filename']);
 $ffmpeg->set('-ss','3');
 $ffmpeg->set('-vframes','1');
 $ffmpeg->set('-f','mjpeg');
 $ffmpeg->output($thumb_path)->ready();
 } 

 catch (Exception $e) {
 $upload_fail = true;
 }

 if (empty($upload_fail)) {
 $vid_id = cl_db_insert(T_PUBMEDIA, array(
 "pub_id" => $post_id,
 "type" => "video",
 "src" => $file_upload['filename'],
 "time" => time(),
 "json_data" => json(array(
 "poster_thumb" => $thumb_path
 ),true)
 ));

 if (is_posnum($vid_id)) {
 $data['message'] = 'Media file uploaded successfully';
 $data['code'] = 200;
 $data['data'] = array(
 "media_id" => $vid_id, 
 "type" => "Video",
 "source" => cl_get_media($file_upload['filename']),
 "poster" => cl_get_media($thumb_path),
 );
 }
 }

 else {
 $data['code'] = 400;
 $data['message'] = "Something went wrong while saving a uploaded media file. Please check your details and try again";
 $data['data'] = array();
 }
 }
 }
 else {
 $data['code'] = 400;
 $data['message'] = "You cannot attach more than 1 video to a post";
 $data['data'] = array();
 }
 }
 else {
 cl_delete_orphan_posts($me['id']);
 cl_update_user_data($me['id'], array(
 'last_post' => 0
 ));
 }
 }

 else {
 $data['code'] = 500;
 $data['message'] = "Media file is missing or invalid";
 $data['data'] = array();
 }
 }
 }
}



I dosen't made this code so, i dont know nothing about him


-
What is Multi-Touch Attribution ? (And How To Get Started)
2 février 2023, par Erin — Analytics Tips -
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.