伪代码如下:
func main() {
url := "http://a.mp4"
args := strings.Split("ffmpeg -y -i pipe:0 -f mpegts pipe:1", " ")
ctx, cancel := context.WithCancel(context.Background())
cmd := exec.CommandContext(ctx, args[0], args[1:]...)
pipe0, _ := cmd.StdinPipe()
pipe1, _ := cmd.StdoutPipe()
cmd.Start()
go func () {
cmd.Wait()
}
go func () {
file := os.Openfile....
io.Copy(file, pipe1)
}
io.Copy(pipe0, http.resp.body)
}
问题是,write 完成了,但是我不确定转码完成了没。去监听 stderr 吗?看 stderr 的已完成转码时长是不是等于预期?