Commit 9a2434d6 authored by Jeffery's avatar Jeffery

Signed-off-by: Jeffery <shuochen.tw@ecom.com.tw>

parents
# rpi-node
portainer:
image: portainer/portainer
ports:
- "9000:9000"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "portainer_data:/data"
restart: always
container_name: portainer
\ No newline at end of file
FROM raspbian/jessie
RUN apt update
RUN apt install -y python3-dev python3-pip
RUN rm -r /var/lib/apt/lists/*
RUN pip3 install --upgrade pip
RUN pip3 install websocket-client==0.40.0
RUN pip3 install docker
RUN pip3 install paho-mqtt
COPY run.py run.py
CMD python3 run.py
\ No newline at end of file
dev tun
tls-client
remote 211.72.168.104 2294
# The "float" tells OpenVPN to accept authenticated packets from any address,
# not only the address which was specified in the --remote option.
# This is useful when you are connecting to a peer which holds a dynamic address
# such as a dial-in user or DHCP client.
# (Please refer to the manual of OpenVPN for more information.)
#float
# If redirect-gateway is enabled, the client will redirect it's
# default network gateway through the VPN.
# It means the VPN connection will firstly connect to the VPN Server
# and then to the internet.
# (Please refer to the manual of OpenVPN for more information.)
#redirect-gateway def1
# dhcp-option DNS: To set primary domain name server address.
# Repeat this option to set secondary DNS server addresses.
#dhcp-option DNS DNS_IP_ADDRESS
pull
# If you want to connect by Server's IPv6 address, you should use
# "proto udp6" in UDP mode or "proto tcp6-client" in TCP mode
proto udp
script-security 2
reneg-sec 0
cipher AES-256-CBC
auth SHA512
auth-user-pass auth
auth-nocache
<ca>
-----BEGIN CERTIFICATE-----
MIIDdTCCAl2gAwIBAgIJAJIASyu6ASDjMA0GCSqGSIb3DQEBCwUAMFExCzAJBgNV
BAYTAlRXMQ8wDQYDVQQHDAZUYWlwZWkxFjAUBgNVBAoMDVN5bm9sb2d5IEluYy4x
GTAXBgNVBAMMEFN5bm9sb2d5IEluYy4gQ0EwHhcNMTgxMjIxMDgxNjQwWhcNMzgw
OTA3MDgxNjQwWjBRMQswCQYDVQQGEwJUVzEPMA0GA1UEBwwGVGFpcGVpMRYwFAYD
VQQKDA1TeW5vbG9neSBJbmMuMRkwFwYDVQQDDBBTeW5vbG9neSBJbmMuIENBMIIB
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsMtiB7wRiUFaB/+p2IcSAMY5
3xYUyaS3C18fU+CAT1r4/nzFPmVoGGkS5kUu9J+28myp+TnvUaW8kJOxY7JXaLGN
0R+dfExOJGWEtJbxCVb6x5gLSXoF+6OgLF88ARlzjXGR7w/EZ8ybNRqkLOh1SQ1a
z2dUEjjSi26z5NrT1qsI+5f6kvGn0RsemJUnIEZaF+PhNnU0f31KPrhqPV0YDKBf
AhUXFNpM+wI7zVH/FZ7fyHNp+hhpJ/li7KmBDmspblqUK8/ee1kkGcQa2MmwnCzn
lGk8lORti/labbGtRv7tFAyN76Ih40oXvSQDQInmC5Nr2TFAKDQ/0Mfx93x/hQID
AQABo1AwTjAdBgNVHQ4EFgQUYSaPPld2EvS90nbNCD6PUhDz4kUwHwYDVR0jBBgw
FoAUYSaPPld2EvS90nbNCD6PUhDz4kUwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0B
AQsFAAOCAQEAHAafRNz48FzKWtEZTt6W6PVlTOqURf99+NR4P+IJvtVhczBkz4f8
vA+mapNaWn7rBmX05Ytuar8Cq/sYzEVGK1O7/6Vargyve0bOD328DWFbsiQcfENf
yDBPZvgK7wbyaHEWpQ9AqEd9hL6jisA4xs0cycsYhZ0qdXYHhfTUyeus2awSLkqC
rBSfwkCpmjSCaJQuePjRQo3M9fA3h8cAajml4GLYuOhGf/4zUwoBgeC89uRbsVeV
6xGJ8rUZ77cIGkncrYx/8pnk6hjoiilExo0HdsyTgn12qjNmODH/5HgZK+WUT+GF
xy86sARTVSusds3+8K68T6gpE5MYwUrKgQ==
-----END CERTIFICATE-----
</ca>
version: '2'
services:
viewer:
build: ./socat
env_file:
- dvr.env
ports:
- "80:80"
networks:
lan:
ipv4_address: 10.0.0.2
restart: always
container_name: viewer
ftp_cmd:
build: ./socat
environment:
- REMOTE_IP=192.168.5.20
- REMOTE_PORT=21
- LOCAL_PORT=21
ports:
- "21:21"
networks:
lan:
ipv4_address: 10.0.0.3
restart: always
container_name: ftp_cmd
ftp_data_1:
build: ./socat
environment:
- REMOTE_IP=192.168.5.20
- REMOTE_PORT=55536
- LOCAL_PORT=55536
ports:
- "55536:55536"
networks:
lan:
ipv4_address: 10.0.0.4
restart: always
container_name: ftp_data_1
ftp_data_2:
build: ./socat
environment:
- REMOTE_IP=192.168.5.20
- REMOTE_PORT=55537
- LOCAL_PORT=55537
ports:
- "55537:55537"
networks:
lan:
ipv4_address: 10.0.0.5
restart: always
container_name: ftp_data_2
ftp_data_3:
build: ./socat
environment:
- REMOTE_IP=192.168.5.20
- REMOTE_PORT=55538
- LOCAL_PORT=55538
ports:
- "55538:55538"
networks:
lan:
ipv4_address: 10.0.0.6
restart: always
container_name: ftp_data_3
srs3:
build: ./srs
networks:
lan:
ipv4_address: 10.0.0.7
command: ./objs/srs -c conf/edge.conf
restart: always
container_name: srs3
ch0:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=0
- SRS_CH=0
links:
- srs3
networks:
lan:
ipv4_address: 10.0.0.10
restart: always
container_name: ch00
ch1:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=1
- SRS_CH=1
links:
- ch0
networks:
lan:
ipv4_address: 10.0.0.11
restart: always
container_name: ch01
ch2:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=7
- SRS_CH=2
links:
- ch1
networks:
lan:
ipv4_address: 10.0.0.12
restart: always
container_name: ch02
ch3:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=4
- SRS_CH=3
links:
- ch2
networks:
lan:
ipv4_address: 10.0.0.13
restart: always
container_name: ch03
ch4:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=6
- SRS_CH=4
links:
- ch3
networks:
lan:
ipv4_address: 10.0.0.14
restart: always
container_name: ch04
ch5:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=8
- SRS_CH=5
links:
- ch4
networks:
lan:
ipv4_address: 10.0.0.15
restart: always
container_name: ch05
ch6:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=3
- SRS_CH=6
links:
- ch5
networks:
lan:
ipv4_address: 10.0.0.16
restart: always
container_name: ch06
ch7:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=2
- SRS_CH=7
links:
- ch6
networks:
lan:
ipv4_address: 10.0.0.17
restart: always
container_name: ch07
ch8:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=8
- SRS_CH=8
links:
- ch7
networks:
lan:
ipv4_address: 10.0.0.18
restart: always
container_name: ch8
ch9:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=9
- SRS_CH=9
links:
- ch8
networks:
lan:
ipv4_address: 10.0.0.19
restart: always
container_name: ch9
ch10:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=10
- SRS_CH=10
links:
- ch9
networks:
lan:
ipv4_address: 10.0.0.20
restart: always
container_name: ch10
ch11:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=11
- SRS_CH=11
links:
- ch10
networks:
lan:
ipv4_address: 10.0.0.21
restart: always
container_name: ch11
ch12:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=12
- SRS_CH=12
links:
- ch11
networks:
lan:
ipv4_address: 10.0.0.22
restart: always
container_name: ch12
ch13:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=13
- SRS_CH=13
links:
- ch12
networks:
lan:
ipv4_address: 10.0.0.23
restart: always
container_name: ch13
ch14:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=14
- SRS_CH=14
links:
- ch13
networks:
lan:
ipv4_address: 10.0.0.24
restart: always
container_name: ch14
ch15:
build: ./ffmpeg
env_file:
- dvr.env
environment:
- DVR_TYPE=main
- DVR_CH=15
- SRS_CH=15
links:
- ch14
networks:
lan:
ipv4_address: 10.0.0.25
restart: always
container_name: ch15
networks:
lan:
driver: bridge
ipam:
driver: default
config:
- subnet: 10.0.0.0/24
gateway: 10.0.0.254
\ No newline at end of file
{
'DVR_HOST' : '192.168.2.199',
'DVR_USER' : 'taoyuan0',
'DVR_PSWD' : 'ecom2828',
'DVR_TAG' : 'tyc0',
'SRS_HOST' : '192.168.5.200',
'SRS_PORT' : '1935',
'LOCAL_PORT' : '80',
'REMOTE_IP' : '192.168.2.199',
'REMOTE_PORT' : '80',
}
\ No newline at end of file
FROM raspbian/jessie
RUN apt-get update
RUN apt-get install -y git make build-essential pkg-config python3-dev python3-pip
RUN rm -r /var/lib/apt/lists/*
RUN pip3 install --upgrade pip
RUN pip3 install pexpect
RUN git clone git://git.videolan.org/x264 /usr/src/x264
WORKDIR /usr/src/x264
RUN ./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl
RUN make
RUN make install
RUN git clone git://source.ffmpeg.org/ffmpeg.git /usr/src/ffmpeg
WORKDIR /usr/src/ffmpeg
RUN ./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree
RUN make
RUN make install
RUN pip3 install paho-mqtt
ENV TZ=Asia/Taipei
COPY run.py run.py
CMD python3 run.py
\ No newline at end of file
import paho.mqtt.client as mqtt, subprocess as sp, os, time, json
topic = os.getenv('DVR_TAG') + "/" + os.getenv('SRS_CH')
rtsp = "rtsp://" + os.getenv('DVR_USER') + ":" + os.getenv('DVR_PSWD') # DVR 使用者認證
rtsp = rtsp + "@" + os.getenv('DVR_HOST') # DVR 位址
rtsp = rtsp + "/" + os.getenv('DVR_TYPE') + "_" + os.getenv('DVR_CH') # DVR 串流
rtmp = "rtmp://" + os.getenv('SRS_HOST') + ":" + os.getenv('SRS_PORT') # SRS 位址
rtmp = rtmp + "/live/" + topic # SRS 串流
cmd = [
'ffmpeg', '-rtsp_transport', 'tcp', # RTSP to RTMP 轉發
'-i', rtsp, # DVR 連結
'-c:v', 'copy', # 相同影像格式
'-an', # 無聲音
'-f', 'flv', rtmp, # SRS 連結
]
# client = mqtt.Client(client_id=os.getenv('DVR_TAG'))
# client.connect(os.getenv('MQTT'))
# data = { 'status' : 0, 'rtsp' : rtsp, 'rtmp' : rtmp }
while True:
p = sp.Popen(cmd, stderr=sp.PIPE)
while p.returncode == None:
t = time.strftime("[%Y/%m/%d][%H:%M:%S][" + str(p.pid) + "]")
if not p.stderr.isatty():
err = p.stderr.readline()
err = str(err, encoding='utf-8') if len(err) > 0 else ""
index1 = (err.index("'") + 1) if "'" in err else 0
index2 = (err.index("'", index1)) if "'" in err else 0
if 'Input' in err and index2 > index1:
print(t + " > I: " + err[index1:index2])
if 'Output' in err and index2 > index1:
print(t + " > O: " + err[index1:index2])
p.stderr.flush()
else:
print(t)
time.sleep(1)
while False:
p = sp.Popen(cmd)
while p.returncode == None:
data['status'] = 1
time.sleep(os.getenv('INTERVAL'))
data['status'] = 0
\ No newline at end of file
jiantw83
3qoZA8ne
\ No newline at end of file
FROM resin/rpi-raspbian
RUN apt update
RUN apt install -y wget build-essential
RUN wget http://www.dest-unreach.org/socat/download/socat-1.7.3.2.tar.gz
RUN tar zxf socat-1.7.3.2.tar.gz
WORKDIR socat-1.7.3.2
RUN ./configure
RUN make
RUN make install
ENV TZ=Asia/Taipei
CMD socat tcp-listen:${LOCAL_PORT},reuseaddr,fork tcp:${REMOTE_IP}:${REMOTE_PORT}
\ No newline at end of file
FROM resin/rpi-raspbian
RUN apt update
RUN apt install -y git python-dev
RUN git clone https://github.com/winlinvip/simple-rtmp-server
WORKDIR /simple-rtmp-server/trunk
RUN ./configure
RUN make
COPY origin.conf conf/origin.conf
COPY edge.conf conf/edge.conf
ENV TZ=Asia/Taipei
\ No newline at end of file
# conf/edge.conf
listen 1935;
max_connections 1000;
pid ./objs/edge.pid;
daemon off;
srs_log_tank ./objs/edge.log;
http_server {
enabled on;
listen 8080;
dir ./objs/nginx/html;
}
vhost __defaultVhost__ {
cluster {
mode remote;
origin 192.168.5.200;
}
http_remux {
enabled on;
mount [vhost]/[app]/[stream].flv;
}
}
\ No newline at end of file
# conf/origin.conf
listen 1935;
max_connections 1000;
daemon off;
pid objs/origin.pid;
srs_log_file ./objs/origin.log;
vhost __defaultVhost__ {
}
\ No newline at end of file
#!bin/bash
# Program:
# Install docker and docker-compose for raspberry pi.
# History:
# 2019/03/12 12:30 First release.
# 2019/03/12 12:33 Remove test and insert sudo to specific command.
# 2019/03/12 12:38 Install command which to install docker-compose.
sudo apt update
sudo curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
sudo rm get-docker.sh
sudo groupadd docker
sudo gpasswd -a pi docker
sudo docker version
sudo apt install -y python3-dev python3-pip
sudo pip3 install --upgrade pip
sudo pip3 install docker-compose
sudo docker-compose version
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment