Support for Pipe Input/Output
nmorenor opened this issue · 2 comments
Library looks great, I'm wondering if there will be a way to have pipes to somehow work! More specifically for doing this kind of thing https://github.com/pion/example-webrtc-applications/blob/master/gocv-receive/main.go
ffmpeg := exec.Command("ffmpeg", "-i", "pipe:0", "-pix_fmt", "bgr24", "-s", strconv.Itoa(frameX)+"x"+strconv.Itoa(frameY), "-f", "rawvideo", "pipe:1")
Where they read/write the ffmpeg as input/output pipe. Found something over stackoverflow, other or gist but not sure what would be the right approach to support this.
Been thinking about this and did a bit more investigation. One approach to have this to work could be with a map of string -> io.Reader where the key of the map is the "filename" (dummyfilename).
Have a C IOReadFunc like the gist call a go function that returns the C.Bytes also making sure that after you do the memcopy to the IOReadFunc you free the memory from the thing returned by the go function, this go function will need to send the "filename" to the go function somehow, may be this is the data param on the C IOReadFunc
There could be a newMedia function that has as a parameter the filename and io.Reader that will use this alternative method to grab data for the video. I think in this way you could handle either reading video file from disk of from somewhere else. It may also need a close function to handle the memory clean when media (c memory things) is instantiated with an io.Reader.
Will give it a try when I have a time. What do you think? Could this work?
Have worked on something while it kid of works, video works but only the mkv file, if I remove the comments on the examples/player-stream/main.go relative to errors it does not work for context:
// go func(err error) {
// errs <- err
// }(err)
Any ideas?
master...nmorenor:reisen:master
Cheers