floostack / transcoder

Transcoding library implementation in Golang
MIT License
270 stars 74 forks source link

Piping Example #6

Open thewalrusisben opened 4 years ago

thewalrusisben commented 4 years ago

Hey there, just wondering if it would be possible to provide a minimal example of how to use the InputPipe / OutputPipe methods available. I've been trying to use them but am not totally sure how the readers and writers are supposed to be set up.

Thank you!

meandrewdev commented 4 years ago
type DiscardCloser struct {
    io.Writer
}

func (DiscardCloser) Close() error { return nil }

rc := ioutil.NopCloser(input)
var wc io.WriteCloser = &DiscardCloser{}
progress, err := ffmpeg.
        New(ffmpegConf).
        InputPipe(&wc, &rc).
        Output(output).
        WithOptions(opts).
        Start(opts)

This code generating error "missing input option"

Mran commented 4 years ago

@thewalrusisben @confirm2315

cmd := exec.Command("ffmpeg", "-i", path, "-ss", sTime, "-t", "3", "-vn", "-f", "mp3", "pipe:")

r, _ := cmd.StdoutPipe()

_ = cmd.Start()

bb, _ := ioutil.ReadAll(r)

I readed his code, seems not support pipe yet

this is my code. just notice the argument "-f",and "pipe:"