Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Videos per Telegram

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Videos per Telegram

    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      spacemishka last edited by

      Hallo zusammen,

      ich möchte mit dem Telegram-Adapter Bilder und Videos von der Pi-Kamera versenden. Ersteres geht soweit.

      Aber die Videos schickt er nicht. Nachdem ich die die Video mit raspvid aufgenommen habe (Länge 10sek) werden diese mit MP4Box zu mp4 konvertiert.

      Hier das vollständige Skript:

      on({id: "telegram.0.communicate.request"/*Last received request*/, change: "any"}, function (obj) {
      var d = new Date();
          var curr_date = d.getDate();
          var curr_month = d.getMonth() + 1; //Months are zero based
          var curr_year = d.getFullYear();
          var curr_hour = d.getHours();
          var curr_min = d.getMinutes();
          //console.log(curr_date + "-" + curr_month + "-" + curr_year + '_'+curr_hour+curr_min);
          //var filename = curr_year +""+ curr_month +""+ curr_date + "_" + curr_hour+""+curr_min + ".jpg";
          //console.log(filename);
      
        if (getState("telegram.0.communicate.request").val.toLowerCase().search("picam") != -1 ) {
            var filename = curr_year +""+ curr_month +""+ curr_date + "_" + curr_hour+""+curr_min + ".jpg";
            exec ("raspistill -w 1920 -h 1080 -q 90 -o /home/pi/picam/" + filename + " > /home/pi/picam/picerr.log"); 
          setTimeout(function() {
        //your code to be executed after 1 second
                  //sendTo('telegram', "/home/pi/picam/" + filename);
                  sendTo('telegram.0', {
                          text:                   '/home/pi/picam/' + filename,
                          caption:                filename,
                          disable_notification:   true
                      });
      
          }, 8000);
        }
      
        if (getState("telegram.0.communicate.request").val.toLowerCase().search("pivid") != -1 ) {
            filename = curr_year +""+ curr_month +""+ curr_date + "_" + curr_hour+""+curr_min + ".h264 ";
            filenamefin = curr_year +""+ curr_month +""+ curr_date + "_" + curr_hour+""+curr_min + ".mp4 ";
            exec ("raspivid -o /home/pi/picam/" + filename + " -t 10000 -w 1280 -h 720 > /home/pi/picam/viderr.log"); 
            //raspivid -o video.h264 -t 10000
            exec ("MP4Box -add "+filename+" " + filenamefin);
            setTimeout(function() {
        //your code to be executed after 1 second
                  sendTo('telegram.0', {
                          text:                   '/home/pi/picam/' + filenamefin,
                          //upload_video:                   '/home/pi/picam/' + filenamefin,
                          caption:                filename,
                          disable_notification:   true
                      });
      
          }, 20000);
        }
      
      });
      
      

      Kann mir jemand einen Tip geben?

      Danke!!

      1 Reply Last reply Reply Quote 0
      • Bluefox
        Bluefox last edited by

        Dein Dateiname beinhaltet Leerzeichen am Ende. Und du musst Dateiname in "text" platzieren.

        1 Reply Last reply Reply Quote 0
        • S
          spacemishka last edited by

          Hallo,

          danke für den Hinweis mit den Leerzeichen. Der Dateiname ist aber doch dem Element 'text' zugewiesen. Analog wie bei den Bildern und da geht es ja,

          Grüße

          1 Reply Last reply Reply Quote 0
          • Bluefox
            Bluefox last edited by

            @spacemishka:

            Hallo,

            danke für den Hinweis mit den Leerzeichen. Der Dateiname ist aber doch dem Element 'text' zugewiesen. Analog wie bei den Bildern und da geht es ja,

            Grüße `
            Wenn du beliebiges bestehendes Video überträgst? Vielleicht sind 20 Sekunden zu kurz.

            1 Reply Last reply Reply Quote 0
            • S
              spacemishka last edited by

              Schein eher am Timing zu liegen. Die Nachricht wurde gesendet bevor das Video fertig verarbeitet wurde

              Damit geht es

              on({id: "telegram.0.communicate.request"/*Last received request*/, change: "any"}, function (obj) {
              var d = new Date();
                  var curr_date = d.getDate();
                  var curr_month = d.getMonth() + 1; //Months are zero based
                  var curr_year = d.getFullYear();
                  var curr_hour = d.getHours();
                  var curr_min = d.getMinutes();
              
                if (getState("telegram.0.communicate.request").val.toLowerCase().search("picam") != -1 ) {
                    var filename = curr_year +""+ curr_month +""+ curr_date + "_" + curr_hour+""+curr_min + ".jpg";
                    exec ("raspistill -q 90 -o /home/pi/picam/" + filename + " > /home/pi/picam/picerr.log"); 
                  setTimeout(function() {
                          sendTo('telegram.0', {
                                  text:                   '/home/pi/picam/' + filename,
                                  caption:                filename,
                                  disable_notification:   true
                              });
                  }, 6000);
                }
              
                if (getState("telegram.0.communicate.request").val.toLowerCase().search("pivid") != -1 ) {
                    filename = curr_year +""+ curr_month +""+ curr_date + "_" + curr_hour+""+curr_min + ".h264";
                    filenamefin = curr_year +""+ curr_month +""+ curr_date + "_" + curr_hour+""+curr_min + ".mp4";
                    setTimeout(function() {
                    exec ("raspivid -o /home/pi/picam/" + filename + " -t 10000 -w 1280 -h 720");
                    }, 1000);
              
                    setTimeout(function() {
                          exec ("MP4Box -add /home/pi/picam/"+filename+" /home/pi/picam/" + filenamefin + " >> vidconerr.log");
                          setTimeout(function() {
                              sendTo('telegram.0', {
                                      text:                   '/home/pi/picam/' + filenamefin,
                                      caption:                filenamefin,
                                      disable_notification:   true
                                  });
              
                          }, 4000);
                    }, 12000);
                }
              
              });
              
              
              1 Reply Last reply Reply Quote 0
              • First post
                Last post

              Support us

              ioBroker
              Community Adapters
              Donate

              436
              Online

              31.7k
              Users

              79.8k
              Topics

              1.3m
              Posts

              2
              5
              1517
              Loading More Posts
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes
              Reply
              • Reply as topic
              Log in to reply
              Community
              Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
              The ioBroker Community 2014-2023
              logo