Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
Create pipe in tmp directory instead of cwd
Gabe Kangasd0ec846b30e6
diff --git a/ffmpeg.go b/ffmpeg.goindex da73b77001..f117d8888e 100644--- a/ffmpeg.go+++ b/ffmpeg.go@@ -20,8 +20,9 @@ func startFfmpeg(configuration Config) {}log.Printf("Starting transcoder saving to /%s.", outputDir)+ pipePath := getTempPipePath()- ffmpegCmd := "cat streampipe.flv | " + configuration.FFMpegPath ++ ffmpegCmd := "cat " + pipePath + " | " + configuration.FFMpegPath +" -hide_banner -i pipe: -vf scale=" + strconv.Itoa(configuration.VideoSettings.ResolutionWidth) + ":-2 -g 48 -keyint_min 48 -preset ultrafast -f hls -hls_list_size 30 -hls_time " +strconv.Itoa(configuration.VideoSettings.ChunkLengthInSeconds) + " -strftime 1 -use_localtime 1 -hls_segment_filename '" +outputDir + "/stream-%Y%m%d-%s.ts' -hls_flags delete_segments -segment_wrap 100 " + hlsPlaylistNamediff --git a/handler.go b/handler.goindex 25fdcaa9e8..54fb31d2b3 100644--- a/handler.go+++ b/handler.go@@ -6,7 +6,6 @@ import ("io""log""os"- "path/filepath""syscall""github.com/pkg/errors"@@ -52,10 +51,9 @@ func (h *Handler) OnPublish(timestamp uint32, cmd *rtmpmsg.NetStreamPublish) errreturn errors.New("PublishingName is empty")}- // Record streams as FLV!- p := filepath.Join(- filepath.Clean(filepath.Join("./", fmt.Sprintf("%s.flv", "streampipe"))),- )+ // Record streams as FLV+ p := getTempPipePath()+ fmt.Println(p)syscall.Mkfifo(p, 0666)f, err := os.OpenFile(p, os.O_RDWR, os.ModeNamedPipe)if err != nil {diff --git a/main.go b/main.goindex add7ad56bb..bc2b5a93e4 100644--- a/main.go+++ b/main.go@@ -50,5 +50,7 @@ func startChatServer() {// static fileshttp.Handle("/", http.FileServer(http.Dir("webroot")))+ log.Printf("Starting public web server on port %d", configuration.WebServerPort)+log.Fatal(http.ListenAndServe(":"+strconv.Itoa(configuration.WebServerPort), nil))}diff --git a/utils.go b/utils.goindex 0de198e2cf..ad55fc84bc 100644--- a/utils.go+++ b/utils.go@@ -5,6 +5,7 @@ import ("io/ioutil""log""os"+ "path/filepath""time")@@ -30,6 +31,10 @@ func touch(fileName string) {}}+func getTempPipePath() string {+ return filepath.Join(os.TempDir(), "streampipe.flv")+}+func copy(src, dst string) {input, err := ioutil.ReadFile(src)if err != nil {