I have an IP camera and I receive from that IP camera snapshot JPEGs. It averages around 10fps.

Currently I am invoking a [web method] in my c# desktop application to upload the JPEG (converted into a byte array). There, on the server the User can view these images like a video feed. This works well. On the client-side the RAM usage goes up quite high.

If I can encode the JPEG images somehow using ffmpeg then the amount of data would be reduced (I guess).

Or is there a way to take a stream of bytes from the JPEGs coming in and somehow redirect to the server where I could have another ffmpeg process running waiting to accept this stream and save the image stream to individual images?

I have looked around (spent several days) and tried different techniques to reduce the 'weight' of the images but nothing seems to work. I am now looking at ffmpeg as my last hope.

  • Ah, I was about to reply :) Ideally of course you'd not stream images but a compressed video stream. XviD is rather fast, for example. Depending on the server power, x264 can be tuned to be fast as well. You'd end up with a really small video stream instead of full images. Regardless of whether you create an image or video stream, you should be able to send that via UDP to another server, and parse it from there. I have zero experience with C#, but that should be feasible in any language. – slhck Nov 24 '13 at 10:42
  • Hi, OK I understand. What I would like though is any help with the ffmpeg command line arguments? – Andrew Simpson Nov 24 '13 at 10:45

If you don't use FFmpeg APIs in your code natively, you can also call ffmpeg to output anything you want as a raw bytestream. For example:

ffmpeg -i input -c:v mjpeg -f rawvideo -

The - means that the output is sent to stdout. The ffmpeg diagnostic messages will be sent to stderr, as usual. You could capture this output in your program and stream it via simple UDP transmission to a listening server.

To further compress your stream, you could of course not send image by image, but compress the images as a raw H.264 video stream:

ffmpeg -i input -c:v libx264 -preset ultrafast -f rawvideo -

You'd then parse the incoming stream like that, where - is stdin:

ffmpeg -f rawvideo -c:v h264 -i - output

Of course you'd need to figure out how to pipe the data properly. ffmpeg can also read from Unix pipes.

I've done something similar without FFmpeg, using the XviD encoder libraries in C++ to produce a video bitstream, then send it over UDP to another machine, and parse it from there. It's doable, but it depends on how your networking stack looks like and how sophisticated (and error-resilient) it needs to be.

  • Hi, thanks for that. The only issue i have is the standard input. But as you rightly mentioned it is a programming issue and not ffmpeg. I will specifically ask this question on StackOverFlow. thanks – Andrew Simpson Nov 24 '13 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.