shorten playlist size, use stream key to construct uri for http server

This commit is contained in:
Muaz Ahmad 2023-08-21 15:10:07 +05:00
parent 223bbf40f7
commit 14336095ea
2 changed files with 8 additions and 6 deletions

View file

@ -9,8 +9,7 @@ import (
func HandleDataLoop(chnk_wrp_ptr *ChunkWrapper) {
StreamCleanup(chnk_wrp_ptr.params.stream_key, 0)
base_dir, _ := os.UserHomeDir()
file_writer, err := flv.NewFLVWriter(base_dir + "/live/" + chnk_wrp_ptr.params.stream_key + "/")
file_writer, err := flv.NewFLVWriter(chnk_wrp_ptr.params.stream_key)
defer file_writer.Close()
if err != nil {
return

View file

@ -4,27 +4,30 @@ import (
"io"
"os/exec"
"encoding/binary"
"os"
)
type FLVWriter struct {
w io.WriteCloser
}
func NewFLVWriter(stream_dir string) (*FLVWriter, error) {
func NewFLVWriter(stream_key string) (*FLVWriter, error) {
base_dir, _ := os.UserHomeDir()
writer := new(FLVWriter)
transcoder := exec.Command(
"ffmpeg",
"-probesize", "5000",
"-probesize", "500",
"-i", "pipe:0",
"-c:a", "aac",
"-c:v", "h264",
"-b:v", "1M",
"-hls_time", "6",
"-hls_list_size", "10",
"-hls_list_size", "4",
"-hls_base_url", "/vid/" + stream_key + "/",
"-hls_flags", "delete_segments",
"stream.m3u8",
)
transcoder.Dir = stream_dir
transcoder.Dir = base_dir + "/live/" + stream_key + "/"
flvpipe, err := transcoder.StdinPipe()
transcoder.Start()
if err != nil {