2023-09-08 14:56:21 +05:00
|
|
|
package transcoder
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
"os"
|
|
|
|
"io"
|
|
|
|
)
|
|
|
|
|
|
|
|
func NewTranscoder(stream_key string) (io.WriteCloser, error) {
|
|
|
|
base_dir, _ := os.UserHomeDir()
|
2023-10-26 00:18:34 +05:00
|
|
|
command := "hls-transcoder-2"
|
2023-09-08 14:56:21 +05:00
|
|
|
command_args := []string{
|
2023-10-26 00:18:34 +05:00
|
|
|
"4",
|
|
|
|
"/vid/" + stream_key + "/",
|
|
|
|
"4",
|
2023-09-08 14:56:21 +05:00
|
|
|
}
|
|
|
|
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
|
|
|
|
}
|