-3

I get the RTSP URL but it cannot use in ReactJS player. The react player only supports HTTP URL, also the player does not support all the streaming.

The React player or in React JS cannot have any support in RTSP URL.

How to implement the live streaming from RTSP URL in react js

Jojo Joseph
  • 1,493
  • 1
  • 15
  • 12

1 Answers1

1

Setup a apache server and inside the /var/www/html/ create an index.html file

          <!DOCTYPE html>
           <html><head><title>Live Cam</title></head>

            <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
            <body>

            <video id="video" autoplay="true" width="975px" height="650px" 
             controls="controls"></video>
            <script>
            if (Hls.isSupported()) {
            var video = document.getElementById('video');
            var hls = new Hls();
            // bind them together
             hls.attachMedia(video);
             hls.on(Hls.Events.MEDIA_ATTACHED, function () {
              console.log("video and hls.js are now bound together !");
             hls.loadSource("'ip address of system'/live/mystream.m3u8");
             hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) {
             console.log("manifest loaded, found " + data.levels.length + " 
              quality level");
               });
              });
             }
            </script>

            </body>
             </html>

then create a live folder and inside the folder create a stream.sh file and insert the code #!/bin/bash

  VIDSOURCE="rtsp://username:password@192.168.140.14/h265/ch1/main/av_stream" 
         AUDIO_OPTS="-c:a aac -b:a 160000 -ac 2"
         VIDEO_OPTS="-s 854x480 -c:v libx264 -b:v 800000"
         OUTPUT_HLS="-hls_time 10 -hls_list_size 10 -start_number 1"
          ffmpeg -i "$VIDSOURCE" -y $AUDIO_OPTS $VIDEO_OPTS $OUTPUT_HLS 
         mystream.m3u8 

after creating the file run the apache server and run the above script by typing the command

        sudo ./stream.sh

after running the above server and file "IP address of system" run in the browser

you can get the live streaming

Jojo Joseph
  • 1,493
  • 1
  • 15
  • 12