Skip to content

Commit

Permalink
Merge pull request #54 from PeteLawrence/feature/rtsp_transport
Browse files Browse the repository at this point in the history
Add in a --rtsptransport flag to realtime command
  • Loading branch information
tphakala authored Mar 17, 2024
2 parents da76ca8 + 1d82646 commit b3e6f2e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/realtime/realtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func setupFlags(cmd *cobra.Command, settings *conf.Settings) error {
cmd.Flags().StringVar(&settings.Realtime.Log.Path, "logpath", viper.GetString("realtime.log.path"), "Path to save log files")
cmd.Flags().BoolVar(&settings.Realtime.ProcessingTime, "processingtime", viper.GetBool("realtime.processingtime"), "Report processing time for each detection")
cmd.Flags().StringVar(&settings.Realtime.RTSP, "rtsp", viper.GetString("realtime.rtsp"), "URL of RTSP audio stream to capture")
cmd.Flags().StringVar(&settings.Realtime.RTSPTransport, "rtsptransport", viper.GetString("realtime.rtsptransport"), "RTSP transport (tcp/udp)")

// Bind flags to the viper settings
if err := viper.BindPFlags(cmd.Flags()); err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type Settings struct {
}

RTSP string // RTSP stream URL
RTSPTransport string //RTSP Transport Protocol
}

WebServer struct {
Expand Down
6 changes: 6 additions & 0 deletions internal/myaudio/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,14 @@ func captureAudioRTSP(settings *conf.Settings, wg *sync.WaitGroup, quitChan chan
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

rtsp_transport := "udp"
if (settings.Realtime.RTSPTransport != "") {
rtsp_transport = settings.Realtime.RTSPTransport;
}

// Start ffmpeg
cmd := exec.CommandContext(ctx, "ffmpeg",
"-rtsp_transport", rtsp_transport, // RTSP transport protocol (tcp/udp)
"-i", settings.Realtime.RTSP,
"-loglevel", "error",
"-vn", // No video
Expand Down

0 comments on commit b3e6f2e

Please sign in to comment.