简体   繁体   中英

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

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 rate 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM