1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 19:42:20 +00:00

Don't export to ASCII art if the telnet packet is disabled

This commit is contained in:
Yohann D'ANELLO 2020-10-13 00:30:05 +02:00
parent 61ae490a5d
commit ee76951854

View File

@ -47,14 +47,21 @@ func ingestFrom(inputChannel chan srt.Packet) {
} }
}() }()
ffmpeg = exec.Command("ffmpeg", "-hide_banner", "-loglevel", "error", "-re", "-i", "pipe:0", ffmpegArgs := []string{"-hide_banner", "-loglevel", "error", "-re", "-i", "pipe:0",
"-an", "-vcodec", "libvpx", "-crf", "10", "-cpu-used", "5", "-b:v", "6000k", "-maxrate", "8000k", "-bufsize", "12000k", // TODO Change bitrate when changing quality "-an", "-vcodec", "libvpx", "-crf", "10", "-cpu-used", "5", "-b:v", "6000k", "-maxrate", "8000k", "-bufsize", "12000k", // TODO Change bitrate when changing quality
"-qmin", "10", "-qmax", "42", "-threads", "4", "-deadline", "1", "-error-resilient", "1", "-qmin", "10", "-qmax", "42", "-threads", "4", "-deadline", "1", "-error-resilient", "1",
"-auto-alt-ref", "1", "-auto-alt-ref", "1",
"-f", "rtp", "rtp://127.0.0.1:5004", "-f", "rtp", "rtp://127.0.0.1:5004",
"-vn", "-acodec", "libopus", "-cpu-used", "5", "-deadline", "1", "-qmin", "10", "-qmax", "42", "-error-resilient", "1", "-auto-alt-ref", "1", "-vn", "-acodec", "libopus", "-cpu-used", "5", "-deadline", "1", "-qmin", "10", "-qmax", "42", "-error-resilient", "1", "-auto-alt-ref", "1",
"-f", "rtp", "rtp://127.0.0.1:5005", "-f", "rtp", "rtp://127.0.0.1:5005"}
"-an", "-f", "rawvideo", "-vf", fmt.Sprintf("scale=%dx%d", telnet.Cfg.Width, telnet.Cfg.Height), "-pix_fmt", "gray", "pipe:1")
// Export stream to ascii art
if telnet.Cfg.Enabled {
ffmpegArgs = append(ffmpegArgs,
"-an", "-f", "rawvideo", "-vf", fmt.Sprintf("scale=%dx%d", telnet.Cfg.Width, telnet.Cfg.Height), "-pix_fmt", "gray", "pipe:1")
}
ffmpeg = exec.Command("ffmpeg", ffmpegArgs...)
input, err := ffmpeg.StdinPipe() input, err := ffmpeg.StdinPipe()
if err != nil { if err != nil {
@ -65,10 +72,6 @@ func ingestFrom(inputChannel chan srt.Packet) {
if err != nil { if err != nil {
panic(err) panic(err)
} }
output, err := ffmpeg.StdoutPipe()
if err != nil {
panic(err)
}
if err := ffmpeg.Start(); err != nil { if err := ffmpeg.Start(); err != nil {
panic(err) panic(err)
@ -106,8 +109,14 @@ func ingestFrom(inputChannel chan srt.Packet) {
} }
}() }()
// Receive ascii // Receive raw video output and convert it to ASCII art, then forward it TCP
go telnet.ServeAsciiArt(output) if telnet.Cfg.Enabled {
output, err := ffmpeg.StdoutPipe()
if err != nil {
panic(err)
}
go telnet.ServeAsciiArt(output)
}
// Receive audio // Receive audio
go func() { go func() {