Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV stream captured CAM with H264 (mp4) codec

I like to stream the web cam pictures wich are captured by opencv. I think about a solution with ffmpeg and live555 (poorly they are not document so well). My problems are:

  1. How can convert the captured images to a H264 format so the picures/second match. If it is in a loop I get more than 25 pictures/sekond and the video is to fast.

  2. How can i directly stream the converted H264 stream over the network via rtp / rtps or similar.

Thanks for your help!

like image 262
user1200794 Avatar asked Jul 03 '12 12:07

user1200794


2 Answers

  1. This is a common problem.
    • if you are not require to distribute your software (private use / server side / open-source), you may use FFMpeg compiled with x264 encoder, there's a config flag for that in FFMpeg's config script.
    • If you do require to distribute your software, i don't know any LGPL licensed library for that, i believe there is no such library. You'd have to use some paid solution.
  2. You should implement DeviceSource.cpp, see DeviceSource.hh and use it as the FramedSource.

Edit: Apple revealed video encoder API, allowing access to stream of h264 frames in iOS8

like image 120
Avishay Cohen Avatar answered Nov 03 '22 08:11

Avishay Cohen


For an example of how to use x264 and Live555 to encode and stream frames, see the following:

  1. spyPanda open source project.
  2. How to write a Live555 FramedSource to allow me to stream H.264 live SO question.
like image 24
kshahar Avatar answered Nov 03 '22 08:11

kshahar