Effacer les filtres
Effacer les filtres

Why does AVIFILE fail with the error "??? Failed to create video stream." ?

3 vues (au cours des 30 derniers jours)
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, ...

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 27 Juin 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

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Produits


Version

R14SP1

Community Treasure Hunt

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

Start Hunting!

Translated by