Why does AVIFILE fail with the error "??? Failed to create video stream." ?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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, ...
Risposta accettata
MathWorks Support Team
il 27 Giu 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Convert Image Type in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!