shorten playlist size, use stream key to construct uri for http server
This commit is contained in:
parent
223bbf40f7
commit
14336095ea
2 changed files with 8 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue