mirror of
https://github.com/owncast/owncast.git
synced 2025-11-03 04:27:18 +08:00
Create pipe in tmp directory instead of cwd
This commit is contained in:
@ -20,8 +20,9 @@ func startFfmpeg(configuration Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Starting transcoder saving to /%s.", outputDir)
|
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 " +
|
" -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 '" +
|
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 " + hlsPlaylistName
|
outputDir + "/stream-%Y%m%d-%s.ts' -hls_flags delete_segments -segment_wrap 100 " + hlsPlaylistName
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -52,10 +51,9 @@ func (h *Handler) OnPublish(timestamp uint32, cmd *rtmpmsg.NetStreamPublish) err
|
|||||||
return errors.New("PublishingName is empty")
|
return errors.New("PublishingName is empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record streams as FLV!
|
// Record streams as FLV
|
||||||
p := filepath.Join(
|
p := getTempPipePath()
|
||||||
filepath.Clean(filepath.Join("./", fmt.Sprintf("%s.flv", "streampipe"))),
|
fmt.Println(p)
|
||||||
)
|
|
||||||
syscall.Mkfifo(p, 0666)
|
syscall.Mkfifo(p, 0666)
|
||||||
f, err := os.OpenFile(p, os.O_RDWR, os.ModeNamedPipe)
|
f, err := os.OpenFile(p, os.O_RDWR, os.ModeNamedPipe)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
2
main.go
2
main.go
@ -50,5 +50,7 @@ func startChatServer() {
|
|||||||
// static files
|
// static files
|
||||||
http.Handle("/", http.FileServer(http.Dir("webroot")))
|
http.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))
|
log.Fatal(http.ListenAndServe(":"+strconv.Itoa(configuration.WebServerPort), nil))
|
||||||
}
|
}
|
||||||
|
|||||||
5
utils.go
5
utils.go
@ -5,6 +5,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -30,6 +31,10 @@ func touch(fileName string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getTempPipePath() string {
|
||||||
|
return filepath.Join(os.TempDir(), "streampipe.flv")
|
||||||
|
}
|
||||||
|
|
||||||
func copy(src, dst string) {
|
func copy(src, dst string) {
|
||||||
input, err := ioutil.ReadFile(src)
|
input, err := ioutil.ReadFile(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user