I am using the following method:
obj=VideoReader(filename); %Read the video
vidFrames=read(obj); %Capture the video frames
Then run a loop and read frame one by one
I=vidFrames(:,:,:,i); %i --> Frame Number
As against:
vid = videoinput(camera_name, camera_id, format);
data = getsnapshot(vid);
[f,t] = getdata(vid);
Where t will give you the frame time