
Recherche avancée
Autres articles (49)
-
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
Creating farms of unique websites
13 avril 2011, parMediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...) -
Problèmes fréquents
10 mars 2010, parPHP et safe_mode activé
Une des principales sources de problèmes relève de la configuration de PHP et notamment de l’activation du safe_mode
La solution consiterait à soit désactiver le safe_mode soit placer le script dans un répertoire accessible par apache pour le site
Sur d’autres sites (4354)
-
Concatenating audio files and superimposing over video
25 avril 2022, par kahI'm trying to write a program that takes a bunch of videos from a folder, compiles them, and then takes another bunch of audio files from a folder and concatenates them to then overlay the combined audio on top of the final video (hope that makes sense). I'm able to process the videos into one final output video, but I keep running into trouble combining the audio. Below I've provided two small sections of code pertaining to audio comp, I'm using moviepy to process the videos and attempting to use it for audio as well.


songDirectory = './songs/'
songList = []
songs = []
audioclip=''

def makeCompilation():
 for filename in os.listdir(songDirectory):
 f = os.path.join(songDirectory, filename)
 if os.path.isfile(f) and filename.endswith(".mp3"):
 audioclip = moviepy.editor.AudioFileClip(f)
 songList.append(filename)


 for song in os.listdir(songDirectory):
 c = os.path.join(songDirectory, song)
 audio_clips = moviepy.editor.AudioFileClip(c)
 audio_output = moviepy.editor.concatenate_audioclips(audio_clips)
 finalClip = concatenate_videoclips(videos, method="compose")
 final_duration = finalClip.duration 
 final_audio_output = audio_output.set_duration(final_duration)
 final_output= finalClip.set_audio(final_audio_output).fx(afx.audio_fadein, 3.0)


 audio_path = "./songs/tempaudiofile.m4a"

 #print(description)
 # Create compilation
 final_output.write_videofile(outputFile, threads=8, temp_audiofile=audio_path, remove_temp=True, codec="libx264", audio_codec="aac")

 return description



The program appeared to be able to find the audio directory, but I needed to be able to use os.path.join(songDirectory, filename) to point directly to each mp3 file so I messed around with it until I got the above code. And when I attempted to iterate through songList, I, as expected, got an error saying that 'str' wasn't iterable, and other errors saying that 'str' has no attribute 'duration'. Essentially, all I need it to do is iterate though the input folder and combine the files by whatever means. Code currently returns the output :


🌲Free Fredobagz x Aflacko x Flint type beat - 'Default_Dance' [prod. kah]-jro0v6ogZ0Y.mp4
225.05
Total Length: 225.05
225.05
Traceback (most recent call last):
 File "/Users/daddyK/Desktop/comp_ bot/make_compilation3.py", line 127, in <module>
makeCompilation(path = "./videos/",
 File "/Users/daddyK/Desktop/comp_ bot/make_compilation3.py", line 110, in makeCompilation
audio_output = moviepy.editor.concatenate_audioclips(audio_clips)
 File "/Users/daddyK/Library/Python/3.10/lib/python/site-packages/moviepy/audio/AudioClip.py", line 315, in concatenate_audioclips
durations = [c.duration for c in clips]
TypeError: 'AudioFileClip' object is not iterable
</module>



At this point I'm a bit stumped, so if anybody could offer some insight as to what I should do to resolve the error and/or if I'm headed in the right direction code-wise I'd greatly appreciate it ! Sorry if the code doesn't make any sense I'll post the whole .py file if needed


-
FFMPEG avoid_negative_ts makes video start not from keyframe
7 mars 2019, par Void FloydLet’s say I want to cut part of the mp4 video and resize it from 1280x720 to 854x480.
My command looks like this :
ffmpeg -ss 45 -i source.mp4 -ss 10 -to 20 \
-acodec aac -ar 44100 -ac 2 -c:v libx264 \
-crf 26 -vf scale=854:480:force_original_aspect_ratio=decrease,pad=854:480:0:0,setsar=1/1,setdar=16/9 \
-video_track_timescale 29971 -pix_fmt yuv420p \
-map_metadata 0 -avoid_negative_ts 1 -y dest.mp4The problem is, when I don’t use option
avoid_negative_ts
, resulting video has some issues with time bases etc, therefore it cannot be later converted by other libs, for example Swift’sAVFoundation
.But when I use this option - video does not start with keyframe.
By using ffprobe I seestart_time=0.065997
or other times other than 0.How can I use option
avoid_negative_ts
and have a video that starts with keyframe ? -
Why does ffmpeg not work with some files ?
18 février 2018, par Hollo1001I’m using FFmpeg and PHP to generate thumbnails from video and get their data. It seems to work ok, but some files just output no thumbnails and also no data(specs like time, height...). I have searched a lot online, but have not found anything like that. Have I missed something ? If you have an idea whats wrong, would be cool if you could help me and maybe others how might have such a problem.
Here is my PHP code for the specs :function _get_video_attributes($video, $ffmpeg) {
$command = $ffmpeg . ' -i ' . $video . ' -vstats 2>&1';
$output = shell_exec($command);
$regex_sizes = "/Video: ([^,]*), ([^,]*), ([0-9]{1,4})x([0-9]{1,4}), ([^,]*), ([0-9]{1,4})/"; // or : $regex_sizes = "/Video: ([^\r\n]*), ([^,]*), ([0-9]{1,4})x([0-9]{1,4})/"; (code from @1owk3y)
if (preg_match($regex_sizes, $output, $regs)) {
$codec = $regs [1] ? $regs [1] : null;
$width = $regs [3] ? $regs [3] : null;
$height = $regs [4] ? $regs [4] : null;
$fps = $regs [6] ? $regs [6] : null;
}
$regex_duration = "/Duration: ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}).([0-9]{1,2})/";
if (preg_match($regex_duration, $output, $regs)) {
$hours = $regs [1] ? $regs [1] : null;
$mins = $regs [2] ? $regs [2] : null;
$secs = $regs [3] ? $regs [3] : null;
$ms = $regs [4] ? $regs [4] : null;
}
return array('codec' => $codec,
'width' => $width,
'height' => $height,
'hours' => $hours,
'mins' => $mins,
'secs' => $secs,
'ms' => $ms,
'fps' => $fps,
);
}And the thumbs :
if($duration < 10){
$interval = floor($duration / 2);
$image = "thumb/".$filenopath."_thumb_".$num.".jpg";
shell_exec($ffmpeg." -ss ".$interval." -i ".$upfile." -vf select='eq(pict_type,I)' -vframes 1 -vf scale=-1:240 ".$thumb."00".$i.".jpg");
rename($image,"thumb/".$image);
}else{
for ($i = 1; $i <= 6; $i++) {
$interval = floor(($i - 0.5) * $duration / $i);
$log = $ffmpeg." -ss ".$interval." -i ".$upfile." -vf select='eq(pict_type,I)' -vframes 1 -vf scale=-1:240 ".$thumb."00".$i.".jpg".PHP_EOL;
//file_put_contents('./log'.date("j.n.Y").'.txt', $log, FILE_APPEND);
shell_exec($ffmpeg." -ss ".$interval." -i ".$upfile." -vf select='eq(pict_type,I)' -vframes 1 -vf scale=-1:240 ".$thumb."00".$i.".jpg");
}