Compare commits

..

6 commits

3 changed files with 27 additions and 5 deletions

View file

@ -8,6 +8,8 @@ Uses the std lib http server implementation for the http serving side.
**Not intended for actual use**. The stream key use is not secure and is used to handle directories without a user db system, than to provide auth. Same goes for the SRT passphrase. Also just accepts connections so will get DDOS'd immediately.
**Update**: main branch has been tested over a network. RTMP should now work fine, SRT "works" with a few modifications. The RTT ping log-buffer slice must be extended depending on network latency (try ~2x latency/10ms, could adjust automatically, but eh). Also will inevitably crash on poor connections due to the lack of DROPSEQ handling, but will work perfectly fine during the initial 3-10s you get.
Limits to a single stream at a time, mostly for the lack of db to handle connections and user information rather than concurrency problems.
Currently always transcodes to vp9 + opus, segments to fragmented mp4. Creates one segment playlist, no manifest. Uses ffmpeg

View file

@ -147,7 +147,12 @@ func (agent *SRTManager) process_conclusion(packet *Packet) (*Packet) {
resp_packet := agent.create_conclusion_resp()
if packet.packet_type == HANDSHAKE {
hs_cif := packet.cif.(*HandshakeCIF)
if hs_cif.hs_type == 0xffffffff && hs_cif.syn_cookie == agent.syn_cookie {
// allow previous shotgunned induction requests to dissipate
if hs_cif.hs_type != 0xffffffff {
return nil
}
if hs_cif.syn_cookie == agent.syn_cookie {
for _, v := range hs_cif.hs_extensions {
// force client to add a stream_id for output location
// to do: add encryption handling

View file

@ -8,11 +8,26 @@ import (
func NewTranscoder(stream_key string) (io.WriteCloser, error) {
base_dir, _ := os.UserHomeDir()
command := "hls-transcoder-2"
command := "ffmpeg"
command_args := []string{
"4",
"/vid/" + stream_key + "/",
"4",
"-probesize", "500",
"-i", "pipe:0",
"-c:a", "libopus",
"-c:v", "vp9",
"-quality", "realtime",
"-speed", "7",
"-tile-columns", "4",
"-frame-parallel", "1",
"-threads", "8",
"-b:v", "1M",
"-g", "30",
"-hls_time", "6",
"-hls_list_size", "4",
"-hls_base_url", "/vid/" + stream_key + "/",
"-hls_segment_type", "fmp4",
"-hls_flags", "delete_segments",
"-hls_flags", "+program_date_time",
"stream.m3u8",
}
transcoder := exec.Command(command, command_args...)
transcoder.Dir = base_dir + "/live/" + stream_key + "/"