diff --git a/rtmp/data_loop.go b/rtmp/data_loop.go index c40cfe8..c911158 100644 --- a/rtmp/data_loop.go +++ b/rtmp/data_loop.go @@ -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 diff --git a/rtmp/flv/writer.go b/rtmp/flv/writer.go index 26e6ad1..711a1b7 100644 --- a/rtmp/flv/writer.go +++ b/rtmp/flv/writer.go @@ -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 {