Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Support for Pipe Input/Output #21

Open
nmorenor opened this issue Mar 22, 2023 · 2 comments
Open

Support for Pipe Input/Output #21

nmorenor opened this issue Mar 22, 2023 · 2 comments

Comments

@nmorenor
Copy link

nmorenor commented Mar 22, 2023

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.

@nmorenor
Copy link
Author

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?

@nmorenor
Copy link
Author

nmorenor commented Mar 25, 2023

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant