Seite 1 von 1

Lua plugin camera with rtsp protocol

Verfasst: Fr 17. Mär 2023, 20:17
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

Re: Lua plugin camera with rtsp protocol

Verfasst: So 19. Mär 2023, 12:47
von jokel
did you write the plugin yourself ?
good idea ... vanhofen is his wish feasible ?

Re: Lua plugin camera with rtsp protocol

Verfasst: So 19. Mär 2023, 16:05
von vanhofen
Don't know.

Re: Lua plugin camera with rtsp protocol

Verfasst: Fr 24. Mär 2023, 15:54
von jaro44
it's a pity, there is no python, and lua is very limited :frowning2:

Re: Lua plugin camera with rtsp protocol

Verfasst: Fr 24. Mär 2023, 16:44
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/

Re: Lua plugin camera with rtsp protocol

Verfasst: Fr 24. Mär 2023, 19:19
von vanhofen
Höre auf, mich hier vors Loch zu schieben.

Re: Lua plugin camera with rtsp protocol

Verfasst: Fr 24. Mär 2023, 19:54
von jokel
yes sir
---
jaro44 ..
which camera do you have .. maybe it supports other protocols

Re: Lua plugin camera with rtsp protocol

Verfasst: Mo 27. Mär 2023, 10:02
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.

Re: Lua plugin camera with rtsp protocol

Verfasst: Mo 27. Mär 2023, 11:54
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.

Re: Lua plugin camera with rtsp protocol

Verfasst: Mo 27. Mär 2023, 17:52
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

Re: Lua plugin camera with rtsp protocol

Verfasst: Di 28. Mär 2023, 08:29
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 :(

Re: Lua plugin camera with rtsp protocol

Verfasst: Di 28. Mär 2023, 12:11
von jokel
search the internet ... for "camera curl command PLZ".
maybe you can configure and control your camera with it
with a bash-script ?