-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starting to add further output options
Signed-off-by: Lukas Bachschwell <lukas@lbsfilm.at>
- Loading branch information
Showing
3 changed files
with
51 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package main | ||
|
||
import ( | ||
"io" | ||
"os/exec" | ||
"syscall" | ||
|
||
log "github.com/s00500/env_logger" | ||
) | ||
|
||
type StreamSink interface { | ||
StartInstance() (io.WriteCloser, func()) | ||
} | ||
|
||
type FFPlaySink struct { | ||
} | ||
|
||
func (sink FFPlaySink) StartInstance() (io.WriteCloser, func()) { | ||
additionalArgs := []string{"-fast", "-flags2", "fast", "-fflags", "nobuffer", "-flags", "low_delay", "-strict", "experimental", "-vf", "setpts=N/60/TB", "-framedrop", "-sync", "ext", "-probesize", "32", "-analyzeduration", "0"} | ||
args := []string{"-i", "-"} | ||
args = append(args, additionalArgs...) | ||
cmd := exec.Command("ffplay", args...) | ||
stdin, err := cmd.StdinPipe() | ||
if err != nil { | ||
log.Fatal("Could not get ffplay stdin") | ||
} | ||
log.MustFatal(cmd.Start()) | ||
return stdin, func() { | ||
cmd.Process.Signal(syscall.SIGKILL) // Not ellegant... could try sigterm and wait before... | ||
} | ||
} | ||
|
||
type UdpSink struct { | ||
} | ||
|
||
func (sink UdpSink) StartInstance() (io.WriteCloser, func()) { | ||
additionalArgs := []string{"-vcodec", "mpeg4", "-v", "0", "-f", "mpegts", "udp://127.0.0.1:23000"} | ||
args := []string{"-i", "-"} | ||
args = append(args, additionalArgs...) | ||
cmd := exec.Command("ffmpeg", args...) | ||
stdin, err := cmd.StdinPipe() | ||
if err != nil { | ||
log.Fatal("Could not get ffmpeg stdin") | ||
} | ||
log.MustFatal(cmd.Start()) | ||
return stdin, func() { | ||
cmd.Process.Signal(syscall.SIGKILL) // Not ellegant... could try sigterm and wait before... | ||
} | ||
} |