mirror of
https://github.com/xfrr/goffmpeg.git
synced 2025-10-04 23:52:40 +08:00
command wrapper
making transcoder
This commit is contained in:
29
transcoder/command.go
Normal file
29
transcoder/command.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package transcoder
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
type Worker struct {
|
||||
Command string
|
||||
Args string
|
||||
Output chan string
|
||||
}
|
||||
|
||||
func (cmd *Worker) Run() {
|
||||
out, err := exec.Command(cmd.Command, cmd.Args).Output()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
cmd.Output <- string(out)
|
||||
}
|
||||
|
||||
func Collect(c chan string) {
|
||||
for {
|
||||
msg := <-c
|
||||
fmt.Printf("The command result is %s\n", msg)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user