1

I am trying to create a video file with MATLAB. Here is my function:

function [vidObj] = createVideo(frames, frameRate, filename)

%Create video object
num_frames = size(frames,2);
vidObj = VideoWriter(filename);
vidObj.Quality = 100;
vidObj = frameRate;
open(vidObj);

%some more stuff...

The issue is that MATLAB always gives me an error at the call to open(vidObj) saying

Error using open (line 69)
NAME must contain a single string.

My string is simple...just 'test_video.avi'. But it's not working. I also tried going in the function and replacing 'filename' with literal strings.

What is strange is that when I just type the commands into the command window, it works fine. Why? And how can I make this work in the function?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Sterling
  • 3,835
  • 14
  • 48
  • 73

1 Answers1

3

It looks like you may be overwriting your video object, vidObj, with the line vidObj = frameRate;.

Try replacing with vidObj.FrameRate = frameRate;.

Ryan J. Smith
  • 1,140
  • 8
  • 15