transcoder icon indicating copy to clipboard operation
transcoder copied to clipboard

Piping Example

Open thewalrusisben opened this issue 4 years ago • 2 comments

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!

thewalrusisben avatar Aug 15 '20 09:08 thewalrusisben

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"

meandrewdev avatar Aug 27 '20 08:08 meandrewdev

@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:"

Mran avatar Sep 01 '20 02:09 Mran