Clear Filters
Clear Filters

How can I receive stream video content over a network with UDP protocol?

30 views (last 30 days)
How can I receive stream video content over a network with UDP protocol?
I'm using Matlab 2015b, and I want to receive stream video from a Ar Drone Parrot. I have used MMS protocol to try receive stream video without success. I get an error because the format used by Ar Drone is MPEG-4 with H.264 encoded video and this protocol use the function "DSPWinMMFileInfo" which throws error.
So, I want to receive this stream video with UDP protocol, but I don't know how. I have seen examples to transmit audio data over a network with UDP, but not for video.
Please, can anybody help me? Thanks
Rakesh Chavan
Rakesh Chavan on 16 Mar 2016
Can you post a snapshot of the error message you receive along with the code snippet that you are using.
The doc. link given below gives an example of sending video over network. Have you used something similar?
María Victoria García
María Victoria García on 17 Mar 2016
Hi Rakesh,
Yes, I have used something similar to this example. My code is:
url = 'mms://';
% Create objects
hSrc = vision.VideoFileReader('Filename', url);
hSnk = vision.DeployableVideoPlayer;
% Run loop. Ctrl-C to exit.
while true
data = step(hSrc);
step(hSnk, data);
And I get this error:
Error using DSPWinMMFileInfo
Could not add the data source to the filter graph.
Error in dspmmfileinfo>getFileInfo (line 98)
videoHeightInPixels, videoFormatName] = DSPWinMMFileInfo(theFile);
Error in dspmmfileinfo (line 19)
cache.fileInfo(index) = {getFileInfo(filename)};
Error in vision.VideoFileReader/setFileInfoProps
Error in vision.VideoFileReader/set.Filename
Error in matlab.system.SystemProp/parseInputs
Error in matlab.system.SystemProp/setProperties
Error in vision.VideoFileReader
Error in protocolo_mms (line 4)
hSrc = vision.VideoFileReader('Filename', url);
In addition I have used this code with UDP protocol:
% Initialize several configuration parameters.
IP_address = '';
IP_port = 5555;
sampleRate = 44100;
samplesPerFrame = 512;
drone.ARv = udp('', 5555, 'LocalPort', 5555);
% Create System objects to view to data produced by the remote client.
hRemoteSource = dsp.UDPReceiver('LocalIPPort', IP_port,...
'RemoteIPAddress', IP_address,...
'MaximumMessageLength', samplesPerFrame,...
'MessageDataType', 'double');
videoPlayer = vision.VideoPlayer;
fiveSeconds = 5*sampleRate;
for i=1:(fiveSeconds/samplesPerFrame)
% Connect the remote source to the local sink
% In other words, receive video data.
remoteData = step(hRemoteSource);
step(videoPlayer, remoteData);
And I get this error:
%Error using UDPReceiver/step
%Intento de acceso a un socket no permitido por sus permisos de acceso
%Error in udp__ (line 23)
% remoteData = step(hRemoteSource);
I am looking forward to your response. Thanks.

Sign in to comment.

Accepted Answer

Florian Enner
Florian Enner on 14 May 2016
Edited: Florian Enner on 14 May 2016
I've uploaded a submission that supports streaming h264 (among other formats) from ip cameras.
% Connect to stream
cam = HebiCam('<address>');
% Continously display latest image
fig = imshow(getsnapshot(cam));
while true
set(fig, 'CData', getsnapshot(cam));
You can get it from File Exchange or Github
Let me know if this works for you.
  1 Comment
María Victoria García
María Victoria García on 16 May 2016
Edited: María Victoria García on 16 May 2016
Hi Florian,
I've tried your code and I get this error:
Undefined variable "us" or class "".
Error in HebiCam (line 72) =;
Error in main (line 3)
cam = HebiCam(url);
Would you know where is the problem?
I am looking forward to your response, please. Thanks.

Sign in to comment.

More Answers (3)

Dinesh Iyer
Dinesh Iyer on 17 Mar 2016
The system object does allow you to read video content over MMS stream. However, the issue might be that it is unable to decode the H.264 stream that is contained in the video.
When you are using UDP, I noticed that the error indicates a permissions issue to access the socket. The system object error also indicates that it is unable to add the source for reading. This might be a permissions issue.
One quick thing to try is see if you are able to view this stream using Windows Media Player as the system object uses some of the same APIs to read it. Open Media Player, File > Open URL and try to stream data from your URL. If Media Player fails, then the system object is expected to fail.
Hope this helps.
María Victoria García
María Victoria García on 30 Mar 2016
Edited: María Victoria García on 30 Mar 2016
I have used Windows Media Player to try if it is possible to view this stream video. I have made indications you have said me and I have used three different url options:
- mms://
- tcp://
- udp://
And I get errors with the three options.
Would you know which is the problem? Is there another possibility to get this stream video?
I am looking forward to your response, please. Thanks.
David on 27 Jan 2017
Hello María VIctoria, I have exactly the same did you fix the issue on madia player codec?
Thanks in advance for your help,

Sign in to comment.

maha annoukoubi
maha annoukoubi on 29 Apr 2016
hello Maria i m working at the same project , please could you contact me on : so that we may share our informations .

Mohamed Abdelkader Zahana
Mohamed Abdelkader Zahana on 12 May 2016
Hi Maria,
I am trying to do almost the same thing. The difference is that I will have an embedded computer (ODROID XU4) with connected camera that streams video over UDP using gstreamer. Then, I would like to receive the video in MATLAB. I'd appreciate if any one can help.
Here is my email in case you find a solution.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!