3d0c / gmf

Go Media Framework
MIT License
891 stars 170 forks source link

Help - Decoding H.264 Stream from Channel #77

Closed SMerrony closed 6 years ago

SMerrony commented 6 years ago

I really have tried reading the examples and tests, but I can't seem to put together the code to extract RGBA images from a stream of H.264 data coming in as a channel of []byte.

Nearly all the examples assume a file as the source; I think I need to use AVIO for a channel, but nothing I try seems to work.

Can anyone provide either the steps I need to follow, or code to achieve this?

3d0c commented 6 years ago

Yeah, it's non trivial problem. In general to achieve it you have to implement custom reader and seeker for "avio" context. See prototypes of these function in avio.go. But, it really depends on what "kind" of stream do you have. Do you have an ability to range reading and do seek? E.g. if you have a video file, which is serving by http server, then you can do it by using HTTP-Range header.

SMerrony commented 6 years ago

The "kind" of steam is a channel of []byte, as I said. It's a raw stream from a camera. I can write the channel to a pipe file and mplayer will play it fine - but I want to achieve something like that inside my application and I thought gmf would be the way to go.

SMerrony commented 6 years ago

I have got this working by munging together various examples - video-to-image was key.