Recherche avancée

Médias (1)

Mot : - Tags -/MediaSPIP 0.2

Autres articles (37)

  • Création définitive du canal

    12 mars 2010, par

    Lorsque votre demande est validée, vous pouvez alors procéder à la création proprement dite du canal. Chaque canal est un site à part entière placé sous votre responsabilité. Les administrateurs de la plateforme n’y ont aucun accès.
    A la validation, vous recevez un email vous invitant donc à créer votre canal.
    Pour ce faire il vous suffit de vous rendre à son adresse, dans notre exemple "http://votre_sous_domaine.mediaspip.net".
    A ce moment là un mot de passe vous est demandé, il vous suffit d’y (...)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La 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 (...)

  • Taille des images et des logos définissables

    9 février 2011, par

    Dans beaucoup d’endroits du site, logos et images sont redimensionnées pour correspondre aux emplacements définis par les thèmes. L’ensemble des ces tailles pouvant changer d’un thème à un autre peuvent être définies directement dans le thème et éviter ainsi à l’utilisateur de devoir les configurer manuellement après avoir changé l’apparence de son site.
    Ces tailles d’images sont également disponibles dans la configuration spécifique de MediaSPIP Core. La taille maximale du logo du site en pixels, on permet (...)

Sur d’autres sites (4797)

  • How to start and stop saving video frames according to a trigger with OpenCV VideoWriter

    11 août 2021, par Jacob nighFor

    I am building an app that records frames from IP camera through RTSP.

    



    My engine is in charge to save a video in mp4 with Opencv VideoWriter working well.
What I am looking for is to create a startRecord and a stopRecord class method that will respectively start and stop recording according to a trigger (it could be an argument that I pass to the thread).
Is anyone know what the best way to do that kind of stuff ?

    



    Here is my class :

    



    from threading import Thread
import cv2
import time
import multiprocessing
import threading
class RTSPVideoWriterObject(object):
    def __init__(self, src=0):
        # Create a VideoCapture object
        self.capture = cv2.VideoCapture(src)

        # Start the thread to read frames from the video stream
        self.thread = Thread(target=self.update, args=())
        self.thread.daemon = True
        self.thread.start()

    def update(self):
        # Read the next frame from the stream in a different thread
        while True:
            if self.capture.isOpened():
                (self.status, self.frame) = self.capture.read()

    def endRecord(self):
        self.capture.release()
        self.output_video.release()
        exit(1)

    def startRecord(self,endRec):

        self.frame_width = int(self.capture.get(3))
        self.frame_height = int(self.capture.get(4))
        self.codec = cv2.VideoWriter_fourcc(*'mp4v')
        self.output_video = cv2.VideoWriter('fileOutput.mp4', self.codec, 30, (self.frame_width, self.frame_height))
        while True:          
            try:
                self.output_video.write(self.frame)
                if endRec:
                    self.endRecord()
            except AttributeError:
                pass




if __name__ == '__main__':

    rtsp_stream_link = 'rtsp://foo:192.5545....'
    video_stream_widget = RTSPVideoWriterObject(rtsp_stream_link)

    stop_threads = False
    t1 = threading.Thread(target = video_stream_widget.startRecord, args =[stop_threads]) 
    t1.start() 
    time.sleep(15)
    stop_threads = True



    



    As you can see in the main I reading frames and store them in a separate thread. Then I am starting to record (record method is with an infinite loop so blocking) and then after 15 sec, I am trying to pass a 'stop_record' argument to stop recording properly.

    



    A part of the code comes from Storing RTSP stream as video file with OpenCV VideoWriter

    



    Is someone have an idea ?
I read a lot that OpenCV can be very tricky for multithreading

    



    N.

    


  • UDP Receiver needs to start before udp sender

    11 janvier 2020, par user27443

    I’m trying to send video from a raspberry pi 0w with camera running Raspian Buster to a machine running Ubuntu 18.04. I’m using ffmpeg to encode to h264 using hardware on the raspi end, and then sending the data with gst-launch-1.0 over UDP. The issue is that if I start the raspi stream, and then start the receiver, the receiver never connects. If I start the receiver and then start the raspi stream, then they connect perfectly.

    Raspi encode and send command :

    ffmpeg -f video4linux2 -framerate 30 -video_size 1280x720 -i /dev/video0 -c:v h264_omx -b:v 2000k -f avi pipe:1 | gst-launch-1.0 --gst-debug=3 fdsrc ! udpsink host=192.168.1.142 port=8090

    Receive and decode and display command :

    gst-launch-1.0 udpsrc port=8090 ! queue ! h264parse ! avdec_h264 ! xvimagesink sync=false

    I’ve looked at the udpsink and udpsrc properties and tried messing around with buffer-size, blocksize, and sync with no luck. I’ve also tried using ffmpeg from python to see if the issue was on the receiver side, with the exact same problem.

    import cv2

    cap = cv2.VideoCapture('udp://127.0.0.1:8090',cv2.CAP_FFMPEG)
    if not cap.isOpened():
       print('VideoCapture not opened')
       exit(-1)

    while True:
       ret, frame = cap.read()

       if not ret:
           print('frame empty')
           break

       cv2.imshow('image', frame)

       if cv2.waitKey(1)&0XFF == ord('q'):
           break

    cap.release()
    cv2.destroyAllWindows()

    In the end, I might just write a small protocol that toggles the sender if no packets are getting through, but I was hoping that UDP would handle the connection better.

    This question seemed simliar : UDP : Client started before Server but didn’t resolve my issue since I don’t have any blocking ability with gstreamer/ffmpeg.

  • Set correct start time of ts-file using ffmpeg

    9 octobre 2020, par Daniel

    I am splitting up a video into multiple 10 second ts-parts (mpeg-ts format) using ffmpeg on windows.

    



    To create the 2nd part (that starts at 10 seconds into the video and ends at 20 seconds into the video) :

    



    ffmpeg -i sample.avi -ss 00:00:10 -to 00:00:20 -vcodec libx264 -acodec aac -vf scale=426:-1 out1.ts


    



    But when i check the file using ffprobe it says :

    



    Duration: 00:00:10.02, start: 1.458667, bitrate: 359 kb/s


    



    So the duration is ok but the start time is incorrect. Is it anyway i can use ffmpeg to correct it to 00:00:20 ?
The best solution would of course to be able to set the correct start time in my first command where i take out the 10 second part but i would also be ok with running a 2nd command to fix the time.

    



    Is this possible ? Cant find any documentation and all examples i found are not for my exact problem and don't seem to work then i play around with them.

    



    Full output from ffprobe :

    



    ffprobe.exe out1.ts
ffprobe version git-2020-02-06-343ccfc Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 39.100 / 56. 39.100
  libavcodec     58. 68.100 / 58. 68.100
  libavformat    58. 38.100 / 58. 38.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 74.100 /  7. 74.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mpegts, from 'out1.ts':
  Duration: 00:00:10.02, start: 1.458667, bitrate: 359 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 426x260 [SAR 780:781 DAR 18:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 131 kb/s