stream-server/transcoder/transcoder.go

25 lines
489 B
Go

package transcoder
import (
"os/exec"
"os"
"io"
)
func NewTranscoder(stream_key string) (io.WriteCloser, error) {
base_dir, _ := os.UserHomeDir()
command := "hls-transcoder-2"
command_args := []string{
"4",
"/vid/" + stream_key + "/",
"4",
}
transcoder := exec.Command(command, command_args...)
transcoder.Dir = base_dir + "/live/" + stream_key + "/"
data_in, err := transcoder.StdinPipe()
if err != nil {
return nil, err
}
transcoder.Start()
return data_in, nil
}