
Recherche avancée
Médias (1)
-
Richard Stallman et le logiciel libre
19 octobre 2011, par
Mis à jour : Mai 2013
Langue : français
Type : Texte
Autres articles (39)
-
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs -
Taille des images et des logos définissables
9 février 2011, parDans beaucoup d’endroits du site, logos et images sont redimensionnées pour correspondre aux emplacements définis par les thèmes. L’ensemble des ces tailles pouvant changer d’un thème à un autre peuvent être définies directement dans le thème et éviter ainsi à l’utilisateur de devoir les configurer manuellement après avoir changé l’apparence de son site.
Ces tailles d’images sont également disponibles dans la configuration spécifique de MediaSPIP Core. La taille maximale du logo du site en pixels, on permet (...) -
Configuration spécifique d’Apache
4 février 2011, parModules spécifiques
Pour la configuration d’Apache, il est conseillé d’activer certains modules non spécifiques à MediaSPIP, mais permettant d’améliorer les performances : mod_deflate et mod_headers pour compresser automatiquement via Apache les pages. Cf ce tutoriel ; mode_expires pour gérer correctement l’expiration des hits. Cf ce tutoriel ;
Il est également conseillé d’ajouter la prise en charge par apache du mime-type pour les fichiers WebM comme indiqué dans ce tutoriel.
Création d’un (...)
Sur d’autres sites (7121)
-
ffmpeg - how can I scale the video while perserving the total frames in it ?
14 juin 2018, par chozI have a video with a size of
515 x 755
, that I would like to resize proportionally to206 x 302
(so, factor is2.5
).In this video, I have the total of 588 frames, and I use
ffmpeg
to scale it, with this command.ffmpeg -i video.mp4 -vf scale=206:-1 xRotation_206.mp4
And I use this to check how many frames are there in the video, based on this answer.
ffmpeg -i video.mp4 -map 0:v:0 -c copy -f null - 2>&1 | awk '/frame=/ {print $2}'
The original video frames is good (588 frames). But, after resizing with the command above, my converted video now has 604 frames.
The question is, how can I resize the video by preserving the total frames in it ? It doesn’t really have to be
ffmpeg
approach, and any suggestion is appreciated.Here’s the sample video that I use : Link
-
ffmpeg concatenating videos of different fps while keeping the total length not changed
23 novembre 2017, par A_MatarI wanna pad an
mp4
video stream with another video clip of a static image that I created using :def generate_white_vid (duration):
output_filename = os.path.join(p_path,'white_vid_'+" 0:.2f}".format(duration)+'.mp4')
ffmpeg_create_vid_from_static_img = 'ffmpeg -loop 1 -i /path/WhiteBackground.jpg -c:v libx264 -t %f -pix_fmt yuv420p -vf scale=1920:1080 %s' % (duration, output_filename)
p = subprocess.Popen(ffmpeg_create_vid_from_static_img, shell=True)
p.communicate()
return output_filenameI use the following to concatenate :
def concat_vids(clip_paths):
filenames_txt = open('clips_to_join.txt','w')
for clip in clip_paths:
filenames_txt.write ('file \''+ clip+'\'\n')
filenames_txt.close()
output_filename = clip_paths[0].split('.', 2)[0]
output_file_path = os.path.join(root_path, output_filename+'-padded.mp4')
# join the clips
ffmpeg_command = ["ffmpeg", "-f", "concat", "-safe", "0", "-i", "clips_to_join.txt", "-codec", "copy", output_file_path] # output_filename = ch0X-start_time-end_time
p = subprocess.Popen(ffmpeg_command)
p.communicate() # wait till the subprocess finishes. You can send commands to process as well.
return output_file_pathWhen I check the length of the resulting video after concatenation, I find that it is not equal to the sum of the two segments that I concatenated, and sometimes it is even less by some seconds !!
Here is how I get the video length in seconds :
def ffmpeg_len(vid_path):
'''
Returns length in seconds using ffmpeg
'''
ffmpeg_get_mediafile_length = ['sh', '-c', 'ffmpeg -i "$1" 2>&1 | grep Duration', '_', vid_path]
p = subprocess.Popen(ffmpeg_get_mediafile_length, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, err = p.communicate()
length_regexp = 'Duration: (\d{2}):(\d{2}):(\d{2})(\.\d+),'
re_length = re.compile(length_regexp)
matches = re_length.search(output)
if matches:
video_length = int(matches.group(1)) * 3600 + \
int(matches.group(2)) * 60 + \
int(matches.group(3)) + float(matches.group(4))
return video_length
else:
print("Can't determine video length.")
print err
raise SystemExitMy guess is that maybe the concatenation unifies the
fps
rate for the all the clips to be joined, if this is the case, how to prevent this from happening ? How can I get a video of the desired length exactly.Maybe it worth mentioning that the video to padded is very short
0.42 second
, the original video is210.58
and the resultant video is210.56
!I have verified that ffmpeg does generate the desired padding region and it is of the desired length
0.42
I got a 0.43 segment when I forced30 fps
but it is okay. -
Restart ffmpeg process using monit if TOTAL CPU is less than 1%
28 mai 2017, par user2201239I have used kind of similar solution like this Restarting ffmpeg process using monit to restart my ffmpeg stream in case it fails for some reason. Remember its not duplicate problem/question, because I have other issues unlike the example question/solution Restarting ffmpeg process using monit, which I’m gonna explain below. So here is my monit configuration :
check process FFMPEGStream with pidfile PATH-to-file/streampid.pid
start program = "PATH-to-file/streambash.sh restart"
stop program = "PATH-to-file/streambash.sh stop"
if TOTAL CPU is less than 1% for 10 cycles then restartHere is my streambash.sh file :
#!/bin/bash
pid_file="PATH-to-file/streampid.pid"
case "$1" in
restart)
PATH-to-file/streambash.sh stop
PATH-to-file/streambash.sh start
;;
start)
rm $pid_file
/usr/bin/ffmpeg -i "INPUT-PATH" -c:v libx264 -b:v 900k -preset ultrafast -aspect 16:9 -s 640x376 -strict experimental -c:a aac -b:a 96k -f flv "RTMP-PATH" &> /dev/null &
ch_pid=$!
echo "Start Stream1: ffmpeg = $ch_pid";
echo $ch_pid > $pid_file
;;
stop)
echo "Stop ffmpeg Stream1";
kill `cat $pid_file` &> /dev/null
;;
*)
echo "Usage: PATH-to-file/streambash.sh {start|stop|restart}"
exit 1
;;
esac
exit 0
echo $pid_fileMonit can start the bash file successfully, but when this condition "if TOTAL CPU is less than 1% for 10 cycles then restart" is matched in monit configuration, it tries to restart, it gives error that process is not running. But in actual the ffmpeg process still runs in the background and I can see that the stream is live on my website. Here is monit logs :
[CET Jan 10 12:55:02] error : 'FFMPEGStream' total cpu usage of 0.4% matches resource limit [cpu usage>1.0%]
[CET Jan 10 12:55:07] error : 'FFMPEGStream' total cpu usage of 0.0% matches resource limit [cpu usage>1.0%]
[CET Jan 10 12:55:12] error : 'FFMPEGStream' total cpu usage of 0.0% matches resource limit [cpu usage>1.0%]
[CET Jan 10 12:55:17] error : 'FFMPEGStream' total cpu usage of 0.4% matches resource limit [cpu usage>1.0%]
[CET Jan 10 12:55:22] error : 'FFMPEGStream' total cpu usage of 0.9% matches resource limit [cpu usage>1.0%]
[CET Jan 10 12:55:27] error : 'FFMPEGStream' total cpu usage of 0.9% matches resource limit [cpu usage>1.0%]
[CET Jan 10 12:55:32] error : 'FFMPEGStream' total cpu usage of 0.0% matches resource limit [cpu usage>1.0%]
[CET Jan 10 12:55:37] error : 'FFMPEGStream' total cpu usage of 0.0% matches resource limit [cpu usage>1.0%]
[CET Jan 10 12:55:42] error : 'FFMPEGStream' total cpu usage of 0.0% matches resource limit [cpu usage>1.0%]
[CET Jan 10 12:55:47] error : 'FFMPEGStream' total cpu usage of 0.4% matches resource limit [cpu usage>1.0%]
[CET Jan 10 12:55:50] info : 'FFMPEGStream' trying to restart
[CET Jan 10 12:55:50] info : 'FFMPEGStream' stop: PATH-to-file/streambash.sh
[CET Jan 10 12:55:51] info : 'FFMPEGStream' start: PATH-to-file/streambash.sh
[CET Jan 10 12:55:56] error : 'FFMPEGStream' process is not running
[CET Jan 10 12:55:58] info : 'FFMPEGStream' trying to restart
[CET Jan 10 12:55:58] info : 'FFMPEGStream' start: PATH-to-file/streambash.sh
[CET Jan 10 12:56:04] error : 'FFMPEGStream' process is not running
[CET Jan 10 12:56:04] info : 'FFMPEGStream' trying to restart
[CET Jan 10 12:56:04] info : 'FFMPEGStream' start: PATH-to-file/streambash.sh
[CET Jan 10 12:56:09] error : 'FFMPEGStream' process is not running
[CET Jan 10 12:56:09] info : 'FFMPEGStream' trying to restart
[CET Jan 10 12:56:09] info : 'FFMPEGStream' start: PATH-to-file/streambash.shMonit keeps trying to restart the process and on each retry, it dumps a new pid to the PATH-to-file/streampid.pid, but as I said it seems, it somehow can stop the actual ffmpeg stream/pid, which keep running in the background.