Read incoming stream from stdin

This commit is contained in:
Rob Watson 2020-07-13 14:28:19 +02:00
parent edf807851b
commit 9d96e0236a
2 changed files with 3 additions and 23 deletions

25
main.go
View File

@ -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)

1
pkg/web/web.go Normal file
View File

@ -0,0 +1 @@
package web