Skip to content

Commit

Permalink
Add rtmp support
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenVD committed Feb 3, 2021
1 parent e2eddd1 commit b861869
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ read

#Install needed packages
sudo apt-get update
sudo apt-get install vlc sed coreutils fbset openssl procps python3-pygame python3-yaml python3-openssl python3 libraspberrypi-bin -y
sudo apt-get install vlc sed coreutils fbset ffmpeg openssl procps python3-pygame python3-yaml python3-openssl python3 libraspberrypi-bin -y

if ! is_vlc_mmal_present;then
echo "Your version of vlc does not have the needed mmal options. Rpisurv needs those"
Expand Down
14 changes: 13 additions & 1 deletion surveillance/core/CameraStream.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import sys
import io
import subprocess
import urllib.request, urllib.error, urllib.parse
from urllib.parse import urlparse

Expand Down Expand Up @@ -57,7 +58,7 @@ def __init__(self, name, camera_stream, drawinstance, display_hdmi_id):

self.obfuscated_credentials_url = self._manipulate_credentials_in_url("obfuscate")

if self.scheme not in ["rtsp", "http", "https", "file"]:
if self.scheme not in ["rtsp", "http", "https", "file", "rtmp"]:
logger.error("CameraStream: " + self.name + " Scheme " + self.scheme + " in " + self.obfuscated_credentials_url + " is currently not supported, you can make a feature request on https://community.rpisurv.net")
sys.exit()

Expand Down Expand Up @@ -97,6 +98,17 @@ def _urllib2open_wrapper(self):
return urllib.request.urlopen(request, timeout=self.probe_timeout)

def is_connectable(self):
if self.scheme == "rtmp":
try:
ffprobeoutput = subprocess.check_output(['/usr/bin/ffprobe', '-v', 'quiet', "-print_format", "flat", "-show_error", self.url], text=True, timeout=self.probe_timeout)
return True
except subprocess.TimeoutExpired as e:
logger.error(f"CameraStream: {self.name} {self.obfuscated_credentials_url} Not Connectable (ffprobe timed out, try increasing probe_timeout for this stream), configured timeout: {self.probe_timeout}")
return False
except Exception as e:
erroroutput_newlinesremoved=e.output.replace('\n', ' ')
logger.error(f"CameraStream: {self.name} {self.obfuscated_credentials_url} Not Connectable ({erroroutput_newlinesremoved}), configured timeout: {self.probe_timeout}")
return False
if self.scheme == "rtsp":
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Expand Down
2 changes: 1 addition & 1 deletion surveillance/surveillance.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def sigterm_handler(_signo, _stack_frame):
#Setup logger
logger = setup_logging()

fullversion_for_installer = "3.0.0-beta5"
fullversion_for_installer = "3.0.0-beta6"

version = fullversion_for_installer
logger.info("Starting rpisurv " + version)
Expand Down

0 comments on commit b861869

Please sign in to comment.