Why does AVIFILE fail with the error "??? Failed to create video stream." ?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have code that generates a movie using the AVIFILE function. The figures show up correctly but the AVI-file is never created.
The AVIFILE function fails with the following error:
??? Failed to create video stream.
Error in ==> avifile.addframe at 226
avi('addframe',rot90(frame,-1), aviobj.Bitmapheader, ...
Akzeptierte Antwort
MathWorks Support Team
am 27 Jun. 2009
The issue is related to the fact that the AVI object itself never contains any frames. If the AVI object is updated in a subfunction (for example, 'makemovie' in the following code) and the subfunction does not return the updated AVI object to the main routine (for example, 'MainFcn' in the following code), a call to close(aviobj) in the main routine fails since the AVI object contains no data. This will cause the error listed above.
To work around this issue, ensure that when you close the AVI object, it contains at least one frame of data. In this case, the subfunction must always return the updated AVI object to the main routine.
The ideal way to create the movie in a subfunction is as follows:
function MainFcn
%create the AVI object here
aviobj = avifile('example.avi')
% function call to create the movie
aviobj = makemovie(aviobj);
% close the file
aviobj = close(aviobj);
return
function aviobj = makemovie(aviobj)
for i = 1:10
plot(1:10);
aviobj = addframe(aviobj, getframe(gcf));
end
return
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!