Is there a way to get a current frame from video streams (especially from RTSP streams)?

I would like to connect to a camera in my local network and get a snapshot from it to do some further analysis as I would do with ImageCapture[] or CurrentImage[] normally.


  • 1
    $\begingroup$ In theory this might (or might not) work: check VLC (in partcular cvlc) documentation on how to send decoded output to a pipe. Create a named pipe (if you're on a Unix-like system), and pipe the output in there. Use Mathematica's BinaryRead or related functions to read frames one by one. Mathematica has no builtin functionality to read from video streams. This is what'd I look into first if I really had to do this, but honestly, it's a long shot. $\endgroup$ – Szabolcs Jul 9 '15 at 13:21
  • $\begingroup$ There is no built-in functionality, but you can build the functionality necessary by using the stream methods introduced in v9. I have not used them, but there is a tutorial. $\endgroup$ – rcollyer Jul 9 '15 at 14:35
  • $\begingroup$ @Szabolcs So I've managed to get decoded stream using VLC from the RSTP. Could you please elaborate on how to work with this stream in Mathematica? $\endgroup$ – mikeonly Jul 9 '15 at 16:45
  • $\begingroup$ I use ffmpeg to stream raw data (sequential rgb int array) to TCP/IP socket and then read the data from a Java process. I process it and then do the same thing in the other direction to create a new movie. I assume you could do the same thing with Mathematica using JLink. I'm not putting this as an answer because there are too many unanswered details. It's just one possible direction. $\endgroup$ – user9444 Jul 14 '15 at 22:52

I did an implementation for capturing from an RTSP using FFMPEG (via RunProcess):

capture = CaptureFromIPCamera[

enter image description here

You can get this function from my Prototypes paclet:

PacletInstall @ "https://github.com/arnoudbuzing/prototypes/releases/download/v0.2.9/Prototypes-0.2.9.paclet"

Or, if you prefer, you can just copy this one function from this source file:


The function works by simply calling the FFMPEG binary from the Wolfram Language with the right options to sample one image from an RTSP stream, and then importing that image. The implementation can probably be improved a lot, for example by directly importing from FFMPEG's standard output.

| improve this answer | |

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.