Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 43 additions & 41 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
services:
loki:
container_name: loki
image: grafana/loki:latest
ports:
- "3100:3100"
volumes:
- ./observability/loki/config:/etc/loki
- ./observability/loki/data:/loki
- ./observability/loki/wal:/wal
command: -config.file=/etc/loki/loki-config.yaml
networks:
- smartess_network

promtail:
container_name: promtail
image: grafana/promtail:latest
volumes:
- ./observability/promtail/config:/etc/promtail
- ./go/cmd/server/logs:/app/logs
command: -config.file=/etc/promtail/promtail-config.yaml
networks:
- smartess_network

grafana:
container_name: grafana
image: grafana/grafana:latest
ports:
- "4000:4000"
volumes:
- ./observability/grafana/data:/var/lib/grafana
- ./observability/grafana/init-scripts:/etc/grafana/provisioning/dashboards # For dashboards
- ./observability/grafana/init-scripts:/etc/grafana/provisioning/datasources # For data sources

environment:
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
depends_on:
- loki
networks:
- smartess_network
# loki:
# container_name: loki
# image: grafana/loki:latest
# ports:
# - "3100:3100"
# volumes:
# - ./observability/loki/config:/etc/loki
# - ./observability/loki/data:/loki
# - ./observability/loki/wal:/wal
# command: -config.file=/etc/loki/loki-config.yaml
# networks:
# - smartess_network
#
# promtail:
# container_name: promtail
# image: grafana/promtail:latest
# volumes:
# - ./observability/promtail/config:/etc/promtail
# - ./go/cmd/server/logs:/app/logs
# command: -config.file=/etc/promtail/promtail-config.yaml
# networks:
# - smartess_network
#
# grafana:
# container_name: grafana
# image: grafana/grafana:latest
# ports:
# - "4000:4000"
# volumes:
# - ./observability/grafana/data:/var/lib/grafana
# - ./observability/grafana/init-scripts:/etc/grafana/provisioning/dashboards # For dashboards
# - ./observability/grafana/init-scripts:/etc/grafana/provisioning/datasources # For data sources
#
# environment:
# - GF_AUTH_ANONYMOUS_ENABLED=true
# - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
# depends_on:
# - loki
# networks:
# - smartess_network
server:
container_name: server
build:
Expand All @@ -49,6 +49,8 @@ services:
volumes:
- ./go/cmd/server/logs:/app/logs
- ./go/common/configs:/app/config
- ./go/server/static:/app/static
- ./go/cmd/hub/data:/tmp/data # Map actual directory to /tmp/data in container
depends_on:
rabbitmq:
condition: service_healthy # Correct placement of health condition
Expand Down Expand Up @@ -106,7 +108,7 @@ services:
# - /app/frontend/.next
# networks:
# - smartess_network
#

# smartessweb_prod_backend:
# container_name: smartessweb_prod_backend
# build:
Expand Down
71 changes: 71 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,104 @@ github.com/asticode/go-astikit v0.30.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xbl
github.com/asticode/go-astits v1.13.0 h1:XOgkaadfZODnyZRR5Y0/DWkA9vrkLLPLeeOvDwfKZ1c=
github.com/asticode/go-astits v1.13.0/go.mod h1:QSHmknZ51pf6KJdHKZHJTLlMegIrhega3LPWz3ND/iI=
github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/nedpals/postgrest-go v0.1.3 h1:ZC3aPPx9rDTWQWzvnWI60lJWjAqgCCD/U6hcHp3NL0w=
github.com/nedpals/postgrest-go v0.1.3/go.mod h1:RGinB2OXsnGLcZMu5avS0U+b9npyZmk+ecK74UDi/xY=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/pion/datachannel v1.5.8 h1:ph1P1NsGkazkjrvyMfhRBUAWMxugJjq2HfQifaOoSNo=
github.com/pion/datachannel v1.5.8/go.mod h1:PgmdpoaNBLX9HNzNClmdki4DYW5JtI7Yibu8QzbL3tI=
github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s=
github.com/pion/dtls/v2 v2.2.12 h1:KP7H5/c1EiVAAKUmXyCzPiQe5+bCJrpOeKg/L05dunk=
github.com/pion/dtls/v2 v2.2.12/go.mod h1:d9SYc9fch0CqK90mRk1dC7AkzzpwJj6u2GU3u+9pqFE=
github.com/pion/ice/v2 v2.3.36 h1:SopeXiVbbcooUg2EIR8sq4b13RQ8gzrkkldOVg+bBsc=
github.com/pion/ice/v2 v2.3.36/go.mod h1:mBF7lnigdqgtB+YHkaY/Y6s6tsyRyo4u4rPGRuOjUBQ=
github.com/pion/interceptor v0.1.29 h1:39fsnlP1U8gw2JzOFWdfCU82vHvhW9o0rZnZF56wF+M=
github.com/pion/interceptor v0.1.29/go.mod h1:ri+LGNjRUc5xUNtDEPzfdkmSqISixVTBF/z/Zms/6T4=
github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=
github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
github.com/pion/mdns v0.0.12 h1:CiMYlY+O0azojWDmxdNr7ADGrnZ+V6Ilfner+6mSVK8=
github.com/pion/mdns v0.0.12/go.mod h1:VExJjv8to/6Wqm1FXK+Ii/Z9tsVk/F5sD/N70cnYFbk=
github.com/pion/rtcp v1.2.12/go.mod h1:sn6qjxvnwyAkkPzPULIbVqSKI5Dv54Rv7VG0kNxh9L4=
github.com/pion/rtp v1.8.3/go.mod h1:pBGHaFt/yW7bf1jjWAoUjpSNoDnw98KTMg+jWWvziqU=
github.com/pion/rtp v1.8.7 h1:qslKkG8qxvQ7hqaxkmL7Pl0XcUm+/Er7nMnu6Vq+ZxM=
github.com/pion/rtp v1.8.7/go.mod h1:pBGHaFt/yW7bf1jjWAoUjpSNoDnw98KTMg+jWWvziqU=
github.com/pion/sctp v1.8.19 h1:2CYuw+SQ5vkQ9t0HdOPccsCz1GQMDuVy5PglLgKVBW8=
github.com/pion/sctp v1.8.19/go.mod h1:P6PbDVA++OJMrVNg2AL3XtYHV4uD6dvfyOovCgMs0PE=
github.com/pion/srtp/v2 v2.0.20 h1:HNNny4s+OUmG280ETrCdgFndp4ufx3/uy85EawYEhTk=
github.com/pion/srtp/v2 v2.0.20/go.mod h1:0KJQjA99A6/a0DOVTu1PhDSw0CXF2jTkqOoMg3ODqdA=
github.com/pion/stun v0.6.1 h1:8lp6YejULeHBF8NmV8e2787BogQhduZugh5PdhDyyN4=
github.com/pion/stun v0.6.1/go.mod h1:/hO7APkX4hZKu/D0f2lHzNyvdkTGtIy3NDmLR7kSz/8=
github.com/pion/transport/v2 v2.2.1/go.mod h1:cXXWavvCnFF6McHTft3DWS9iic2Mftcz1Aq29pGcU5g=
github.com/pion/transport/v2 v2.2.3/go.mod h1:q2U/tf9FEfnSBGSW6w5Qp5PFWRLRj3NjLhCCgpRK4p0=
github.com/pion/transport/v2 v2.2.4/go.mod h1:q2U/tf9FEfnSBGSW6w5Qp5PFWRLRj3NjLhCCgpRK4p0=
github.com/pion/transport/v2 v2.2.10 h1:ucLBLE8nuxiHfvkFKnkDQRYWYfp8ejf4YBOPfaQpw6Q=
github.com/pion/transport/v2 v2.2.10/go.mod h1:sq1kSLWs+cHW9E+2fJP95QudkzbK7wscs8yYgQToO5E=
github.com/pion/transport/v3 v3.0.1/go.mod h1:UY7kiITrlMv7/IKgd5eTUcaahZx5oUN3l9SzK5f5xE0=
github.com/pion/transport/v3 v3.0.2 h1:r+40RJR25S9w3jbA6/5uEPTzcdn7ncyU44RWCbHkLg4=
github.com/pion/transport/v3 v3.0.2/go.mod h1:nIToODoOlb5If2jF9y2Igfx3PFYWfuXi37m0IlWa/D0=
github.com/pion/turn/v2 v2.1.3/go.mod h1:huEpByKKHix2/b9kmTAM3YoX6MKP+/D//0ClgUYR2fY=
github.com/pion/turn/v2 v2.1.6 h1:Xr2niVsiPTB0FPtt+yAWKFUkU1eotQbGgpTIld4x1Gc=
github.com/pion/turn/v2 v2.1.6/go.mod h1:huEpByKKHix2/b9kmTAM3YoX6MKP+/D//0ClgUYR2fY=
github.com/pion/webrtc/v3 v3.3.5 h1:ZsSzaMz/i9nblPdiAkZoP+E6Kmjw+jnyq3bEmU3EtRg=
github.com/pion/webrtc/v3 v3.3.5/go.mod h1:liNa+E1iwyzyXqNUwvoMRNQ10x8h8FOeJKL8RkIbamE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A=
github.com/sclevine/agouti v3.0.0+incompatible h1:8IBJS6PWz3uTlMP3YBIR5f+KAldcGuOeFkFbUWfBgK4=
github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/wlynxg/anet v0.0.3 h1:PvR53psxFXstc12jelG6f1Lv4MWqE0tI76/hHGjh9rg=
github.com/wlynxg/anet v0.0.3/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
9 changes: 9 additions & 0 deletions go/cmd/hub_camera_only/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Original Hub for the video streaming feature design and end-to-end dev

This is the original development environment that was used to research, design, test and develop the most networking/theory/arch intensive components of the video streaming feature.\
> First End-to-end working prototype... from RTSP raw stream to final web surveillance page. Development purposes only and not for production.

It is faster to build and deploy in dev/test envs with docker as well as with any deps since it simulates a hub with only smart camera features. \

For the official production camera features as well as other features like alerts/events, logs, etc... of the full project pipeline as seen on website and interfaces,
please refer to prod docker-composes and not this one here which is used for isolated networking / dev purposes.
2 changes: 1 addition & 1 deletion go/cmd/hub_camera_only/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ services:
- consumer
networks:
- smartess_network # Use the existing network
# Mock camera rtsp stream for testing purposes
# Mock camera rtsp stream for testing purposes
mock_camera:
container_name: mock_camera
build:
Expand Down
89 changes: 47 additions & 42 deletions go/cmd/hub_camera_only/producer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,42 +219,7 @@ func streamRTSP(config *FFmpegConfig, producer *stream.Producer) error {
reader := bufio.NewReaderSize(stdout, config.bufferReaderSize) //1024*1024)

buf := make([]byte, config.bufferReaderSize) //512*1024)
//errorChan := make(chan error, 1)
//
//go func() {
// for {
// n, err := stdout.Read(buf)
// if err != nil {
// errorChan <- fmt.Errorf("error reading from RTSP stream: %v", err)
// return
// }
// if n == 0 {
// continue
// }
//
// videoChunk := buf[:n]
// if err := producer.Send(amqp.NewMessage(videoChunk)); err != nil {
// errorChan <- fmt.Errorf("failed to publish message: %v", err)
// return
// }
// log.Printf("Sent video chunk (%d bytes) to stream", n)
// time.Sleep(50 * time.Millisecond)
// }
//}()
//
//// Wait for either an error or the command to finish
//select {
//case err := <-errorChan:
// cmd.Process.Kill()
// cmd.Wait()
// return err
//case err := <-func() chan error {
// c := make(chan error, 1)
// go func() { c <- cmd.Wait() }()
// return c
//}():
// return err
//}

for {
n, err := reader.Read(buf)
if err != nil {
Expand Down Expand Up @@ -284,9 +249,48 @@ func streamRTSP(config *FFmpegConfig, producer *stream.Producer) error {
return nil
}

// errorChan := make(chan error, 1)
//
// go func() {
// for {
// n, err := stdout.Read(buf)
// if err != nil {
// errorChan <- fmt.Errorf("error reading from RTSP stream: %v", err)
// return
// }
// if n == 0 {
// continue
// }
//
// videoChunk := buf[:n]
// if err := producer.Send(amqp.NewMessage(videoChunk)); err != nil {
// errorChan <- fmt.Errorf("failed to publish message: %v", err)
// return
// }
// log.Printf("Sent video chunk (%d bytes) to stream", n)
// time.Sleep(50 * time.Millisecond)
// }
// }()
//
// // Wait for either an error or the command to finish
// select {
// case err := <-errorChan:
//
// cmd.Process.Kill()
// cmd.Wait()
// return err
//
// case err := <-func() chan error {
// c := make(chan error, 1)
// go func() { c <- cmd.Wait() }()
// return c
// }():
//
// return err
// }
func main() {
SELECTED_CAMERA_ENUM := ANT_CAMERA // MOCK_CAMERA
SELECTED_CAMERA := int(SELECTED_CAMERA_ENUM)
SELECTED_CAMERA_ENUM := MOCK_CAMERA // MOCK_CAMERA
//SELECTED_CAMERA := int(SELECTED_CAMERA_ENUM)

// Read camera configuration
dir := "/app/config/cameras.yaml"
Expand All @@ -300,11 +304,12 @@ func main() {
log.Fatalf("failed to unmarshal yaml: %v", err)
}

if len(cameras["cameras"]) <= SELECTED_CAMERA {
log.Fatalf("Invalid camera selection: %d", SELECTED_CAMERA)
}
//if len(cameras["cameras"]) <= SELECTED_CAMERA {
// log.Fatalf("Invalid camera selection: %d", SELECTED_CAMERA)
//}

RTSP_STREAM_URL := cameras["cameras"][SELECTED_CAMERA]["streamURL"]
//RTSP_STREAM_URL := cameras["cameras"][SELECTED_CAMERA]["streamURL"]
RTSP_STREAM_URL := "rtsp://mock_camera:8554/live"
log.Printf("RTSP Stream URL: %s", RTSP_STREAM_URL)

// Validate RTSP stream before proceeding
Expand Down
54 changes: 27 additions & 27 deletions go/common/scripts/ffmpeg_segment_concat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ ffmpeg -f hls -i segments.m3u8 -c:v copy -c:a copy output.mp4

ffmpeg -f concat -safe 0 -i concat.txt -c:v libx264 -preset fast -r 15 -g 15 -vf "fps=15" -c:a aac -b:a 64k output2.mp4

## Using concat.txt
## Step 1: Create concat.txt if it doesn't exist, or clear it if it does
#[ -f concat.txt ] && > concat.txt || touch concat.txt
#
## Step 2: Fill concat.txt based on segment files in segments.m3u8
#grep -E "^segment-[0-9]{3}\.mp4$" segments.m3u8 | while read -r line; do
# echo "file '$line'" >> concat.txt
#done
#
## Step 3: Compile the playlist using concat.txt with FFmpeg
#ffmpeg -f concat -safe 0 -i concat.txt -c:v copy -c:a copy output.mp4
##ffmpeg -f concat -safe 0 -i concat.txt -c:v copy -c:a copy -map 0:v:0? -map 0:a:0? output.mp4

## Verify segments exist
#ls -l segment-*.mp4

## Test first segment playback and codec compatibility
#ffplay segment-000.mp4
#ffprobe segment-000.mp4
#ffprobe -v error -show_streams segment-000.mp4
#ffprobe segment-000.mp4 -show_packets | grep pkt_dts_time

## Fix bad encoding by enforcing codec compatibility if copy failed
#ffmpeg -i segments.m3u8 -c:v libx264 -c:a aac -r 15 -g 30 output.mp4

## Fix bad timestamps
#ffmpeg -fflags +genpts -i segments.m3u8 -c:v copy -c:a copy output.mp4
# Using concat.txt
# Step 1: Create concat.txt if it doesn't exist, or clear it if it does
[ -f concat.txt ] && > concat.txt || touch concat.txt

# Step 2: Fill concat.txt based on segment files in segments.m3u8
grep -E "^segment-[0-9]{3}\.mp4$" segments.m3u8 | while read -r line; do
echo "file '$line'" >> concat.txt
done

# Step 3: Compile the playlist using concat.txt with FFmpeg
ffmpeg -f concat -safe 0 -i concat.txt -c:v copy -c:a copy output.mp4
#ffmpeg -f concat -safe 0 -i concat.txt -c:v copy -c:a copy -map 0:v:0? -map 0:a:0? output.mp4

# Verify segments exist
ls -l segment-*.mp4

# Test first segment playback and codec compatibility
ffplay segment-000.mp4
ffprobe segment-000.mp4
ffprobe -v error -show_streams segment-000.mp4
ffprobe segment-000.mp4 -show_packets | grep pkt_dts_time

# Fix bad encoding by enforcing codec compatibility if copy failed
ffmpeg -i segments.m3u8 -c:v libx264 -c:a aac -r 15 -g 30 output.mp4

# Fix bad timestamps
ffmpeg -fflags +genpts -i segments.m3u8 -c:v copy -c:a copy output.mp4
Loading
Loading