Recherche avancée

Médias (0)

Mot : - Tags -/metadatas

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (95)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

  • Problèmes fréquents

    10 mars 2010, par

    PHP et safe_mode activé
    Une des principales sources de problèmes relève de la configuration de PHP et notamment de l’activation du safe_mode
    La solution consiterait à soit désactiver le safe_mode soit placer le script dans un répertoire accessible par apache pour le site

Sur d’autres sites (4973)

  • avcodec/ffv1dec : Switch to ProgressFrames

    2 septembre 2022, par Andreas Rheinhardt
    avcodec/ffv1dec : Switch to ProgressFrames
    

    Avoids implicit av_frame_ref() and therefore allocations
    and error checks. It also avoids explicitly allocating
    the AVFrames (done implicitly when getting the buffer).

    It also fixes a data race : The AVFrame's sample_aspect_ratio
    is currently updated after ff_thread_finish_setup()
    and this write is unsynchronized with the read in av_frame_ref().
    Removing the implicit av_frame_ref() fixed this.

    Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

    • [DH] libavcodec/ffv1.h
    • [DH] libavcodec/ffv1dec.c
  • Monitoring for failure and quickly restarting systemd service

    16 février 2024, par mzrt

    I am running a 24/7 youtube stream on Ubuntu. My ffmpeg command is wrapped in a systemd service. On several occasions the ffmpeg command has failed and systemd has not restarted quickly enough to keep the youtube stream alive. When this happens I need to daemon-reload and restart the systemd service.

    &#xA;

    To counter this I have written a bash script that checks the log for stream ending errors, however, it does not seem to be working. I have had failures since implementing this script, and it did not seem to have been triggered.

    &#xA;

    two questions :

    &#xA;

      &#xA;
    1. is there a more efficient way to do what I am doing ?
    2. &#xA;

    3. if not, can anyone identify what I am doing wrong ?
    4. &#xA;

    &#xA;

    #!/bin/bash&#xA;&#xA;RESET=0&#xA;&#xA;while true; do&#xA;    # Get the current time minus 1 minute&#xA;    LAST_1_MINUTE=$(date -d &#x27;1 minute ago&#x27; &#x27;&#x2B;%b %e %H:%M:%S&#x27;)&#xA;    &#xA;    # Run the command to check for the error within the last minute&#xA;    if journalctl --since "$LAST_1_MINUTE" | grep -qi "Error writing trailer"; then&#xA;        if [ $RESET -lt 1 ]; then&#xA;            # Perform actions if error is detected&#xA;            sudo systemctl daemon-reload &amp;&amp; \&#xA;            echo "Restarting master.service by monitor.sh script at $(date)" >> /var/log/monitor.log &amp;&amp; \&#xA;            sudo systemctl restart master.service&#xA;            RESET=2&#xA;        fi&#xA;    else&#xA;        RESET=$((RESET - 1))&#xA;    fi&#xA;&#xA;    # Wait for 20 seconds before the next iteration&#xA;    sleep 20&#xA;done&#xA;

    &#xA;

  • Efficiently Fetching the Latest Frame from a Live Stream using OpenCV in Python

    10 juillet 2023, par Nicolantonio De Bari

    Problem :

    &#xA;

    I have a FastAPI server that connects to a live video feed using cv2.VideoCapture. The server then uses OpenCV to process the frames for object detection and sends the results to a WebSocket. Here's the relevant part of my code :

    &#xA;

    class VideoProcessor:&#xA;    # ...&#xA;&#xA;    def update_frame(self, url):&#xA;        logger.info("update_frame STARTED")&#xA;        cap = cv2.VideoCapture(url)&#xA;        while self.capture_flag:&#xA;            ret, frame = cap.read()&#xA;            if ret:&#xA;                frame = cv2.resize(frame, (1280, 720))&#xA;                self.current_frame = frame&#xA;            else:&#xA;                logger.warning("Failed to read frame, retrying connection...")&#xA;                cap.release()&#xA;                time.sleep(1)&#xA;                cap = cv2.VideoCapture(url)&#xA;&#xA;    async def start_model(self, url, websocket: WebSocket):&#xA;        # ...&#xA;        threading.Thread(target=self.update_frame, args=(url,), daemon=True).start()&#xA;        while self.capture_flag:&#xA;            if self.current_frame is not None:&#xA;                frame = cv2.resize(self.current_frame, (1280, 720))&#xA;                bbx = await self.process_image(frame)&#xA;                await websocket.send_text(json.dumps(bbx))&#xA;                await asyncio.sleep(0.1)&#xA;

    &#xA;

    Currently, I'm using a separate thread (update_frame) to continuously fetch frames from the live feed and keep the most recent one in self.current_frame.

    &#xA;

    The issue with this method is that it uses multi-threading and continuously reads frames in the background, which is quite CPU-intensive. The cv2.VideoCapture.read() function fetches the oldest frame in the buffer, and OpenCV does not provide a direct way to fetch the latest frame.

    &#xA;

    Goal

    &#xA;

    I want to optimize this process by eliminating the need for a separate thread and fetching the latest frame directly when I need it. I want to ensure that each time I process a frame in start_model, I'm processing the most recent frame from the live feed.

    &#xA;

    I have considered a method of continuously calling cap.read() in a tight loop to "clear" the buffer, but I understand that this is inefficient and can lead to high CPU usage.

    &#xA;

    Attempt :

    &#xA;

    What I then tried to do is use ffmpeg & subprocess to get the latest frame, but I dont seem to understand how to get the latest frame then.

    &#xA;

    async def start_model(self, url, websocket: WebSocket):&#xA;    try:&#xA;        logger.info("Model Started")&#xA;        self.capture_flag = True&#xA;&#xA;        command = ["ffmpeg", "-i", url, "-f", "image2pipe", "-pix_fmt", "bgr24", "-vcodec", "rawvideo", "-"]&#xA;        pipe = subprocess.Popen(command, stdout=subprocess.PIPE, bufsize=10**8)&#xA;&#xA;        while self.capture_flag:&#xA;            raw_image = pipe.stdout.read(1280*720*3)  # read 720p frame (BGR)&#xA;            if raw_image == b&#x27;&#x27;:&#xA;                logger.warning("Failed to read frame, retrying connection...")&#xA;                await asyncio.sleep(1) # delay for 1 second before retrying&#xA;                continue&#xA;            &#xA;            frame = np.fromstring(raw_image, dtype=&#x27;uint8&#x27;)&#xA;            frame = frame.reshape((720, 1280, 3))&#xA;            if frame is not None:&#xA;                self.current_frame = frame&#xA;                frame = cv2.resize(self.current_frame, (1280, 720))&#xA;                bbx = await self.process_image(frame)&#xA;                await websocket.send_text(json.dumps(bbx))&#xA;                await asyncio.sleep(0.1)&#xA;                &#xA;        pipe.terminate()&#xA;&#xA;    except WebSocketDisconnect:&#xA;        logger.info("WebSocket disconnected during model operation")&#xA;        self.capture_flag = False  # Ensure to stop the model operation when the WebSocket disconnects&#xA;

    &#xA;

    Question

    &#xA;

    Is there a more efficient way to fetch the latest frame from a live stream using OpenCV in Python ? Can I modify my current setup to get the newest frame without having to read all the frames in a separate thread ?&#xA;Or is there another library that I could use ?

    &#xA;

    I know a similar question has been asked, but not related to video streaming.

    &#xA;