-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (40 loc) · 1.02 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"os"
// "fmt"
"net/http"
"mime"
"mime/multipart"
"io/ioutil"
// "time"
// "strconv"
// "log"
)
func check(e error) {
if e != nil {
os.Stderr.WriteString("Panic?")
panic(e)
}
}
func generateImage() {
req, _ := http.NewRequest("GET", "http://127.0.0.1:42243/https/stream/mixed?video=mpjpeg&audio=aac&resolution=hd", nil)
resp, _ := http.DefaultClient.Do(req)
_, params, _ := mime.ParseMediaType(resp.Header.Get("Content-Type"))
mr := multipart.NewReader(resp.Body, params["boundary"])
for part, err := mr.NextPart(); err == nil; part, err = mr.NextPart() {
// log.Println("Part. Type: "+part.Header.Get("Content-Type"))
if part.Header.Get("Content-Type") != "video/x-h264" {
// log.Println("Not h264")
continue
}
value, _ := ioutil.ReadAll(part)
_, err := os.Stdout.Write(value)
check(err)
}
}
func main() {
// fmt.Println("running")
generateImage()
// http.HandleFunc("/", handler)
// log.Fatal(http.ListenAndServe(":8080", nil))
}