mirror of
https://github.com/DavidHGS/aiedge.git
synced 2026-04-22 23:37:05 +08:00
add yaml
This commit is contained in:
@@ -55,6 +55,8 @@ ENV IMG_NUM ""
|
||||
##拉流地址 rtmp://aiedge.ndsl-lab.cn:8035/live/stream1
|
||||
##推流地址 rtmp://aiedge.ndsl-lab.cn:8035/live/stream
|
||||
ENV PULLSTREAM_URL ""
|
||||
ENV PUSHSTREAM_URL ""
|
||||
ENV FPS ""
|
||||
|
||||
RUN mkdir /app/aiedge
|
||||
COPY . /app/aiedge
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
FROM huangzhenming/ubuntu20.04.arm64:v1.0 AS build
|
||||
|
||||
|
||||
## 设置时区
|
||||
RUN apt-get -y update && DEBIAN_FRONTEND="noninteractive" apt -y install tzdata
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
# 容器环境变量添加,会覆盖默认的变量值
|
||||
ENV GO111MODULE=on\
|
||||
GOPROXY=https://goproxy.cn,direct
|
||||
|
||||
RUN mkdir /app
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt update && apt-get install -y --no-install-recommends ca-certificates
|
||||
RUN update-ca-certificates
|
||||
|
||||
## 安装 ffmepg
|
||||
RUN apt install -y ffmpeg
|
||||
|
||||
RUN apt install -y git wget sudo
|
||||
RUN mkdir /app/tmp
|
||||
|
||||
## 安装go1.17.8
|
||||
RUN chmod -R 777 /app/tmp&& cd /app/tmp
|
||||
RUN wget https://go.dev/dl/go1.17.8.linux-arm64.tar.gz &&\
|
||||
tar -C /usr/local -xzf go1.17.8.linux-arm64.tar.gz &&\
|
||||
## 软链接
|
||||
ln -s /usr/local/go/bin/* /usr/bin/
|
||||
# 设置环境变量
|
||||
ENV GOPATH="$HOME/go" \
|
||||
PATH="$PATH:/usr/local/go/bin:$GOPATH/bin" \
|
||||
GOPROXY=https://goproxy.cn,direct
|
||||
## 相当于source /bin/sh 中无source === /bin/bash -c "source ~/.bashrc"
|
||||
# RUN . ~/.bashrc
|
||||
|
||||
## 配置goav编译环境
|
||||
RUN apt-get install -y autoconf automake build-essential libass-dev libfreetype6-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texi2html zlib1g-dev
|
||||
RUN apt install -y libavdevice-dev libavfilter-dev libswscale-dev libavcodec-dev libavformat-dev libswresample-dev libavutil-dev
|
||||
RUN apt-get install -y yasm
|
||||
## 设置环境变量
|
||||
ENV FFMPEG_ROOT=$HOME/ffmpeg \
|
||||
CGO_LDFLAGS="-L$FFMPEG_ROOT/lib/ -lavcodec -lavformat -lavutil -lswscale -lswresample -lavdevice -lavfilter" \
|
||||
CGO_CFLAGS="-I$FFMPEG_ROOT/include" \
|
||||
LD_LIBRARY_PATH=$HOME/ffmpeg/lib
|
||||
|
||||
## 编译安装gocv
|
||||
|
||||
RUN cd /app/tmp
|
||||
RUN git clone https://github.com/hybridgroup/gocv.git \
|
||||
&& cd gocv \
|
||||
&& make install
|
||||
|
||||
## 设置ai应用环境变量
|
||||
ENV IMG_NUM ""
|
||||
##拉流地址 rtmp://aiedge.ndsl-lab.cn:8035/live/stream1
|
||||
##推流地址 rtmp://aiedge.ndsl-lab.cn:8035/live/stream
|
||||
ENV PULLSTREAM_URL ""
|
||||
ENV PUSHSTREAM_URL ""
|
||||
ENV FPS ""
|
||||
|
||||
RUN mkdir /app/aiedge
|
||||
COPY . /app/aiedge
|
||||
CMD cd /app/aiedge/&& go run main.go
|
||||
# CMD /app/aiedge/myapp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: aiapp-arm
|
||||
namespace: aiedge
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: aiapp-arm
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: aiapp-arm
|
||||
spec:
|
||||
containers:
|
||||
- name: aiapp
|
||||
image: david945/aiapp-arm:v2
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["/bin/bash"]
|
||||
args: ["-c","cd /tmp/aiedge/&& go run main.go"]
|
||||
env:
|
||||
- name: IMG_NUM
|
||||
value: "300"
|
||||
- name: FPS
|
||||
value: "25"
|
||||
- name: PULLSTREAM_URL
|
||||
value: "rtmp://192.168.20.150:30200/live/stream1"
|
||||
- name: PUSHSTREAM_URL
|
||||
value: "rtmp://192.168.20.150:30200/live/stream"
|
||||
securityContext:
|
||||
privileged: true
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: edge1-nx40
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: aiapp
|
||||
namespace: aiedge
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: aiapp
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: aiapp
|
||||
spec:
|
||||
containers:
|
||||
- name: aiapp
|
||||
image: david945/aiapp:v2
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: IMG_NUM
|
||||
value: "300"
|
||||
- name: FPS
|
||||
value: "25"
|
||||
- name: PULLSTREAM_URL
|
||||
value: "rtmp://192.168.20.150:30200/live/stream1"
|
||||
- name: PUSHSTREAM_URL
|
||||
value: "rtmp://192.168.20.150:30200/live/stream"
|
||||
securityContext:
|
||||
privileged: true
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: edge1-nx90
|
||||
@@ -15,7 +15,11 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
//系统变量 IMG_NUM,PULLSTREAM_URL 默认为30 rtmp://aiedge.ndsl-lab.cn:8035/live/stream1
|
||||
//系统变量
|
||||
//IMG_NUM 默认为30
|
||||
//FPS 25
|
||||
//PULLSTREAM_URL 默认为 rtmp://aiedge.ndsl-lab.cn:8035/live/stream1
|
||||
//PUSHSTREAM_URL 默认为 rtmp://aiedge.ndsl-lab.cn:8035/live/stream
|
||||
/*****************************图片参数*************************************************/
|
||||
imgNum := 30 //截取图片数量
|
||||
var err error
|
||||
@@ -23,15 +27,20 @@ func main() {
|
||||
imgNum, err = strconv.Atoi(IMG_NUM)
|
||||
fmt.Println(imgNum)
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Println("Atoi error")
|
||||
}
|
||||
inputPath := "./images/frame%d.jpg" //拉流抽帧图片地址
|
||||
outputPath := "./output/outframe%d.jpg" //目标检测图片输出地址
|
||||
/*****************************输出视频参数**********************************************/
|
||||
//根据视频流输入设置
|
||||
fps := 30 //视频帧率
|
||||
frameWidth := 1280 //视频帧宽度
|
||||
fps := 25 //视频帧率
|
||||
if FPS := os.Getenv("FPS"); FPS != "" {
|
||||
fps, err = strconv.Atoi(FPS)
|
||||
fmt.Println("fps:", fps)
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Println("Atoi error")
|
||||
}
|
||||
|
||||
frameWidth := 1280 //视频帧宽度ls
|
||||
frameHeight := 720 //视频帧高度
|
||||
/*****************************接口参数*************************************************/
|
||||
// pullStreamUrl := "rtmp://aiedge.ndsl-lab.cn:8035/live/2d6tsn0iqy108" //拉流地址
|
||||
@@ -39,11 +48,15 @@ func main() {
|
||||
if PULLSTREAM_URL := os.Getenv("PULLSTREAM_URL"); PULLSTREAM_URL != "" {
|
||||
pullStreamUrl = os.Getenv("PULLSTREAM_URL") //拉流地址
|
||||
}
|
||||
|
||||
pushStreamUrl := "rtmp://aiedge.ndsl-lab.cn:8035/live/stream" //推流地址
|
||||
if PUSHSTREAM_URL := os.Getenv("PUSHSTREAM_URL"); PUSHSTREAM_URL != "" {
|
||||
pushStreamUrl = os.Getenv("PUSHSTREAM_URL") //拉流地址
|
||||
}
|
||||
fmt.Println(pullStreamUrl)
|
||||
// objectDetectionUrl := "http://192.168.1.200:30001/v1/object-detection" //目标检测接口地址
|
||||
objectDetectionUrl := "http://192.168.20.150:30001/v1/face/detection" //人脸识别接口地址
|
||||
loginUrl := "http://192.168.20.170:30089/api/v1/auth/signin" //用户登录,获取jwt接口地址
|
||||
|
||||
loginUrl := "http://192.168.20.150:30089/api/v1/auth/signin" //用户登录,获取jwt接口地址
|
||||
|
||||
start := time.Now()
|
||||
|
||||
@@ -78,7 +91,9 @@ func main() {
|
||||
fmt.Printf("Time Cost %s \n", elapsed)
|
||||
// //ffmpeg -re -stream_loop -1 -i video02.mp4 -vcodec copy -acodec copy -f flv -y rtmp://aiedge.ndsl-lab.cn:8035/live/stream
|
||||
|
||||
command := "ffmpeg -re -stream_loop -1 -i video02.mp4 -vcodec copy -acodec copy -f flv -y rtmp://aiedge.ndsl-lab.cn:8035/live/stream"
|
||||
command := "ffmpeg -re -stream_loop -1 -i video02.mp4 -vcodec copy -acodec copy -f flv -y %s"
|
||||
command = fmt.Sprintf(command, pushStreamUrl)
|
||||
fmt.Println(command)
|
||||
cmd := exec.Command("/bin/bash", "-c", command)
|
||||
var out bytes.Buffer
|
||||
cmd.Stdout = &out
|
||||
@@ -90,4 +105,8 @@ func main() {
|
||||
// for true {
|
||||
// fmt.Printf("ok")
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
//docker build . --network="host" --build-arg "HTTP_PROXY=http://127.0.0.1:7890" --build-arg "HTTPS_PROXY=http://127.0.0.1:7890" -t hgs/aiapp:v8
|
||||
//docker run -it -e IMG_NUM="125" -e FPS="25" -e PULLSTREAM_URL="rtmp://192.168.20.150:30200/live/stream1" -e PUSHSTREAM_URL="rtmp://192.168.20.150:30200/live/stream" hgs/aiapp:v7 sh -c"cd /tmp/aiedge/&& go run main.go"
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: aiapp-arm-start
|
||||
namespace: aiedge
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: aiapp-arm-start
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: aiapp-arm-start
|
||||
spec:
|
||||
containers:
|
||||
- name: aiapp
|
||||
image: david945/aiapp-arm:start
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: IMG_NUM
|
||||
value: "300"
|
||||
- name: FPS
|
||||
value: "25"
|
||||
- name: PULLSTREAM_URL
|
||||
value: "rtmp://192.168.20.150:30200/live/stream1"
|
||||
- name: PUSHSTREAM_URL
|
||||
value: "rtmp://192.168.20.150:30200/live/stream"
|
||||
securityContext:
|
||||
privileged: true
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: edge1-nx40
|
||||
Reference in New Issue
Block a user