📜 ⬆️ ⬇️

Organization of video broadcasting on the site

Hello.

Fighting traffic jams together


As part of this project in Krasnogorsk, we decided to install a pair of network cameras and make it convenient to view streaming video. Looking ahead, the result can be viewed on our website or from a mobile phone on wap www.ventumnet.ru/camera



There was some experience with Axis cameras, which, of course, are the flagships of the industry, but we stopped at a more budget option - D-Link DCS-2102 network cameras.
They cost around 4,000 rubles. For this money you get a decent picture and bitrate, and most importantly - access via the RTSP protocol, and immediately with a configured profile for viewing on mobile phones having an onboard player 3gp, in our case it was the Sony Ericsson T650i .
')

Implementation


For viewing convenience, the web decided to convert video online to flv using vlc running in vlm mode.
This is done like this:
  1. cvlc -I telnet --telnet-password your_password --rtsp-caching=1200 --video --no-sout-audio --udp-caching=30000 --http-caching=5000

    All caching options are chosen empirically, in your case they may be different.
    In principle, there is also sound from the cameras, but we don’t need it, therefore --no-sout-audio.
  2. Preparing the config /home/vlc/playlist.txt:

    new kamera4 broadcast enabled
    setup kamera4 input "rtsp://ip_address:554/mp4"
    setup kamera4 output #transcode{vcodec=FLV1,vb=2048,acodec=mp3,samplerate=22050}
    :std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:8084/stream4.flv}
    new kamera3 broadcast enabled
    setup kamera3 input "rtsp://ip_adress2:554/mp4"
    setup kamera3 output #transcode{vcodec=FLV1,vb=2048,acodec=mp3,samplerate=22050}
    :std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:8083/stream3.flv}
    control kamera4 play
    control kamera3 play


    Pay attention to the dst, the web server's built-in vlc ports are different, they could not be started on the same ones, although this is strange, and it is likely that in the next vlc releases it will be possible to distinguish streams only by the second part of the url, such as /stream1.flv /stream2.flv. .etc.
    Cameras are configured accordingly, give 2 megabits.

  3. # telnet localhost 4212
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    Password:
    Welcome, Master
    > load /home/vlc/playlist.txt
    > exit
    Connection closed by foreign host.

  4. Check, listen?

    # netstat -an | grep 808
    tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN
    tcp 0 0 0.0.0.0:8082 0.0.0.0:* LISTEN
    tcp 0 0 0.0.0.0:8083 0.0.0.0:* LISTEN
    tcp 0 0 0.0.0.0:8084 0.0.0.0:* LISTEN


  5. You can wget'nut.

    # wget "http://localhost:8084/stream4.flv"
    --2009-01-26 11:03:14-- localhost:8084/stream4.flv
    localhost... 127.0.0.1
    localhost|127.0.0.1|:8084... .
    HTTP , ... 200 OK
    : [video/x-flv]
    : `stream4.flv'.

    [ <=> ] 1 114 847 85,8K/s ^C

  6. JW FLV Player was used as a player.
    To get static pictures, not streaming video, I had to sign an NDA with D-Link in order to access the cameras via http. For reasons of the NDA, we will not provide a link, it is simply of the form kamera / cgi-bin / dai_mne_kartinuku_plz.cgi
  7. Along the way, we are doing a wap site where you can either look at the pictures or directly follow the link rtsp: // directly to the camera. At the same time we take with the gismeteo.ru weather in / tmp / temp and overlay it with

    convert $IMAGE_PATH/cam2_new.jpg -fill yellow -pointsize 22 -gravity "South" -dr
    aw "text -230,310 ' `cat /tmp/temp`°C'" $IMAGE_PATH/cam2_new.jpg


    The picture is 160x120, the bitrate is 256 kilobits / c, 5 fps, it looks quite to itself through GPRS.
  8. We place cameras on google maps.
  9. You can watch live at http://www.ventumnet.ru/live and via wap at www.ventumnet.ru/camera


Disadvantages:




The article was published in the sandbox, there was no reaction, so at the request of the author decided to post on his behalf. Accordingly, the author himself will respond to the comments (as far as possible) on my behalf.

Source: https://habr.com/ru/post/52190/


All Articles