I am not able to create a basic VideoWriter object as described in the documentation, for example:
video = VideoWriter('newfile.avi');
returns "Not enough input arguments."
as does
video = VideoWriter('newfile.avi','Motion JPEG AVI');
However, adding a sample third argument:
v = VideoWriter('newfile.avi','Motion JPEG AVI','test');
returns
Error using VideoWriter: Too many input arguments.
Has anyone else experienced this or know of what the problem might be?

8 Kommentare

What shows up for
which -all VideoWriter
Colin
Colin am 13 Mär. 2023
This returns
/Applications/MATLAB_R2022b.app/toolbox/matlab/audiovideo/VideoWriter.m % VideoWriter constructor
Walter Roberson
Walter Roberson am 13 Mär. 2023
That looks reasonable.
Could you post the complete message, including the traceback ?
Hi, sorry, I'm not quite sure what you mean. This is the full input/output of the second command:
which -all VideoWriter
/Applications/MATLAB_R2022b.app/toolbox/matlab/audiovideo/VideoWriter.m % VideoWriter constructor
For calling VideoWriter itself, I see there's a "dbstack" command but I don't know how to use it for troubleshooting a built-in function.
When you call
video = VideoWriter('newfile.avi');
then the only time that you can get a message such as
error using VideoWriter
Not enough input arguments.
with no further message, is the case where you are invoking a built-in (pre-compiled) function -- but we can see from the results of which that a regular function is being invoked.
When a regular function is invoked, you get messages such as
Not enough input arguments.
Error in bwmorph (line 90)
validateattributes(bwin,{'numeric' 'logical'},{'real' 'nonsparse' '2d'}, ...
Notice the traceback showing the line of code inside bwmorph in which the problem was detected. The details of the line number and the text of the line can help a lot in tracking down what the problem is.
(Note: this is a different situation than the case in which a function is being called with too many input arguments. When too many input arguments are used, then depending how the function is coded, MATLAB might be able to detect the problem before running the function at all. But in the case of too few input arguments, MATLAB needs to run the function, as the function might be able to handle the situation where not all parameters were passed in.)
Yes, it turns out that if I "show package contents", I can see that VideoWriter.m lives inside the audiovideo toolbox. I am then able to pinpoint the error to the following line within VideoWriter.m:
multimedia.internal.io.FilePath(newFileName)
When newFileName='newfile.avi', the error is
Not enough input arguments.
Error in erase (line 2)
for i=indx1:indx2
Error in multimedia.internal.io.FilePath/set.Extension (line 178)
obj.Extension = erase(obj.Extension,'.');
Error in multimedia.internal.io.FilePath (line 42)
[obj.ParentPath, ~, obj.Extension] = fileparts(filename);
However, the audiovideo toolbox does not seem to contain a 'multimedia' function, so I don't know how to investigate this further or fix it, if a change could be made to the 'erase' call; searching for 'multimedia.internal.io' reveals other errors related to audio processing, but none that seem directly relevant here (to my understanding).
Walter Roberson
Walter Roberson am 13 Mär. 2023
The problem is that you have a third party erase.m in your path
Colin
Colin am 13 Mär. 2023
This is exactly it -- I had a climate-model (WRF) set of files that included an erase.m script, and removing it from the path made VideoWriter happy. Will add this as an answer. Thank you!

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Colin
Colin am 13 Mär. 2023
Bearbeitet: Colin am 13 Mär. 2023

0 Stimmen

It turns out that I had a third-party erase.m script in my Matlab path which was interfering with the built-in erase function and making one of VideoWriter's subscripts unhappy. Searching in my filesystem for this erase.m and then calling
rmpath(location/of/third/party/erase.m)
made VideoWriter work again as expected. (h/t Walter Roberson)

Weitere Antworten (0)

Produkte

Version

R2022b

Gefragt:

am 12 Mär. 2023

Bearbeitet:

am 13 Mär. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by