
Recherche avancée
Autres articles (56)
-
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...) -
Emballe médias : à quoi cela sert ?
4 février 2011, parCe plugin vise à gérer des sites de mise en ligne de documents de tous types.
Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ; -
Menus personnalisés
14 novembre 2010, parMediaSPIP utilise le plugin Menus pour gérer plusieurs menus configurables pour la navigation.
Cela permet de laisser aux administrateurs de canaux la possibilité de configurer finement ces menus.
Menus créés à l’initialisation du site
Par défaut trois menus sont créés automatiquement à l’initialisation du site : Le menu principal ; Identifiant : barrenav ; Ce menu s’insère en général en haut de la page après le bloc d’entête, son identifiant le rend compatible avec les squelettes basés sur Zpip ; (...)
Sur d’autres sites (4983)
-
Trying to find a way to limit the number of List that can run at one time
14 mars 2024, par JakeMy application has a List of Tasks. Each Task launches a FFMPEG process that requires a lot of resources on my machine. At times, this list can contain 200+ processes to FFMPEG. While processing, my memory is at 99% and everything freezes up.


I need to limit the amount of processes that can run at one time. I have read a little about SemaphoreSlim ; however, I cannot wrap my mind around it's implementation.


Is this a solution for this particular problem and if so, any ideas on how to implement it in my code ?


Below is my code :


public async System.Threading.Tasks.Task GetVideoFiles()
{ 
 OpenFileDialog openFileDialog = new OpenFileDialog();
 openFileDialog.Multiselect = true;
 
 if (openFileDialog.ShowDialog() == true)
 {
 AllSplices.Clear();
 AllSplices = new ObservableCollection<splicemodel>();
 IsBusy = true;
 IsBusyMessage = "Extracting Metadata";
 IsBusyBackgroundVisible = "Visible";
 NotifyPropertyChanged(nameof(IsBusy));
 NotifyPropertyChanged(nameof(IsBusyMessage));
 NotifyPropertyChanged(nameof(IsBusyBackgroundVisible));
 metaTasks = new List>(); 
 extractFramesTask = new List();
 
 foreach (string file in openFileDialog.FileNames)
 {
 FileInfo fileInfo = new FileInfo(file);
 bool canAdd = true;
 var tempFileName = fileInfo.Name;
 
 foreach (var video in AllVideos)
 {
 if (file == video.VideoPath)
 {
 canAdd = false;
 break;
 }

 if (video.VideoName.Contains(tempFileName))
 {
 video.VideoName = "_" + video.VideoName; 
 } 
 }
 if (canAdd)
 { 
 metaTasks.Add(System.Threading.Tasks.Task.Run(() => ProcessMetaData(file))); 
 } 
 }
 var metaDataResults = await System.Threading.Tasks.Task.WhenAll(metaTasks); 
 
 foreach (var vid in metaDataResults)
 { 
 if(vid == null)
 {
 continue;
 }
 
 vid.IsNewVideo = true; 
 AllVideos.Add(vid);
 
 // This list of task launches up to 200 video processing processes to FFMPEG
 extractFramesTask.Add(System.Threading.Tasks.Task.Run(() => ExtractFrames(vid)));
 
 vid.IsProgressVisible = "Visible";
 TotalDuration += vid.VideoDuration;
 vid.NumberOfFrames = Convert.ToInt32(vid.VideoDuration.TotalSeconds * 30);
 _ = ReportProgress(vid);
 }
 
 IsBusyMessage = "Importing Frames";
 NotifyPropertyChanged(nameof(IsBusyMessage)); 
 await System.Threading.Tasks.Task.WhenAll(extractFramesTask); 
 }
</splicemodel>


-
Python 3 subprocess.popen() doesn't work on linux. Works on windows [closed]
30 avril 2021, par user2628458process = subprocess.Popen(
 cmd, shell=True,
 stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
 universal_newlines=True)
for line in process.stdout:
 # ...



I have this line that executes an FFmpeg job and throws out every line in the output to a variable. It works fine on Windows, but doesn't work at all on Linux. The
for
loop never gets executed. I can't find anything about this, or the difference between Windows and Linuxsubprocess.Popen()
. Can you please point me the right way to fix this ?

-
ffmpeg piped to python and displayed with cv2.imshow slides rightward and changes colors
10 septembre 2021, par MichaelCode :


import cv2
import time
import subprocess
import numpy as np

w,h = 1920, 1080
fps = 15

def ffmpegGrab():
 """Generator to read frames from ffmpeg subprocess"""
 cmd = f'.\\Resources\\ffmpeg.exe -f gdigrab -framerate {fps} -offset_x 0 -offset_y 0 -video_size {w}x{h} -i desktop -pix_fmt bgr24 -vcodec rawvideo -an -sn -f image2pipe -' 

 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 while True:
 raw_frame = proc.stdout.read(w*h*3)
 frame = np.fromstring(raw_frame, np.uint8)
 frame = frame.reshape((h, w, 3))
 yield frame

# Get frame generator
gen = ffmpegGrab()

# Get start time
start = time.time()

# Read video frames from ffmpeg in loop
nFrames = 0
while True:
 # Read next frame from ffmpeg
 frame = next(gen)
 nFrames += 1

 frame = cv2.resize(frame, (w // 4, h // 4))

 cv2.imshow('screenshot', frame)

 if cv2.waitKey(1) == ord("q"):
 break

 fps = nFrames/(time.time()-start)
 print(f'FPS: {fps}')


cv2.destroyAllWindows()



The code does display the desktop capture however the color format seems to switch and the video scrolls rightward as if it is repeated. Am I going about this in the correct way ?