Read incoming stream from stdin
This commit is contained in:
parent
edf807851b
commit
9d96e0236a
25
main.go
25
main.go
|
@ -1,10 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"segmenta/pkg/generator"
|
"segmenta/pkg/generator"
|
||||||
"segmenta/pkg/handler"
|
"segmenta/pkg/handler"
|
||||||
|
@ -13,32 +11,13 @@ import (
|
||||||
// How to stream a static video file as a "live" stream?
|
// How to stream a static video file as a "live" stream?
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var url string
|
|
||||||
|
|
||||||
flag.StringVar(&url, "url", "", "URL to open")
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
if url == "" {
|
|
||||||
fmt.Println("Usage:")
|
|
||||||
flag.PrintDefaults()
|
|
||||||
os.Exit(-1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// open URL:
|
|
||||||
client := http.Client{}
|
|
||||||
resp, err := client.Get(url)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
handler := handler.NewS3Handler("rfwatson-hls", "public-read")
|
handler := handler.NewS3Handler("rfwatson-hls", "public-read")
|
||||||
generator := generator.NewFFMPEGGenerator("test", resp.Body)
|
generator := generator.NewFFMPEGGenerator("test", os.Stdin)
|
||||||
generator.AddHandler(handler)
|
generator.AddHandler(handler)
|
||||||
|
|
||||||
fmt.Println("starting generator...")
|
fmt.Println("starting generator...")
|
||||||
|
|
||||||
err = generator.Generate()
|
err := generator.Generate()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
package web
|
Loading…
Reference in New Issue