Update naming logic.

This commit is contained in:
Сергей Петров 2025-04-03 15:28:27 +05:00
parent d311776302
commit 15688905d3
6 changed files with 23 additions and 22 deletions

View File

@ -27,9 +27,3 @@ func main() {
logger.Log.Error("Failed to create flow", zap.Error(err)) logger.Log.Error("Failed to create flow", zap.Error(err))
} }
} }
//remote_write:
//- url: https://prometheus-prod-53-prod-me-central-1.grafana.net/api/prom/push
//basic_auth:
//username: 2350647
//password: glc_eyJvIjoiMTM4ODkxOCIsIm4iOiJzdGFjay0xMjEzMjA0LWhtLXdyaXRlLXBzYSIsImsiOiJibnU4bFI4ZHM2NXQ4MUo3a2UwSzRnWjMiLCJtIjp7InIiOiJwcm9kLW1lLWNlbnRyYWwtMSJ9fQ==

View File

@ -3,8 +3,8 @@ module reader
go 1.24.1 go 1.24.1
require ( require (
git.insit.tech/psa/rtsp_reader-writer/writer v0.0.0-20250401090923-510c1d636d6c git.insit.tech/psa/rtsp_reader-writer/writer v0.0.0-20250403101647-d3117763025c
git.insit.tech/sas/rtsp_proxy v0.0.0-20250331071234-841a39837c26 git.insit.tech/sas/rtsp_proxy v0.0.0-20250403064958-d4446b880371
github.com/bluenviron/gortsplib/v4 v4.12.3 github.com/bluenviron/gortsplib/v4 v4.12.3
github.com/bluenviron/mediacommon v1.14.0 github.com/bluenviron/mediacommon v1.14.0
github.com/bluenviron/mediacommon/v2 v2.0.0 github.com/bluenviron/mediacommon/v2 v2.0.0
@ -14,7 +14,7 @@ require (
) )
require ( require (
github.com/asticode/go-astikit v0.53.0 // indirect github.com/asticode/go-astikit v0.54.0 // indirect
github.com/asticode/go-astits v1.13.0 // indirect github.com/asticode/go-astits v1.13.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect

View File

@ -2,15 +2,21 @@ git.insit.tech/psa/rtsp_reader-writer/writer v0.0.0-20250328095722-6d9cef974261
git.insit.tech/psa/rtsp_reader-writer/writer v0.0.0-20250328095722-6d9cef974261/go.mod h1:vFg2FZ/v01qLRLionpgocR5MaznCijzUiCSrPou45Ts= git.insit.tech/psa/rtsp_reader-writer/writer v0.0.0-20250328095722-6d9cef974261/go.mod h1:vFg2FZ/v01qLRLionpgocR5MaznCijzUiCSrPou45Ts=
git.insit.tech/psa/rtsp_reader-writer/writer v0.0.0-20250401090923-510c1d636d6c h1:K471uPxQyfWV/7kEouWUmwBCph48LQhAnRhF7Z38rDM= git.insit.tech/psa/rtsp_reader-writer/writer v0.0.0-20250401090923-510c1d636d6c h1:K471uPxQyfWV/7kEouWUmwBCph48LQhAnRhF7Z38rDM=
git.insit.tech/psa/rtsp_reader-writer/writer v0.0.0-20250401090923-510c1d636d6c/go.mod h1:fNiizkos/pm0o0C7rOmHKXrkKYHz0VgsrWfl+tBBH50= git.insit.tech/psa/rtsp_reader-writer/writer v0.0.0-20250401090923-510c1d636d6c/go.mod h1:fNiizkos/pm0o0C7rOmHKXrkKYHz0VgsrWfl+tBBH50=
git.insit.tech/psa/rtsp_reader-writer/writer v0.0.0-20250403101647-d3117763025c h1:XL0wdylLmMB3WK55l8X1dc/TmBIuVHO9/gUho79NsHw=
git.insit.tech/psa/rtsp_reader-writer/writer v0.0.0-20250403101647-d3117763025c/go.mod h1:dDCZejhHOcSrjFJi6iwB82bTIYEA6IX2CXFXHffrU30=
git.insit.tech/sas/rtsp_proxy v0.0.0-20250326124321-cb817660066c h1:A/D1INKJI/jkgy4TRamf7HTvQVqGy7qPBdTlZmYWIm0= git.insit.tech/sas/rtsp_proxy v0.0.0-20250326124321-cb817660066c h1:A/D1INKJI/jkgy4TRamf7HTvQVqGy7qPBdTlZmYWIm0=
git.insit.tech/sas/rtsp_proxy v0.0.0-20250326124321-cb817660066c/go.mod h1:/AHWd1Otr+ikOLWzpXtoozzifEx9ZKou+R6DgwaEzr0= git.insit.tech/sas/rtsp_proxy v0.0.0-20250326124321-cb817660066c/go.mod h1:/AHWd1Otr+ikOLWzpXtoozzifEx9ZKou+R6DgwaEzr0=
git.insit.tech/sas/rtsp_proxy v0.0.0-20250331071234-841a39837c26 h1:YZUBOjJXF3zqlVtQ+IfjFMr7spYZdBQjbqLelWudIUY= git.insit.tech/sas/rtsp_proxy v0.0.0-20250331071234-841a39837c26 h1:YZUBOjJXF3zqlVtQ+IfjFMr7spYZdBQjbqLelWudIUY=
git.insit.tech/sas/rtsp_proxy v0.0.0-20250331071234-841a39837c26/go.mod h1:/AHWd1Otr+ikOLWzpXtoozzifEx9ZKou+R6DgwaEzr0= git.insit.tech/sas/rtsp_proxy v0.0.0-20250331071234-841a39837c26/go.mod h1:/AHWd1Otr+ikOLWzpXtoozzifEx9ZKou+R6DgwaEzr0=
git.insit.tech/sas/rtsp_proxy v0.0.0-20250403064958-d4446b880371 h1:rfv9H0aF9piFSfdh1ZPPMU+vb2ws/nZyanRJfZmteGI=
git.insit.tech/sas/rtsp_proxy v0.0.0-20250403064958-d4446b880371/go.mod h1:C8AfoW1Go9xoZz2VdGYKjK8h3ormC3zYb40h7OGL+rs=
github.com/asticode/go-astikit v0.30.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0= github.com/asticode/go-astikit v0.30.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0=
github.com/asticode/go-astikit v0.52.0 h1:kTl2XjgiVQhUl1H7kim7NhmTtCMwVBbPrXKqhQhbk8Y= github.com/asticode/go-astikit v0.52.0 h1:kTl2XjgiVQhUl1H7kim7NhmTtCMwVBbPrXKqhQhbk8Y=
github.com/asticode/go-astikit v0.52.0/go.mod h1:fV43j20UZYfXzP9oBn33udkvCvDvCDhzjVqoLFuuYZE= github.com/asticode/go-astikit v0.52.0/go.mod h1:fV43j20UZYfXzP9oBn33udkvCvDvCDhzjVqoLFuuYZE=
github.com/asticode/go-astikit v0.53.0 h1:ELK5FEuGyUomSzM4Vk5TQ+adGqhVs4FBmDFh10rDPMU= github.com/asticode/go-astikit v0.53.0 h1:ELK5FEuGyUomSzM4Vk5TQ+adGqhVs4FBmDFh10rDPMU=
github.com/asticode/go-astikit v0.53.0/go.mod h1:fV43j20UZYfXzP9oBn33udkvCvDvCDhzjVqoLFuuYZE= github.com/asticode/go-astikit v0.53.0/go.mod h1:fV43j20UZYfXzP9oBn33udkvCvDvCDhzjVqoLFuuYZE=
github.com/asticode/go-astikit v0.54.0 h1:uq9eurgisdkYwJU9vSWIQaPH4MH0cac82sQH00kmSNQ=
github.com/asticode/go-astikit v0.54.0/go.mod h1:fV43j20UZYfXzP9oBn33udkvCvDvCDhzjVqoLFuuYZE=
github.com/asticode/go-astits v1.13.0 h1:XOgkaadfZODnyZRR5Y0/DWkA9vrkLLPLeeOvDwfKZ1c= 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/asticode/go-astits v1.13.0/go.mod h1:QSHmknZ51pf6KJdHKZHJTLlMegIrhega3LPWz3ND/iI=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=

View File

@ -2,6 +2,7 @@ package log
import ( import (
"fmt" "fmt"
"strconv"
"time" "time"
log2 "git.insit.tech/sas/rtsp_proxy/core/log" log2 "git.insit.tech/sas/rtsp_proxy/core/log"
@ -20,5 +21,5 @@ func StartMainLogger(local, program string) {
fmt.Sprintf("%s/%s-main_%s.log", fmt.Sprintf("%s/%s-main_%s.log",
config.LogsDirectory, config.LogsDirectory,
program, program,
time.Now().Format("15-04-05_02-01-2006"))) strconv.FormatInt(time.Now().Unix(), 10)))
} }

View File

@ -25,8 +25,8 @@ func multiplyAndDivide(v, m, d int64) int64 {
return (secs*m + dec*m/d) return (secs*m + dec*m/d)
} }
// MpegtsMuxer allows to save a H264 / MPEG-4 audio stream into a MPEG-TS file. // MpegTSMuxer allows to save a H264 / MPEG-4 audio stream into MPEG-TS file.
type MpegtsMuxer struct { type MpegTSMuxer struct {
FileName string FileName string
H264Format *format.H264 H264Format *format.H264
Mpeg4AudioFormat *format.MPEG4Audio Mpeg4AudioFormat *format.MPEG4Audio
@ -41,7 +41,7 @@ type MpegtsMuxer struct {
} }
// Initialize initializes a MpegtsMuxer. // Initialize initializes a MpegtsMuxer.
func (e *MpegtsMuxer) Initialize() error { func (e *MpegTSMuxer) Initialize() error {
var err error var err error
e.f, err = os.Create(e.FileName) e.f, err = os.Create(e.FileName)
if err != nil { if err != nil {
@ -65,13 +65,13 @@ func (e *MpegtsMuxer) Initialize() error {
} }
// Close closes all the MpegtsMuxer resources. // Close closes all the MpegtsMuxer resources.
func (e *MpegtsMuxer) Close() { func (e *MpegTSMuxer) Close() {
e.b.Flush() e.b.Flush()
e.f.Close() e.f.Close()
} }
// WriteH264 writes a H264 access unit into MPEG-TS. // WriteH264 writes a H264 access unit into MPEG-TS.
func (e *MpegtsMuxer) WriteH264(pts int64, au [][]byte) error { func (e *MpegTSMuxer) WriteH264(pts int64, au [][]byte) error {
e.mutex.Lock() e.mutex.Lock()
defer e.mutex.Unlock() defer e.mutex.Unlock()
@ -140,7 +140,7 @@ func (e *MpegtsMuxer) WriteH264(pts int64, au [][]byte) error {
} }
// WriteAAC writes MPEG-4 audio access units into MPEG-TS. // WriteAAC writes MPEG-4 audio access units into MPEG-TS.
func (e *MpegtsMuxer) WriteAAC(aus [][]byte, pts int64) error { func (e *MpegTSMuxer) WriteAAC(aus [][]byte, pts int64) error {
e.mutex.Lock() e.mutex.Lock()
defer e.mutex.Unlock() defer e.mutex.Unlock()

View File

@ -44,7 +44,7 @@ func CreateVideo(dir string) error {
for _, file := range files { for _, file := range files {
// Create logger. // Create logger.
cam := log2.CamLogging( cam := log2.CamLogging(
fmt.Sprintf("%s/%s/reader-cam_%s.log", dirData, file.Name(), time.Now().Format("15-04-05_02-01-2006"))) fmt.Sprintf("%s/%s/reader-cam_%s.log", dirData, file.Name(), strconv.FormatInt(time.Now().Unix(), 10)))
res, err := storage.ReadDir(fmt.Sprintf("%s/%s", dirData, file.Name())) res, err := storage.ReadDir(fmt.Sprintf("%s/%s", dirData, file.Name()))
if err != nil { if err != nil {
@ -141,13 +141,13 @@ func CreateVideo(dir string) error {
filename, _ := strings.CutSuffix(filenames[i], ".insit") filename, _ := strings.CutSuffix(filenames[i], ".insit")
tsFilename := fmt.Sprintf("%s/%s/%s/%s.ts", dirData, file.Name(), resolution, filename) tsFilename := fmt.Sprintf("%s/%s/%s/%s.ts", dirData, file.Name(), resolution, filename)
currentMpegtsMuxer := processor.MpegtsMuxer{ currentMpegTSMuxer := processor.MpegTSMuxer{
FileName: tsFilename, FileName: tsFilename,
H264Format: &h264Format, H264Format: &h264Format,
Mpeg4AudioFormat: &aacFormat, Mpeg4AudioFormat: &aacFormat,
} }
err = currentMpegtsMuxer.Initialize() err = currentMpegTSMuxer.Initialize()
if err != nil { if err != nil {
cam.Error("init muxer error:", zap.String("filename", filenames[i]), zap.Error(err)) cam.Error("init muxer error:", zap.String("filename", filenames[i]), zap.Error(err))
return return
@ -187,7 +187,7 @@ func CreateVideo(dir string) error {
switch pkt.Type { switch pkt.Type {
case storage.PacketTypeH264: case storage.PacketTypeH264:
// Encode the access unit into MPEG-TS. // Encode the access unit into MPEG-TS.
err = currentMpegtsMuxer.WriteH264(pkt.Pts, pkt.H264AUs) err = currentMpegTSMuxer.WriteH264(pkt.Pts, pkt.H264AUs)
if err != nil { if err != nil {
cam.Warn( cam.Warn(
"write H264 packet error:", zap.String("filename", filenames[i]), zap.Error(err)) "write H264 packet error:", zap.String("filename", filenames[i]), zap.Error(err))
@ -201,7 +201,7 @@ func CreateVideo(dir string) error {
} }
// Encode the access unit into MPEG-TS. // Encode the access unit into MPEG-TS.
err = currentMpegtsMuxer.WriteAAC([][]byte{au}, pkt.Pts) err = currentMpegTSMuxer.WriteAAC([][]byte{au}, pkt.Pts)
if err != nil { if err != nil {
cam.Warn( cam.Warn(
"write G711 packet error:", zap.String("filename", filenames[i]), zap.Error(err)) "write G711 packet error:", zap.String("filename", filenames[i]), zap.Error(err))
@ -209,7 +209,7 @@ func CreateVideo(dir string) error {
} }
} }
} }
currentMpegtsMuxer.Close() currentMpegTSMuxer.Close()
if storage.Exists(tsFilename) { if storage.Exists(tsFilename) {
time.Sleep(period * time.Second) time.Sleep(period * time.Second)