Answer the question
In order to leave comments, you need to log in
How to convert rstp streams of ip cameras to images in golang in parallel?
Hello!
The following situation is the n-th number of ip cameras from which it is necessary to convert the rtsp stream into an image and it is desirable to do this in parallel.
Made a test case with 3 cameras, looks like this:
func convert1() {
cmd := "/usr/bin/ffmpeg"
args := []string{"-i", "rtsp://ip:port", "-f", "image2", "filename.ext"}
exec.Command(cmd, args...).Run()
}
func convert2() {
cmd := "/usr/bin/ffmpeg"
args := []string{"-i", "rtsp://ip:port", "-f", "image2", "filename.ext"}
exec.Command(cmd, args...).Run()
}
func convert3() {
cmd := "/usr/bin/ffmpeg"
args := []string{"-i", "rtsp://ip:port", "-f", "image2", "filename.ext"}
exec.Command(cmd, args...).Run()
}
func main() {
go convert1()
go convert2()
convert3()
fmt.Println("RTSP streams of videocameras successfully converted!")
}
Answer the question
In order to leave comments, you need to log in
Make one conversion function that would take parameters: ip, port, output file.
In a loop, run this function with the desired parameters through go
To wait for the completion of goroutines, you can use sync.WaitGroup
nathanleclaire.com/blog/2014/02/15/how-to-wait-for...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question