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?
It looks like you may be overwriting your video object, vidObj
, with the line vidObj = frameRate;
.
Try replacing with vidObj.FrameRate = frameRate;
.