
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)
-
ffmpeg crash when updating overlay file (c# console app)
24 décembre 2024, par Vlad StefanI am trying to develop a console app that can record the screen and have cpu/ram/gpu usage of the machine noted on the recording. The problem i am facing is that after a while (2-3 hours) the recording stops because ffmpeg is trying to read the file text while my C# code tries to update the file. I managed to find out that I should use a temp file and replace the original instead of rewriting the whole file but that way I encounter another problem, ffmpeg will try to read the file while the file is replaced or even for that split second when is considered deleted. Any ideas what I should do ? How should the method with the temp file be managed or how can I make the method that updates the same file stable ? I was even thinking to increment the ffmpeg reload frames since it might narrow the chances of crashing but it's not a 100% crash proof solution.


Error message received from ffmpeg with updating only the text from the file :


Error: [Parsed_drawtext_0 @ 000001e68fd95dc0] [FILE @ 0000009fb7ffee70] Error occurred in CreateFileMapping()
Error: [Parsed_drawtext_0 @ 000001e68fd95dc0] The text file 'OverlayFiles/OverlayFile_MyPC.txt' could not be read or is empty
Error: [vf#0:0 @ 000001e68fd48300] Error while filtering: Operation not permitted
Error: [vf#0:0 @ 000001e68fd48300] Task finished with error code: -1 (Operation not permitted)



Error message received from ffmpeg with the use of a temp file that's replacing the original file :


Error: [Parsed_drawtext_0 @ 0000014c815e6200] [FILE @ 000000253d7fee70] Cannot read file 'OverlayFiles/OverlayFile_MyPC.txt': Permission denied
Error: [Parsed_drawtext_0 @ 0000014c815e6200] The text file 'OverlayFiles/OverlayFile_MyPC.txt' could not be read or is empty
Error: [vf#0:0 @ 0000014c81597280] Error while filtering: Permission denied
Error: [vf#0:0 @ 0000014c81597280] Task finished with error code: -13 (Permission denied)
Error: [vf#0:0 @ 0000014c81597280] Terminating thread with return code -13 (Permission denied)



ffmpeg arguments :


string arguments = $"-video_size 1920x1080 -framerate 30 -f gdigrab -i desktop -c:v libx264rgb -crf 0 -preset ultrafast -color_range 2 " +
 $"-vf \"drawtext=fontfile=C\\\\:/Windows/fonts/consola.ttf:fontsize=30:fontcolor='white':textfile={overlayFilePath_}:boxcolor=0x00000080:box=1:x=10:y=H-210:reload=1\" \"" + 
 outputFile + "\"";



The code that updates the overlay file (1st version) :


public void UpdateOverlayText(string filePath)
{
 string usage = GetSystemUsage(filePath); // Get the system usage data

 try
 {
 // Open the file with FileShare.ReadWrite to allow other processes to read it while writing
 using (var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
 {
 using (var writer = new StreamWriter(fileStream))
 {
 writer.Write(usage); // Write the system usage data to the file
 }
 }

 // Ensure file permissions are set correctly after writing
 SetFilePermissions(filePath);
 }
 catch (IOException ex)
 {
 Console.WriteLine($"Error updating overlay file: {ex.Message}");
 }
}



(UPDATE)Code that updates overlay file using MemoryStream :


public void UpdateOverlayText(string filePath)
{
 string usage = GetSystemUsage(filePath);

 try
 {
 using (var memoryStream = new MemoryStream())
 {
 using (var writer = new StreamWriter(memoryStream))
 {
 writer.Write(usage);
 writer.Flush();

 memoryStream.Position = 0;

 File.WriteAllBytes(filePath, memoryStream.ToArray());
 }
 }

 SetFilePermissions(filePath);
 }
 catch (IOException ex)
 {
 Console.WriteLine($"Error updating overlay file: {ex.Message}");
 }
}



Code tested using MemoryStream and Temp file :


public void UpdateOverlayText(string filePath)
{
 string usage = GetSystemUsage(filePath);
 string tempFilePath = filePath + ".tmp";
 try
 {
 // Write to a temporary file first
 using (var memoryStream = new MemoryStream())
 {
 using (var writer = new StreamWriter(memoryStream))
 {
 writer.Write(usage);
 writer.Flush();

 memoryStream.Position = 0;
 File.WriteAllBytes(tempFilePath, memoryStream.ToArray());
 }
 }
 File.Replace(tempFilePath, filePath, null);
 }
 catch (IOException ex)
 {
 Console.WriteLine($"Error updating overlay file: {ex.Message}");
 }
 finally
 {
 if (File.Exists(tempFilePath))
 {
 File.Delete(tempFilePath);
 }
 }
}



Thanks in advance for your help and sorry for any typo or wrong phrases I used.


-
ValueError : Image size of 100010x50004 pixels is too large. It must be less than 2^16 in each direction
3 avril 2021, par SlowI am using
matplotlib.pyplot
to plot an animation video from data files.
Below is my code, I am getting this error each time I run the code.



ValueError : Image size of 100010x50004 pixels is too large. It must be
less than 2^16 in each direction.




According to some suggestions, I have restarted my kernel and update it, but still getting this issue.


import matplotlib
matplotlib.use('Qt5Agg')
from matplotlib.animation import FFMpegWriter
import matplotlib.pyplot as plt
import numpy as np
import readArray as ra
# import polygon as poly

def fieldMovie( fid, sx, sy, dt):
 """
 save the field and vesicle deformation movie
 
 input: 
 fid: name
 sx, sy: coordinates
 dt: time step

 Returns
 -------
 None.

 """
 # sx = ra.readArray('sx.afdat')
 # sy = ra.readArray('sy.afdat') 
 xbon = ra.readArray('xbound.afdat')
 ybon = ra.readArray('ybound.afdat')
 
 Tend = int(len(sx)/1)
 m = 1350
 n = 135
 x = np.arange(0, m)
 y = np.arange(0, n)
 X, Y = np.meshgrid(x, y)
 
 metadata = dict(title='field', artist='Matplotlib', 
 comment='draw field')
 writer = FFMpegWriter(fps=7, metadata=metadata)
 
 fig = plt.figure(figsize=(10, 5))
 with writer.saving(fig, fid, Tend):
 for i in range(0, 9999, 2):
 time = dt*i
 fig.clf()
 sx_this = sx[i]
 sx_this = np.r_[sx_this, [sx_this[0,:]]]
 sy_this = sy[i]
 sy_this = np.r_[sy_this, [sy_this[0,:]]]
 sx_min = np.min(sx_this, axis=0)
 sx_this = sx_this - np.floor(sx_min/m)*m
 
 plt.fill(sx_this, sy_this, 'r', linewidth=1.5)
 sx_this = sx_this - m
 plt.fill(sx_this, sy_this, 'r', linewidth=1.5)
 plt.plot(xbon, ybon, '.' ,color = 'k' , markersize=1.0)
 plt.axis('equal')
 plt.axis('on')
 plt.xlim(0, m-1)
 title1 = 'test '
 title2 = 'at T = %.4f s, Ht = 18%%' % time
 plt.title(title1+title2, fontsize=16, fontweight='bold')
 ax = plt.gca()
 ax.set_position([0.05, 0.05, 0.8, 0.85])
 plt.pause(0.1)
 writer.grab_frame()
 plt.axes().set_aspect('equal')
 
sx = ra.readArray('sx.afdat')
sy = ra.readArray('sy.afdat')
dt = 0.002 * 1.5e-7 / 0.0003 * 700001 / 10000
fieldMovie('Animation.mp4', sx, sy, dt)



-
Add Meta-Data to OpenCV VideoWriter as it records
29 avril 2016, par Kells1986I have some simple code that records video at 3 frames per second using
openCV 2.4
. The code is running on a Raspberry Pi, which is going to be powered by a battery for about 5 minutes before it will die.Because the Raspberry Pi dies the video recording does not terminate gracefully, and it seems that the meta-data isn’t written to the file properly.
mplayer
is capable of playing the file back, but what I would like to do is post-process the video in some existing software. In order to be able to do that the software needs to extract the number of frames in the video from the meta-data, which it cannot do at present.Is there anyway of forcing
openCV
to write the meta-data as it records ? Or can I getmplayer
/ffmpeg
to fill in the gaps later ?Here is the code that records the video :
VideoCapture cap(0); // open the default camera
cap.set(CV_CAP_PROP_FPS, fps);
cap.set(CV_CAP_PROP_FRAME_WIDTH, 1280);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 720);
if(!cap.isOpened()) // check if we succeeded
return -1;
Mat testFrame;
cap >> testFrame;
cap >> testFrame;
cap >> testFrame;
Size outSize = Size(testFrame.cols, testFrame.rows);
VideoWriter writer(filename, CV_FOURCC('M','J','P','G'), fps, outSize, true);
int count = 0;
for(; ;)
{
Mat frame;
cap >> frame; // get a new frame from camera
writer.write(frame);
}