NEWS
[VORLAGE] Kamerabild (Video) per RTSP an Telegram senden
-
Hallo Leute, nach langen hin und her mit doppelter Auslösung des Triggers habe ich nun das fertige Script um eure Kamerabilder per Telegram zu schicken.
Was ihr benötigt:
-Natürlich eine IP Kamera die RTSP kann. (bei mir sind es Reolink)
-FFMPEG (sudo apt install ffmpeg) -> bei Ubuntu
-Telegram Adapter der funktioniertVorgehensweise:
Ihr erstellt euch ein kleines Blockly Script Das ein Datenpunkt erstellt und darin führt ihr ein Script aus das ein Trigger enthällt.
Bei mir sind die Trigger ein Türsensor und zusätzlich noch per PING Adapter ob ich zuhause bin oder nicht.Das sieht dann so aus:
<xml xmlns="https://developers.google.com/blockly/xml"> <block type="create" id="8Fp@p0I-+~c5kK48_l6`" x="-1112" y="-562"> <field name="NAME">TuerAufundAbwesend</field> <statement name="STATEMENT"> <block type="on" id="sA4Gf~UX%4uq%);;v0$V"> <field name="OID">hmip.0.devices.3014F711A00000DA4994CFE9.channels.1.windowOpen</field> <field name="CONDITION">true</field> <field name="ACK_CONDITION"></field> <statement name="STATEMENT"> <block type="controls_if" id="@vvSHW`dSyDp*5Py~]C;"> <value name="IF0"> <block type="logic_compare" id="-,ceF]*Qsac[|e;x^pVD"> <field name="OP">EQ</field> <value name="A"> <block type="get_value" id=";Y6CJ$4[|h5F}kFV!V|Z"> <field name="ATTR">val</field> <field name="OID">ping.0.yves-Standard-PC-i440FX-PIIX-1996.YvesHandy</field> </block> </value> <value name="B"> <block type="logic_boolean" id="2||~b[D=_qTmGt@$GeK."> <field name="BOOL">FALSE</field> </block> </value> </block> </value> <statement name="DO0"> <block type="control" id="Y}9phZUiu1gsbXq#{Y=m"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">javascript.0.TuerAufundAbwesend</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="WA{o%~lN.wi!#w3c*j_k"> <field name="BOOL">TRUE</field> </block> </value> </block> </statement> </block> </statement> <next> <block type="on" id="PYyEK@qZ`MF_lKlI}g2O"> <field name="OID">hmip.0.devices.3014F711A00000DA4994CFE9.channels.1.windowOpen</field> <field name="CONDITION">false</field> <field name="ACK_CONDITION"></field> <statement name="STATEMENT"> <block type="controls_if" id="|y})zM3fEIURP!X.|htX"> <value name="IF0"> <block type="logic_compare" id="B[xABHjT{iGjP(N_Y!p{"> <field name="OP">EQ</field> <value name="A"> <block type="get_value" id="G%eX]tVzQI/6=+8o:8mL"> <field name="ATTR">val</field> <field name="OID">ping.0.yves-Standard-PC-i440FX-PIIX-1996.YvesHandy</field> </block> </value> <value name="B"> <block type="logic_boolean" id="E48C*];s[Po[5d1^8:h)"> <field name="BOOL">FALSE</field> </block> </value> </block> </value> <statement name="DO0"> <block type="control" id="USWCYV`7yr9][oHFN]@~"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">javascript.0.TuerAufundAbwesend</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="jd=-O:#oP4])dHY}8{+x"> <field name="BOOL">FALSE</field> </block> </value> </block> </statement> </block> </statement> </block> </next> </block> </statement> </block> </xml>
Dann kommt der Teil für die Aufnahme per RTSP und Telegram in ein neues Blockly Script.
Da ist bei mir oben der eben erstellte Datenpunkt und dann kommen bei mir 3 Kameras (ihr müsst euren eigenen RTSP Stream finden)
In den RTSP Code ist eine Aufnahmezeit die ihr ändern könnt. Direkt nach dem -t .....Dann kommt ein Timeout, welcher dazu dient, den System genug zeit zu geben das eben aufgenommene Video in eine mp4 Datei umzuwandeln und zu speichern.
Dann kommen meine 3 Telegram aktionen.
Das war schon alles
Das ist dann der Part hier:<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable type="timeout" id="timeout">timeout</variable> </variables> <block type="on" id="Fuhb%x!.((fMW[47N0b0" x="-1562" y="-1712"> <field name="OID">javascript.0.TuerAufundAbwesend</field> <field name="CONDITION">gt</field> <field name="ACK_CONDITION"></field> <statement name="STATEMENT"> <block type="exec" id="dDwB56u5^D[IqF26Vgz*"> <mutation xmlns="http://www.w3.org/1999/xhtml" with_statement="false"></mutation> <field name="WITH_STATEMENT">FALSE</field> <field name="LOG">log</field> <value name="COMMAND"> <shadow type="text" id="zSYV5{v;D#tJ|g%}oJf/"> <field name="TEXT">ffmpeg -y -i rtsp://admin:01384655@192.168.1.245:554/h264Preview_01_sub -t 10 -f mp4 -vcodec libx264 -pix_fmt yuv420p -an -vf scale=w=640:h=480:force_original_aspect_ratio=decrease -r 15 /opt/iobroker/cam1.mp4</field> </shadow> </value> <next> <block type="exec" id="x|`S-r/p=XcEM%n?`[:H"> <mutation xmlns="http://www.w3.org/1999/xhtml" with_statement="false"></mutation> <field name="WITH_STATEMENT">FALSE</field> <field name="LOG">log</field> <value name="COMMAND"> <shadow type="text" id="g)}F_tYNf27fXhs.*3Ou"> <field name="TEXT">ffmpeg -y -i rtsp://admin:01384655@192.168.1.246:554/h264Preview_01_sub -t 15 -f mp4 -vcodec libx264 -pix_fmt yuv420p -an -vf scale=w=640:h=480:force_original_aspect_ratio=decrease -r 15 /opt/iobroker/cam2.mp4</field> </shadow> </value> <next> <block type="exec" id="@ZtCCb=jt}s)(/oyYlrr"> <mutation xmlns="http://www.w3.org/1999/xhtml" with_statement="false"></mutation> <field name="WITH_STATEMENT">FALSE</field> <field name="LOG">log</field> <value name="COMMAND"> <shadow type="text" id="3447l}YWkET=Eb-K1@yc"> <field name="TEXT">ffmpeg -y -i rtsp://admin:01384655@192.168.1.247:554/h264Preview_01_sub -t 10 -f mp4 -vcodec libx264 -pix_fmt yuv420p -an -vf scale=w=640:h=480:force_original_aspect_ratio=decrease -r 15 /opt/iobroker/cam3.mp4</field> </shadow> </value> <next> <block type="timeouts_settimeout" id="t.8t4/CexnY;QFj6FRdE"> <field name="NAME">timeout</field> <field name="DELAY">35</field> <field name="UNIT">sec</field> <statement name="STATEMENT"> <block type="telegram" id="]ly{5FXKmZm|qp?@KSYL"> <field name="INSTANCE">.3</field> <field name="LOG">log</field> <field name="SILENT">FALSE</field> <field name="PARSEMODE">default</field> <value name="MESSAGE"> <shadow type="text" id="FxF3~=P%hRcVj_+is8E3"> <field name="TEXT">/opt/iobroker/cam1.mp4</field> </shadow> </value> <next> <block type="telegram" id=":u}fevbvVQC8wsMGc6u6"> <field name="INSTANCE">.3</field> <field name="LOG">log</field> <field name="SILENT">FALSE</field> <field name="PARSEMODE">default</field> <value name="MESSAGE"> <shadow type="text" id="@}p?|jkAj:;(Nqb@Fp~s"> <field name="TEXT">/opt/iobroker/cam2.mp4</field> </shadow> </value> <next> <block type="telegram" id="9n=0WAZ5bmk5qt@?}h=S"> <field name="INSTANCE">.3</field> <field name="LOG">log</field> <field name="SILENT">FALSE</field> <field name="PARSEMODE">default</field> <value name="MESSAGE"> <shadow type="text" id="07YvJAU]N0?3dni}h]m*"> <field name="TEXT">/opt/iobroker/cam3.mp4</field> </shadow> </value> </block> </next> </block> </next> </block> </statement> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </xml>
So nun viel spaß damit
-
@ymurawski Hallo, geht das auch unter Windows? Wo endet dein Kamerastream bei dem exec Befehl und was gehört zum Umwandeln?
Nach Windows Neustart funktioniert es jetzt so:
ffmpeg -y -i rtsp://192.168.1.59:554/live.sdp -t 10 -f mp4 -vcodec libx264 -pix_fmt yuv420p -an -vf scale=w=640:h=480:force_original_aspect_ratio=decrease -r 15 c:/cam1.mp4
-
Danke für dein Script , läuft super
-
@ritter
Hallo kann man die Auflösung auch höher einstellen ? -
@chucky666 Ich denke schon nur das Umwandeln wird dann länger dauern.
-
@ymurawski
Hallo
Ich habe jetzt auch 2 Reolink Kameras , so funktioniert alles . Und ist die Reaktion 2-3 Sekunden langsamer wie meine alte cam . Wie hast du dieses Problem gelöst ?
Gibt es die Möglichkeit 2-3 rückwirkend aufzunehmen?