
Recherche avancée
Médias (1)
-
La conservation du net art au musée. Les stratégies à l’œuvre
26 mai 2011
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (64)
-
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 (...) -
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 -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir
Sur d’autres sites (7215)
-
How to match the video bitrate of opencv with ffmpeg ?
24 avril 2019, par user10890282I am trying to read three cameras simultaneously one of which is done through a video grabber card. I want to be able to stream the data and also write out videos from these sources. I used FFmpeg to write out the data from the video grabber card and OpenCV writer for the normal USB cameras. But the bit rates of the files do not match nor does the size. This becomes a problem as I post-process the files. I tried to convert the OpenCV written files using FFmpeg later but the duration of the files still remain different though the bit rates have changed. I really would appreciate pointers to know how to go about this from the script itself. The ideal case would be that I use FFmpeg for all the three sources with the same settings. But how can I do this without spitting out all the information on the console as writing out the files, since there would have to be three sources written out simultaneously ? Could someone tell me how to have multiple FFmpeg threads going on for writing out files while streaming videos using OpenCV ?
I have attached my current code with OpenCV writer and FFmpeg for one source :
from threading import Thread
import cv2
import time
import sys
import subprocess as sp
import os
import datetime
old_stdout=sys.stdout
maindir= "E:/Trial1/"
os.chdir(maindir)
maindir=os.getcwd()
class VideoWriterWidget(object):
def __init__(self, video_file_name, src=0):
if (src==3):
self.frame_name= "Cam_"+str(src)+"(Right)"
if(src==2):
self.frame_name= "Cam_"+str(src)+"(Left)"
# Create a VideoCapture object
#self.frame_name =str(src)
self.video_file = video_file_name+"_"
self.now=datetime.datetime.now()
self.ts=datetime.datetime.now()
self.video_file_nameE="{}.avi".format("Endo_"+self.ts.strftime("%Y%m%d_%H-%M-%S"))
self.video_file_name = "{}.avi".format(video_file_name+self.ts.strftime("%Y%m%d_%H-%M-%S"))
self.FFMPEG_BIN = "C:/ffmpeg/bin/ffmpeg.exe"
self.command=[self.FFMPEG_BIN,'-y','-f','dshow','-rtbufsize','1024M','-video_size','640x480','-i', 'video=Datapath VisionAV Video 01','-pix_fmt', 'bgr24', '-r','60', self.video_file_name]
self.capture = cv2.VideoCapture(src)
# Default resolutions of the frame are obtained (system dependent)
self.frame_width = int(self.capture.get(3))#480
self.frame_height = int(self.capture.get(4))# 640
# Set up codec and output video settings
if(src==2 or src==3):
self.codec = cv2.VideoWriter_fourcc('M','J','P','G')
self.output_video = cv2.VideoWriter(self.video_file_name, self.codec, 30, (self.frame_width, self.frame_height))
# Start the thread to read frames from the video stream
self.thread = Thread(target=self.update, args=(src,))
self.thread.daemon = True
self.thread.start()
# Start another thread to show/save frames
self.start_recording()
print('initialized {}'.format(self.video_file))
if (src==0):
self.e_recording_thread = Thread(target=self.endo_recording_thread, args=())
self.e_recording_thread.daemon = True
self.e_recording_thread.start()
print('initialized endo recording')
def update(self,src):
# Read the next frame from the stream in a different thread
while True:
if self.capture.isOpened():
(self.status, self.frame) = self.capture.read()
if (src==3):
self.frame= cv2.flip(self.frame,-1)
def show_frame(self):
# Display frames in main program
if self.status:
cv2.namedWindow(self.frame_name, cv2.WINDOW_NORMAL)
cv2.imshow(self.frame_name, self.frame)
# Press Q on keyboard to stop recording0000
key = cv2.waitKey(1)
if key == ord('q'):#
self.capture.release()
self.output_video.release()
cv2.destroyAllWindows()
exit(1)
def save_frame(self):
# Save obtained frame into video output file
self.output_video.write(self.frame)
def start_recording(self):
# Create another thread to show/save frames
def start_recording_thread():
while True:
try:
self.show_frame()
self.save_frame()
except AttributeError:
pass
self.recording_thread = Thread(target=start_recording_thread, args=())
self.recording_thread.daemon = True
self.recording_thread.start()
def endo_recording_thread(self):
self.Pr1=sp.call(self.command)
if __name__ == '__main__':
src1 = 'Your link1'
video_writer_widget1 = VideoWriterWidget('Endo_', 0)
src2 = 'Your link2'
video_writer_widget2 = VideoWriterWidget('Camera2_', 2)
src3 = 'Your link3'
video_writer_widget3 = VideoWriterWidget('Camera3_', 3)
# Since each video player is in its own thread, we need to keep the main thread alive.
# Keep spinning using time.sleep() so the background threads keep running
# Threads are set to daemon=True so they will automatically die
# when the main thread dies
while True:
time.sleep(5) -
Revision 106308 : Mine de rien, cette modification casse toutes les dépendances de saisies. ...
16 septembre 2017, par p@… — LogMine de rien, cette modification casse toutes les dépendances de saisies. Possible de faire plus de test avant de commit ? Voir aussi https://www.mail-archive.com/spip@rezo.net/msg72722.html
-
Revision 112273 : version 2.0.8 : ne pas tenter de détecter la version de PHP si on est ...
2 novembre 2018, par bruno@… — Logversion 2.0.8 : ne pas tenter de détecter la version de PHP si on est sur SPIP < 3.2
ref https://www.mail-archive.com/spip-zone@rezo.net/msg46459.html