
Recherche avancée
Médias (1)
-
The pirate bay depuis la Belgique
1er avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
Autres articles (79)
-
Organiser par catégorie
17 mai 2013, parDans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...) -
Récupération d’informations sur le site maître à l’installation d’une instance
26 novembre 2010, parUtilité
Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer le (...) -
Emballe Médias : Mettre en ligne simplement des documents
29 octobre 2010, parLe plugin emballe médias a été développé principalement pour la distribution mediaSPIP mais est également utilisé dans d’autres projets proches comme géodiversité par exemple. Plugins nécessaires et compatibles
Pour fonctionner ce plugin nécessite que d’autres plugins soient installés : CFG Saisies SPIP Bonux Diogène swfupload jqueryui
D’autres plugins peuvent être utilisés en complément afin d’améliorer ses capacités : Ancres douces Légendes photo_infos spipmotion (...)
Sur d’autres sites (7271)
-
Anomalie #4345 : super_cron HS en https
11 juin 2019, par jluc -Voici le nouveau .diff avec tout : "supercron v2"
- le port 443 et le préfixe ssl :// pour fsockopen si on en est https
- les logs d’échecs de connexion et de fsockopen
- le timestamp sur l’url pour bypasser les caches -
Anomalie #2910 : Erreur 404 après redirection après message forum ds un site avec URLs arbo.
8 janvier 2013, par Joachim SENEMoi, j’ai le problème en Spip 3.0.5. … mais je vais vérifier sur d’autres spip 3.0.5 que j’ai de côté, en les configurant avec le même type d’URL… pour voir. merci.
-
How to efficiently store variable frame rate video stream in a pyqt application ?
1er octobre 2024, par Jeroen De GeeterI am developing a PyQT (PySide6) application that needs to display and store multiple camera streams at the same time. The display of the camera streams goes well, however, storing these streams seems to slow down the application significantly up to a point where the GUI doesn't work fluently anymore.


I have a minimal working example using a stub to demonstrate how my code currently works. However, given that it is a minimal working example, it will not visibly slow down.


import sys
from time import sleep

import av
import numpy as np
import pyqtgraph as pg
from PySide6.QtCore import QThread, Signal, Slot, Qt
from PySide6.QtWidgets import QApplication, QHBoxLayout, QWidget, QVBoxLayout, QPushButton, QGroupBox


class RGBCameraStub(QThread):

 newFrame = Signal(np.ndarray)

 def __init__(self):
 super().__init__()
 self.killSwitch = True

 def stop(self):
 self.killSwitch = False
 self.quit()
 self.wait()

 def run(self):
 self.killSwitch = True
 while self.killSwitch:
 self.newFrame.emit((np.random.rand(1456, 1080, 3) * 255).astype(np.uint8))
 sleep((20 + int(np.random.rand() * 30))/ 1000)


class VideoWriter(QThread):

 def __init__(self):
 super().__init__()
 self.output_container = av.open('output_video.mkv', mode='w')
 self.stream = self.output_container.add_stream('ffv1', rate=None)
 self.stream.width = 1456
 self.stream.height = 1080
 self.stream.pix_fmt = 'yuv420p'

 @Slot(np.ndarray)
 def addFrame(self, frame: np.ndarray):
 av_frame = av.VideoFrame.from_ndarray(frame, format='rgb24')
 av_frame.pts = None # Leave emtpy for auto-handling - variable framerate?
 for packet in self.stream.encode(av_frame):
 self.output_container.mux(packet)

 def stop(self):
 self.output_container.close()
 self.quit()
 self.wait()

 def run(self):
 self.exec()


class VideoBox(QGroupBox):

 def __init__(self, title):
 super().__init__(title=title)
 self.createLayout()
 self.videoWidget.setImage((np.random.rand(1456, 1080, 3) * 255).astype(np.uint8))

 def createLayout(self):
 layout = QVBoxLayout()
 self.videoWidget = pg.RawImageWidget()
 layout.addWidget(self.videoWidget)
 self.setLayout(layout)
 self.setStyleSheet("""QGroupBox {
 border: 1px solid #494B4F;
 margin-top: 8px;
 min-width: 180px;
 min-height: 180px;
 padding: 2px 0px 0px 0px;
 }
 QGroupBox::title {
 color: #aeb0b8;
 subcontrol-origin: margin;
 subcontrol-position: top left;
 left: 20px;
 padding: 0 8px;
 }""")

 def setImage(self, data: np.ndarray):
 self.videoWidget.setImage(data)

class MainWindow(QWidget):

 closeSignal = Signal()

 def __init__(self):
 super().__init__()
 self.setGeometry(0, 0, 900, 720)
 self.createLayout()

 def createLayout(self):
 self.vimbaImage = VideoBox("RGB")
 self.info = self.infoLayout()

 layout = QVBoxLayout()
 layout.addWidget(self.vimbaImage)
 layout.addWidget(self.info)
 self.setLayout(layout)

 self.setAttribute(Qt.WA_StyledBackground, True)
 self.setStyleSheet("MainWindow { background-color: #1e1f22; }")

 def infoLayout(self):
 widget = QWidget()
 layout = QVBoxLayout()

 rgbButtonWidget = QWidget()
 buttonLayout = QHBoxLayout()
 self.connectButton = QPushButton('Connect', parent=self)
 self.disconnectButton = QPushButton('Disconnect', parent=self)
 buttonLayout.addWidget(self.connectButton)
 buttonLayout.addWidget(self.disconnectButton)
 buttonLayout.addStretch()
 rgbButtonWidget.setLayout(buttonLayout)
 layout.addWidget(rgbButtonWidget)

 widget.setLayout(layout)
 return widget

 def closeEvent(self, event):
 self.closeSignal.emit()
 event.accept()



if __name__ == "__main__":
 app = QApplication(sys.argv)

 rgbCamera = RGBCameraStub()
 videoWriter = VideoWriter()
 videoWriter.start()

 main_window = MainWindow()

 # Button connections
 main_window.connectButton.clicked.connect(rgbCamera.start)
 main_window.disconnectButton.clicked.connect(rgbCamera.stop)
 # main_window.disconnectButton.clicked.connect(videoWriter.stop)

 # Display frames
 rgbCamera.newFrame.connect(main_window.vimbaImage.setImage)

 # Write frame to file
 rgbCamera.newFrame.connect(videoWriter.addFrame)

 # Close application
 main_window.closeSignal.connect(rgbCamera.stop)
 main_window.closeSignal.connect(videoWriter.stop)

 main_window.show()
 sys.exit(app.exec())




My question(s) therefore are :


- 

- How can I increase the performance of the
VideoWriter
? I am currently adding frame by frame as soon as the camera thread provides a new frame. Maybe this is not the best approach ? - The frame rate of the camera is not completely stable, I therefore set
av_frame.pts = None
but maybe this is also not the approach to take ? - With code as is, the resulting media file quickly blows up in size, is there a way of dealing with this without quality loss ?








As a side not, I currently use the PyAV wrapper for the FFmpeg libraries, however I am open to other suggestions.


- How can I increase the performance of the