
Recherche avancée
Médias (91)
-
Collections - Formulaire de création rapide
19 février 2013, par
Mis à jour : Février 2013
Langue : français
Type : Image
-
Les Miserables
4 juin 2012, par
Mis à jour : Février 2013
Langue : English
Type : Texte
-
Ne pas afficher certaines informations : page d’accueil
23 novembre 2011, par
Mis à jour : Novembre 2011
Langue : français
Type : Image
-
The Great Big Beautiful Tomorrow
28 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Texte
-
Richard Stallman et la révolution du logiciel libre - Une biographie autorisée (version epub)
28 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Texte
-
Rennes Emotion Map 2010-11
19 octobre 2011, par
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (112)
-
Script d’installation automatique de MediaSPIP
25 avril 2011, parAfin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
La documentation de l’utilisation du script d’installation (...) -
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...) -
La sauvegarde automatique de canaux SPIP
1er avril 2010, parDans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)
Sur d’autres sites (11990)
-
avutil/mips : Use MMI_{L, S}QC1 macro in {SAVE, RECOVER}_REG
23 juillet 2021, par Jiaxun Yangavutil/mips : Use MMI_L, SQC1 macro in SAVE, RECOVER_REG
SAVE,RECOVER_REG will be available for Loongson2 again,
also comment about the magic.Signed-off-by : Jiaxun Yang <jiaxun.yang@flygoat.com>
Reviewed-by : Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by : Michael Niedermayer <michael@niedermayer.cc> -
Python : ani.save very slow. Any alternatives to create videos ?
14 novembre 2023, par CzesklebaIm doing some simple diffusion calculations. I save 2 matrices to 2 datasets every so many steps (every 2s or so) to a single .h5 file. After that I then load the file in another script, create some figures (2 subplots etc., see/run code - i know could be prettier). Then I use matplotlib.animation to make the animation. In the code below, in the very last lines, I then run the ani.save command from matplotlib.


And that's where the problem is. The animation is created within 2 seconds, even for my longer animations (14.755 frames, done in under 2s at 8284 it/s) but after that, ani.save in line 144 takes forever (it didn't finish over night). It reserves/uses about 10gb of my RAM constantly but seemingly takes forever. If you run the code below be sure to set the frames_to_do (line 20) to something like 30 or 60 to see that it does in fact save an mp4 for shorter videos. You can set it higher to see how fast the time to save stuff increases to something unreasonable.


I've been fiddling this for 2 days now and I cant figure it out. I guess my question is : Is there any way to create the video in a reasonable time like this ? Or do I need something other than animation ?


You should be able to just run the code. Ill provide a diffusion_array.h5 with 140 frames so you dont have to create a dummy file, if I can figure out how to upload something like this safely. (The results are with dummy numbers for now, diffusion coefficients etc. are not right yet.)
I used dropbox. Not sure if thats allowed, if not I'll delete the link and uhh PM me or something ?




Here is the code :


import h5py
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
from matplotlib.animation import FuncAnimation
from tqdm import tqdm
import numpy as np


# saving the .mp4 after tho takes forever

# Create an empty figure and axis
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(16, 9), dpi=96)

# Load all saved arrays into a list
file_name = 'diffusion_array.h5'
loaded_u_arrays = []
loaded_h_arrays = []
frames_to_do = 14755 # for now like this, use # version once the slow mp4 convert is cleared up

# with h5py.File(file_name, 'r') as hf:
# for key in hf.keys():
# if key.startswith('u_snapshot_'):
# loaded_u_arrays.append(hf[key][:])
# elif key.startswith('h_snapshot_'):
# loaded_h_arrays.append(hf[key][:])

with h5py.File(file_name, 'r') as hf:
 for i in range(frames_to_do):
 target_key1 = f'u_snapshot_{i:05d}'
 target_key2 = f'h_snapshot_{i:05d}'
 if target_key1 in hf:
 loaded_u_arrays.append(hf[target_key1][:])
 else:
 print(f'Dataset u for time step {i} not found in the file.')
 if target_key2 in hf:
 loaded_h_arrays.append(hf[target_key2][:])
 else:
 print(f'Dataset h for time step {i} not found in the file.')

# Create "empty" imshow objects
# First one
norm1 = mcolors.Normalize(vmin=140, vmax=400)
cmap1 = plt.get_cmap('hot')
cmap1.set_under('0.85')
im1 = ax1.imshow(loaded_u_arrays[0], cmap=cmap1, norm=norm1)
ax1.set_title('Diffusion Heatmap')
ax1.set_xlabel('X')
ax1.set_ylabel('Y')
cbar_ax = fig.add_axes([0.05, 0.15, 0.03, 0.7])
cbar_ax.set_xlabel('$T$ / K', labelpad=20)
fig.colorbar(im1, cax=cbar_ax)


# Second one
ax2 = plt.subplot(1, 2, 2)
norm2 = mcolors.Normalize(vmin=-0.1, vmax=5)
cmap2 = plt.get_cmap('viridis')
cmap2.set_under('0.85')
im2 = ax2.imshow(loaded_h_arrays[0], cmap=cmap2, norm=norm2)
ax2.set_title('Diffusion Hydrogen')
ax2.set_xlabel('X')
ax2.set_ylabel('Y')
cbar_ax = fig.add_axes([0.9, 0.15, 0.03, 0.7])
cbar_ax.set_xlabel('HD in ml/100g', labelpad=20)
fig.colorbar(im2, cax=cbar_ax)

# General
fig.subplots_adjust(right=0.85)
time_text = ax2.text(-15, 0.80, f'Time: {0} s', transform=plt.gca().transAxes, color='black', fontsize=20)

# Annotations
# Heat 1
marker_style = dict(marker='o', markersize=6, markerfacecolor='black', markeredgecolor='black')
ax1.scatter(*[10, 40], s=marker_style['markersize'], c=marker_style['markerfacecolor'],
 edgecolors=marker_style['markeredgecolor'])
ann_heat1 = ax1.annotate(f'Temp: {loaded_u_arrays[0][40, 10]:.0f}', xy=[10, 40], xycoords='data',
 xytext=([10, 40][0], [10, 40][1] + 48), textcoords='data',
 arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=0.3"), fontsize=12, color='black')
# Heat 2
ax1.scatter(*[140, 85], s=marker_style['markersize'], c=marker_style['markerfacecolor'],
 edgecolors=marker_style['markeredgecolor'])
ann_heat2 = ax1.annotate(f'Temp: {loaded_u_arrays[0][85, 140]:.0f}', xy=[140, 85], xycoords='data',
 xytext=([140, 85][0] + 55, [140, 85][1] + 3), textcoords='data',
 arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=0.3"), fontsize=12, color='black')

# Diffusion 1
marker_style = dict(marker='o', markersize=6, markerfacecolor='black', markeredgecolor='black')
ax2.scatter(*[10, 40], s=marker_style['markersize'], c=marker_style['markerfacecolor'],
 edgecolors=marker_style['markeredgecolor'])
ann_diff1 = ax2.annotate(f'HD: {loaded_h_arrays[0][40, 10]:.0f}', xy=[10, 40], xycoords='data',
 xytext=([10, 40][0], [10, 40][1] + 48), textcoords='data',
 arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=0.3"), fontsize=12, color='black')
# Diffusion 2
ax2.scatter(*[140, 85], s=marker_style['markersize'], c=marker_style['markerfacecolor'],
 edgecolors=marker_style['markeredgecolor'])
ann_diff2 = ax2.annotate(f'HD: {loaded_h_arrays[0][85, 140]:.0f}', xy=[140, 85], xycoords='data',
 xytext=([140, 85][0] + 55, [140, 85][1] + 3), textcoords='data',
 arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=0.3"), fontsize=12, color='black')


# Function to update the animation
def update(frame, *args):
 loaded_u_array, loaded_h_array = args

 s_per_frame = 2 # during weld/cooling you save a state every 2s
 frames_to_room_temp = 7803 # that means this many frames need to be animated
 dt_big = 87 # during "just diffusion" you save every 10 frame but 87s pass in those

 # Update the time step shown
 if frame <= frames_to_room_temp:
 im1.set_data(loaded_u_array[frame])
 im2.set_data(loaded_h_array[frame])
 time_text.set_text(f'Time: {frame * s_per_frame} s')

 else:
 im1.set_data(loaded_u_array[frame])
 im2.set_data(loaded_h_array[frame])
 calc_time = int(((2 * frames_to_room_temp) + (frame - frames_to_room_temp) * 87) / 3600)
 time_text.set_text(f'Time: {calc_time} s')

 # Annotate some points
 ann_heat1.set_text(f'Temp: {loaded_u_arrays[frame][40, 10]:.0f}')
 ann_heat2.set_text(f'Temp: {loaded_u_arrays[frame][85, 140]:.0f}')
 ann_diff1.set_text(f'HD: {loaded_h_arrays[frame][40, 10]:.0f}')
 ann_diff2.set_text(f'HD: {loaded_h_arrays[frame][85, 140]:.0f}')

 return im1, im2 # Return the updated artists


# Create the animation without displaying it
ani = FuncAnimation(fig, update, frames=frames_to_do, repeat=False, blit=True, interval=1,
 fargs=(loaded_u_arrays, loaded_h_arrays)) # frames=len(loaded_u_arrays)

# Create the progress bar with tqdm
with tqdm(total=frames_to_do, desc='Creating Animation') as pbar: # total=len(loaded_u_arrays)
 for i in range(frames_to_do): # for i in range(len(loaded_u_arrays)):
 update(i, loaded_u_arrays, loaded_h_arrays) # Manually update the frame with both datasets
 pbar.update(1) # Update the progress bar

# Save the animation as a video file (e.g., MP4)
print("Converting to .mp4 now. This may take some time. This is normal, wait for Python to finish this process.")
ani.save('diffusion_animation.mp4', writer='ffmpeg', dpi=96, fps=60)

# Close the figure to prevent it from being displayed
plt.close(fig)




-
ffmpeg save mp3 file from available wss stream
11 juillet 2021, par phoenixAZIn a hello world node.js app I am succeeding in getting a feed from twilio conference and sending to the google speech to text. Concurrently I want to control recording to mp3 of the available audio stream (programmatically call start and stop). The was is subscribed to audio stream but I don't know how to attach ffmpeg to the local stream. I have tried :


// ffmpeg('rtsp://host:port/path/to/stream')
 //experimenting telling it to use the local stream
 //
 //ffmpeg(wss.addListener) //invlaid input error
 //ffmpeg(wss.stream) //thsi hits the console error below
 ffmpeg(wss.stream)
 .noVideo()
 .audioChannels(1)
 .audioBitrate(128)
 .duration('1:00')
 .on('end', function () { console.log('saved mp3'); })
 .on('error', function (err) { console.log('error mp3'); })
 .save('/path/to/output.mp3');



Any suggestions are welcomed. I am in a node.js project