1. go env查看環境變量
設置某個項的值:如 go env -w GO111MODULE=on
2. helloworld.go
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
編譯:go build helloworld.go生成helloworld.exe
直接運行:go run helloworld.go
3. https://github.com/deepch/RTSPtoWebRTC
GO111MODULE=on go run *.go Windows下不支持
使用vscode,打開terminal,在termal窗口右上角有個+號,點看,選擇git bash,然后執行就可以
進來后就是一個MINGW64控制台,什么ls cd等命令都可以直接使用了
migu@DESKTOP-1SNLJOP MINGW64 /c/tanglm/RTSPtoWebRTC-master
$
migu@DESKTOP-1SNLJOP MINGW64 /c/tanglm/RTSPtoWebRTC-master
$ GO111MODULE=on go run *.go
go: github.com/deepch/vdk@v0.0.0-20210508200759-5adbbcc01f89: Get "https://proxy.golang.org/github.com/deepch/vdk/@v/v0.0.0-20210508200759-5adbbcc01f89.mod": dial tcp 172.217.160.113:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
migu@DESKTOP-1SNLJOP MINGW64 /c/tanglm/RTSPtoWebRTC-master
golang國內代理
https://blog.csdn.net/u013272009/article/details/90139288
win
$env:GOPROXY = "https://goproxy.io"
linxu bash
export GOPROXY=https://goproxy.io
go build 生成:RTSPtoWebRTC
config.json文件修改:rtsp url改為自己要拉的流
{
"server": {
"http_port": ":8083",
"ice_servers": ["stun:stun.l.google.com:19302"],
"ice_username": "",
"ice_credential": ""
},
"streams": {
"H264_AAC": {
"on_demand": false,
"disable_audio": true,
"url": "rtsp://139.224.204.41:8554/D1.264" //修改點
},
//后面忽略
}
直接運行 ./RTSPtoWebRTC
leehm@ubuntu:~/Desktop/share/RTSPtoWebRTC$ ./RTSPtoWebRTC
2021/06/15 14:39:19 Stream Try Connect H264_AAC
2021/06/15 14:39:19 Server Start Awaiting Signal
[GIN] 2021/06/15 - 14:48:24 | 301 | 108.999µs | 192.168.192.1 | GET "/"
[GIN] 2021/06/15 - 14:48:24 | 200 | 472.545µs | 192.168.192.1 | GET "/stream/player/H264_AAC"
[GIN] 2021/06/15 - 14:48:24 | 200 | 394.777212ms | 192.168.192.1 | GET "/static/js/bootstrap.mi
然后打開瀏覽器8083端口,config.json配置
http://192.168.192.141:8083/
可以看見畫面了