Deleted generation M3U8 playlist.

This commit is contained in:
Сергей Петров 2025-03-26 11:01:29 +05:00
parent 61971d0acb
commit 22502fea9d
5 changed files with 26 additions and 32 deletions

View File

@ -2,9 +2,10 @@ package main
import ( import (
"flag" "flag"
"fmt"
"git.insit.tech/psa/rtsp_reader-writer/writer/internal/config" "git.insit.tech/psa/rtsp_reader-writer/writer/internal/config"
"git.insit.tech/psa/rtsp_reader-writer/writer/internal/ingest/rtsp" "git.insit.tech/psa/rtsp_reader-writer/writer/internal/ingest/rtsp"
"log" "git.insit.tech/sas/rtsp_proxy/core/log"
) )
func main() { func main() {
@ -17,14 +18,16 @@ func main() {
panic(err) panic(err)
} }
Log := log.MainLogging("/home/psa/GoRepository/" + "/data/" + "camera54-centr-kirova-kalinina")
// Connect to each camera. // Connect to each camera.
for _, link := range cams { for _, link := range cams {
log.Printf("process camera:\n %s\n", link) fmt.Printf("process camera:\n %s\n", link)
go func() { go func() {
err = rtsp.StartWriter(*directory, 60, link) err = rtsp.StartWriter(*directory, 60, link, Log)
if err != nil { if err != nil {
log.Printf("procRTSP function error for camera %s: %s", link, err.Error()) fmt.Printf("procRTSP function error for camera %s: %s", link, err.Error())
} }
}() }()
} }

View File

@ -3,7 +3,7 @@ module git.insit.tech/psa/rtsp_reader-writer/writer
go 1.24.1 go 1.24.1
require ( require (
git.insit.tech/sas/rtsp_proxy v0.0.0-20250325071536-7b97f96d64e6 git.insit.tech/sas/rtsp_proxy v0.0.0-20250326040356-446f7f0578d9
github.com/Eyevinn/mp4ff v0.47.0 github.com/Eyevinn/mp4ff v0.47.0
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
@ -11,7 +11,6 @@ require (
github.com/gen2brain/aac-go v0.0.0-20230119102159-ef1e76509d21 github.com/gen2brain/aac-go v0.0.0-20230119102159-ef1e76509d21
github.com/golang/snappy v1.0.0 github.com/golang/snappy v1.0.0
github.com/pion/rtp v1.8.13 github.com/pion/rtp v1.8.13
github.com/zaf/g711 v1.4.0
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
) )
@ -19,11 +18,10 @@ require (
github.com/asticode/go-astikit v0.52.0 // indirect github.com/asticode/go-astikit v0.52.0 // indirect
github.com/asticode/go-astits v1.13.0 // indirect github.com/asticode/go-astits v1.13.0 // indirect
github.com/google/uuid v1.6.0 // indirect github.com/google/uuid v1.6.0 // indirect
github.com/grafov/m3u8 v0.12.1 // indirect
github.com/pion/randutil v0.1.0 // indirect github.com/pion/randutil v0.1.0 // indirect
github.com/pion/rtcp v1.2.15 // indirect github.com/pion/rtcp v1.2.15 // indirect
github.com/pion/sdp/v3 v3.0.11 // indirect github.com/pion/sdp/v3 v3.0.11 // indirect
github.com/zencoder/go-dash v0.0.0-20201006100653-2f93b14912b2 // indirect github.com/zaf/g711 v1.4.0 // indirect
go.uber.org/multierr v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect go.uber.org/zap v1.27.0 // indirect
golang.org/x/net v0.37.0 // indirect golang.org/x/net v0.37.0 // indirect

View File

@ -1,5 +1,5 @@
git.insit.tech/sas/rtsp_proxy v0.0.0-20250325071536-7b97f96d64e6 h1:9WyrbPswZtjr3sqoCYaqus22j5st2HuVjWMiBTAorsM= git.insit.tech/sas/rtsp_proxy v0.0.0-20250326040356-446f7f0578d9 h1:8aOLn23rkkXR/mpkOtbaNrCWsiBs0Pl+/ds3CzUuHZo=
git.insit.tech/sas/rtsp_proxy v0.0.0-20250325071536-7b97f96d64e6/go.mod h1:/AHWd1Otr+ikOLWzpXtoozzifEx9ZKou+R6DgwaEzr0= git.insit.tech/sas/rtsp_proxy v0.0.0-20250326040356-446f7f0578d9/go.mod h1:/AHWd1Otr+ikOLWzpXtoozzifEx9ZKou+R6DgwaEzr0=
github.com/Eyevinn/mp4ff v0.47.0 h1:XSSHYt5+I0fyOnHWoNwM72DtivlmHFR0V9azgIi+ZVU= github.com/Eyevinn/mp4ff v0.47.0 h1:XSSHYt5+I0fyOnHWoNwM72DtivlmHFR0V9azgIi+ZVU=
github.com/Eyevinn/mp4ff v0.47.0/go.mod h1:hJNUUqOBryLAzUW9wpCJyw2HaI+TCd2rUPhafoS5lgg= github.com/Eyevinn/mp4ff v0.47.0/go.mod h1:hJNUUqOBryLAzUW9wpCJyw2HaI+TCd2rUPhafoS5lgg=
github.com/asticode/go-astikit v0.30.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0= github.com/asticode/go-astikit v0.30.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0=

View File

@ -4,6 +4,7 @@ import (
"encoding/binary" "encoding/binary"
"errors" "errors"
"fmt" "fmt"
"go.uber.org/zap"
"log" "log"
"os" "os"
"strconv" "strconv"
@ -21,11 +22,11 @@ import (
) )
// StartWriter starts the program. // StartWriter starts the program.
func StartWriter(dir string, period int, link string) error { func StartWriter(dir string, period int, link string, Log *zap.Logger) error {
err := RTSP(dir, period, link) err := RTSP(dir, period, link, Log)
if err != nil { if err != nil {
// Change domain if a camera was flipped to another domain. // Change domain if a camera was flipped to another domain.
err = changeDomain(dir, period, link, err) err = changeDomain(dir, period, link, err, Log)
if err != nil { if err != nil {
return fmt.Errorf("change domain error: %w", err) return fmt.Errorf("change domain error: %w", err)
} }
@ -70,15 +71,6 @@ func RTSP(dir string, period int, link string) error {
return fmt.Errorf("mkdirall error: %w", err) return fmt.Errorf("mkdirall error: %w", err)
} }
////////////////////////////////////////////////////////////////////////////////////////////////////
/*
// Create M3U8 playlist.
go gen.MediaPlaylistGenerator(dir+"/data/"+cutURI, "", fn.Duration, resolutions)
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// Find formats. // Find formats.
var audioFormat string var audioFormat string
var videoFormat string var videoFormat string
@ -1121,16 +1113,16 @@ func RTSP(dir string, period int, link string) error {
} }
// changeDomain changes domain if a camera was flipped to another domain. // changeDomain changes domain if a camera was flipped to another domain.
func changeDomain(dir string, period int, link string, err error) error { func changeDomain(dir string, period int, link string, err error, Log *zap.Logger) error {
err2 := errors.New("404 (Not found)") err2 := errors.New("404 (Not found)")
if errors.As(err, &err2) { if errors.As(err, &err2) {
if strings.Contains(link, "video-1") { if strings.Contains(link, "video-1") {
err = RTSP(dir, period, strings.Replace(link, "video-1", "video-2", 1)) err = RTSP(dir, period, strings.Replace(link, "video-1", "video-2", 1), Log)
if err != nil { if err != nil {
return err return err
} }
} else { } else {
err = RTSP(dir, period, strings.Replace(link, "video-2", "video-1", 1)) err = RTSP(dir, period, strings.Replace(link, "video-2", "video-1", 1), Log)
if err != nil { if err != nil {
return err return err
} }

View File

@ -15,13 +15,14 @@ func main() {
seg := Segment{ seg := Segment{
Date: now.Format(time.RFC3339), Date: now.Format(time.RFC3339),
Duration: "1m", Duration: "1m",
Packets: InterleavedPacket{ Packets: []InterleavedPacket{
{
Type: PacketTypeH264, Type: PacketTypeH264,
Pts: now.UnixNano(), Pts: now.UnixNano(),
H264AUs: [][]byte{ H264AUs: [][]byte{
[]byte{0x00, 0x01, 0x02}, []byte{0x00, 0x01, 0x02},
[]byte{0x03, 0x04}, []byte{0x03, 0x04},
},
}, },
}, },
} }