开发者

Service a live OpenCV H.264 stream through Live555 on Windows

开发者 https://www.devze.com 2023-03-17 18:09 出处:网络
Totally new to this! As the title says, I\'m trying to serve a stream from OpenCV through Live555 using H.264 that is captured from a webcam.

Totally new to this! As the title says, I'm trying to serve a stream from OpenCV through Live555 using H.264 that is captured from a webcam.

I've tried something like:

 #define LOCALADDRESS "rtsp://localhost:8081"   // Address media is served
 #define FOURCCCODEC CV_FOURCC('H','2','6','4') // H.264 codec
 #define FPS 25                                // Frame ra开发者_Python百科te things run at
 m_writer = cvCreateVideoWriter(LOCALADDRESS, FOURCCCODEC, FPS, cvSize(VIDEOWIDTH, VIDEOHEIGHT));

as reading a rtsp stream, is done similarly:

CvCapture *capture = cvCreateFileCapture(LOCALADDRESS);

which doesn't work so I'm turning to Live555. How do I feed a CvCapture encoded in H.264 to be served by Live555? There doesn't seem to be a straitforward way to serve a bytestream from one to another or perhaps I'm missing something.


There really isn't a straight-forward way I know of; certainly nothing that will happen in anything less than a few hundred lines of code.

I'm assuming you want to use an on-demand RTSP server (this is where the server's just sitting there, waiting for a client to connect, and then it starts streaming when the client establishes a connection and makes a request)? If so, this item in the Live555 FAQ applies.

However, Live555 is a weird (possibly misguided?) library, so it's unfortunately a bit more complicated than that. Live555 uses a single thread of operation with an event loop, so what you'll have to do is shove your raw bytestream into a buffer or queue, and then in your subsession class for streaming H.264, you'll check and see if there's available data in the queue and if so, pass it along. If not, schedule another check in a few milliseconds. You'll also need to strip off any NALU identifiers before you pass them along to live555.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号