Lua plugin camera with rtsp protocol

Antworten
Benutzeravatar
jaro44
Beiträge: 37
Registriert: Di 12. Apr 2016, 18:04
Wohnort: Polska
Box: tank, trinity duo, xsarius alpha hd

Lua plugin camera with rtsp protocol

Beitrag von jaro44 »

I'ts possible build lua with socket for this camera plugin to work?:

Code: Alles auswählen

-- Załadowanie biblioteki lua-socket
local socket = require("socket")

-- Określenie adresu IP kamery oraz portu RTSP
local camera_ip = "192.168.1.100"
local rtsp_port = 554

-- Wysłanie żądania DESCRIBE, aby uzyskać informacje o strumieniu
local describe_request = "DESCRIBE rtsp://" .. camera_ip .. ":" .. rtsp_port .. "/stream RTSP/1.0\r\n" ..
                         "CSeq: 1\r\n" ..
                         "Accept: application/sdp\r\n\r\n"
local describe_socket = assert(socket.connect(camera_ip, rtsp_port))
describe_socket:send(describe_request)

-- Odczytanie odpowiedzi od kamery
local describe_response = ""
while true do
    local chunk, status, partial = describe_socket:receive("*a")
    describe_response = describe_response .. (chunk or partial)
    if status == "closed" then
        break
    end
end

-- Wyodrębnienie adresu strumienia z odpowiedzi DESCRIBE
local stream_address = string.match(describe_response, "m=video%s+(.-)%s+")

-- Wysłanie żądania SETUP, aby nawiązać połączenie z kamery
local setup_request = "SETUP rtsp://" .. camera_ip .. ":" .. rtsp_port .. "/" .. stream_address .. " RTSP/1.0\r\n" ..
                      "CSeq: 2\r\n" ..
                      "Transport: RTP/AVP;unicast;client_port=5000-5001\r\n\r\n"
local setup_socket = assert(socket.connect(camera_ip, rtsp_port))
setup_socket:send(setup_request)

-- Odczytanie odpowiedzi od kamery
local setup_response = ""
while true do
    local chunk, status, partial = setup_socket:receive("*a")
    setup_response = setup_response .. (chunk or partial)
    if status == "closed" then
        break
    end
end

-- Wysłanie żądania PLAY, aby rozpocząć odtwarzanie strumienia
local play_request = "PLAY rtsp://" .. camera_ip .. ":" .. rtsp_port .. "/" .. stream_address .. " RTSP/1.0\r\n" ..
                     "CSeq: 3\r\n" ..
                     "Range: npt=0.000-\r\n\r\n"
local play_socket = assert(socket.connect(camera_ip, rtsp_port))
play_socket:send(play_request)

-- Odczytanie odpowiedzi od kamery
local play_response = ""
while true do
    local chunk, status, partial = play_socket:receive("*a")
    play_response = play_response .. (chunk or partial)
    if status == "closed" then
        break
    end
end

-- Otworzenie gniazda UDP do odbierania pakietów RTP
local udp_socket = assert(socket.udp())
udp_socket:setsockname("*", 5000)

-- Odbieranie i przetwarzanie pakietów RTP
while true do
    local data, ip, port = udp_socket:receivefrom()
    -- Tutaj można umieścić kod przetwarzający pakiet RTP
end
Benutzeravatar
jokel
Beiträge: 2390
Registriert: Mi 31. Mär 2021, 14:23
Box: ZGEMMA H7/C
Has thanked: 5 times
Been thanked: 5 times

Re: Lua plugin camera with rtsp protocol

Beitrag von jokel »

did you write the plugin yourself ?
good idea ... vanhofen is his wish feasible ?
Benutzeravatar
vanhofen
Administrator
Beiträge: 2924
Registriert: Di 5. Apr 2016, 00:05
Has thanked: 2 times
Been thanked: 10 times

Re: Lua plugin camera with rtsp protocol

Beitrag von vanhofen »

Don't know.
Benutzeravatar
jaro44
Beiträge: 37
Registriert: Di 12. Apr 2016, 18:04
Wohnort: Polska
Box: tank, trinity duo, xsarius alpha hd

Re: Lua plugin camera with rtsp protocol

Beitrag von jaro44 »

it's a pity, there is no python, and lua is very limited :frowning2:
Benutzeravatar
jokel
Beiträge: 2390
Registriert: Mi 31. Mär 2021, 14:23
Box: ZGEMMA H7/C
Has thanked: 5 times
Been thanked: 5 times

Re: Lua plugin camera with rtsp protocol

Beitrag von jokel »

do not despair right away, give vanhofen a little time. he also has to read up first ... see
https://lunarmodules.github.io/luasocket/
Benutzeravatar
vanhofen
Administrator
Beiträge: 2924
Registriert: Di 5. Apr 2016, 00:05
Has thanked: 2 times
Been thanked: 10 times

Re: Lua plugin camera with rtsp protocol

Beitrag von vanhofen »

Höre auf, mich hier vors Loch zu schieben.
Benutzeravatar
jokel
Beiträge: 2390
Registriert: Mi 31. Mär 2021, 14:23
Box: ZGEMMA H7/C
Has thanked: 5 times
Been thanked: 5 times

Re: Lua plugin camera with rtsp protocol

Beitrag von jokel »

yes sir
---
jaro44 ..
which camera do you have .. maybe it supports other protocols
Benutzeravatar
jaro44
Beiträge: 37
Registriert: Di 12. Apr 2016, 18:04
Wohnort: Polska
Box: tank, trinity duo, xsarius alpha hd

Re: Lua plugin camera with rtsp protocol

Beitrag von jaro44 »

jokel hat geschrieben: Fr 24. Mär 2023, 19:54 yes sir
---
jaro44 ..
which camera do you have .. maybe it supports other protocols
No, only rtsp.
so, I see that the neutrino has run out and this relic must be thrown into the trash.
It's time to invest in box with better support.
Thx and good luck.
Benutzeravatar
BPanther
NI - VIP
Beiträge: 745
Registriert: So 29. Sep 2019, 18:37
Kontaktdaten:

Re: Lua plugin camera with rtsp protocol

Beitrag von BPanther »

LUA is not needed, why not using webtv?!

Example:

Code: Alles auswählen

<webtv title="!RTSP-TEST" url="rtsp://wowzaec2demo.streamlock.net/vod/mp4%3ABigBuckBunny_115k.mp4" description=""/>
Works without problems.
Bild
Benutzeravatar
jokel
Beiträge: 2390
Registriert: Mi 31. Mär 2021, 14:23
Box: ZGEMMA H7/C
Has thanked: 5 times
Been thanked: 5 times

Re: Lua plugin camera with rtsp protocol

Beitrag von jokel »

BPanther hat geschrieben: Mo 27. Mär 2023, 11:54 LUA is not needed, why not using webtv?!

Example:

Code: Alles auswählen

<webtv title="!RTSP-TEST" url="rtsp://wowzaec2demo.streamlock.net/vod/mp4%3ABigBuckBunny_115k.mp4" description=""/>
Works without problems.
good alternative ...
i also have an ip camera and will experiment with ffmpeg
neutrino still has many possibilities to offer
Benutzeravatar
jaro44
Beiträge: 37
Registriert: Di 12. Apr 2016, 18:04
Wohnort: Polska
Box: tank, trinity duo, xsarius alpha hd

Re: Lua plugin camera with rtsp protocol

Beitrag von jaro44 »

BPanther hat geschrieben: Mo 27. Mär 2023, 11:54 LUA is not needed, why not using webtv?!

Example:

Code: Alles auswählen

<webtv title="!RTSP-TEST" url="rtsp://wowzaec2demo.streamlock.net/vod/mp4%3ABigBuckBunny_115k.mp4" description=""/>
Works without problems.
Of course BP, it works, but there are no configuration options as if it were possible in a plugin :(
Benutzeravatar
jokel
Beiträge: 2390
Registriert: Mi 31. Mär 2021, 14:23
Box: ZGEMMA H7/C
Has thanked: 5 times
Been thanked: 5 times

Re: Lua plugin camera with rtsp protocol

Beitrag von jokel »

search the internet ... for "camera curl command PLZ".
maybe you can configure and control your camera with it
with a bash-script ?
Antworten

Zurück zu „Neutrino allgemein“