Recherche avancée

Médias (1)

Mot : - Tags -/pirate bay

Autres articles (103)

Sur d’autres sites (12642)

  • multipart/x-mixed-replace - MJPG video stream does not close in

    18 janvier 2024, par karlcess

    I'm using Node.js and React.
In React I have a simple component that is displayed on the screen when a button is clicked. The component is as follows :

    


    import React from &#x27;react&#x27;&#xA;&#xA;const Image = () => {&#xA;  return <img src="http://stackoverflow.com/api/mjpgStream/stream01" style='max-width: 300px; max-height: 300px' />;&#xA;}&#xA;&#xA;

    &#xA;

    Webpack redirects my requests (api=localhost:3456/mjpgStream/stream0).&#xA;In node I created an express server that when receiving the GET continuously sends JPEG images with multipart/x-mixed-replace. Below is the code :

    &#xA;

    const cb: RequestHandler = (req, res) => {&#xA;  const url = req.url.toString().slice(1);&#xA;  res.writeHead(200, {&#xA;    "Content-Type": "multipart/x-mixed-replace;boundary=&#x27;stream&#x27;",&#xA;    Connection: "keep-alive",&#xA;    Expires: "Fri, 27 May 1977 00:00:00 GMT",&#xA;    "Cache-Control": "no-cache, no-store, max-age=0, must-revalidate",&#xA;    Pragma: "no-cache",&#xA;  });&#xA;  let sub = PubSub.subscribe(url, function (msg: any, data: any) {&#xA;    res.write("--stream\r\n");&#xA;    res.write("Content-Type: image/jpeg\r\n");&#xA;    res.write("Content-Length: " &#x2B; data.length &#x2B; "\r\n");&#xA;    res.write("\r\n");&#xA;    res.write(data, "binary");&#xA;    res.write("\r\n");&#xA;  });&#xA;&#xA;  req.on("close", () => {&#xA;    PubSub.unsubscribe(sub);&#xA;    res.end();&#xA;  });&#xA;&#xA;  res.on("error", function (err) {&#xA;    console.error("Error in response:", err);&#xA;  });&#xA;};&#xA;&#xA;router.get(/\/[a-z,0-9]*/, cb);&#xA;

    &#xA;

    The video stream is published in the topic with PubSub and is correctly displayed in the Image component.&#xA;The problem is that when I click the button to close the Image component from the web page, the close event is not captured on the express server side and the mjpg flow continues to exist. I can't understand why.

    &#xA;

  • avcodec/cbs : Mark init and close functions as av_cold

    1er juillet 2022, par Andreas Rheinhardt
    avcodec/cbs : Mark init and close functions as av_cold
    

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

    • [DH] libavcodec/cbs.c
  • Close FFMPEG if connection with ipcam lost

    20 décembre 2023, par Gianluca

    this is my scrit that transmit a live camera rtsp stream to youtube rtmp stream.

    &#xA;&#xA;

    The Script before start verify if connection with camera is alive.

    &#xA;&#xA;

    The problem is during the process, if network connection lost ffmpeg remain in locked state.

    &#xA;&#xA;

    It's possibile to close ffmpeg or restart task if connection with camera lost ?

    &#xA;&#xA;

    :LOOP&#xA;timeout /t 10&#xA;ping 192.168.1.11&#xA;IF ERRORLEVEL 1 goto exit&#xA;IF ERRORLEVEL 0 goto START&#xA;:START&#xA;&#xA;ffmpeg  -f lavfi -i anullsrc -rtsp_transport tcp -i rtsp://192.168.1.11:10554/tcp/av0_0 -tune zerolatency -vcodec libx264 -t 12:00:00 -pix_fmt &#x2B; -c:v copy -c:a aac -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/(secret code)&#xA;&#xA;goto LOOP&#xA;

    &#xA;