Save pre-loaded videos

1 次查看(过去 30 天)
Jessica Yorzinski
Jessica Yorzinski 2022-8-31
回答: Sugandhi 2023-6-7
I have used LoadMovieIntoTexturesDemo.m to pre-load a video. Can anyone give advice on how to save that preloaded video for later use? I would ultimately like to pre-load a number of videos and then play them later. This is the type of code, but this doesn't work:
for i=1:10
stimFname=imageNames{i};
moviename=stimFname;
LoadMovieIntoTexturesDemo(moviename);
movie_All{i}=movie;
end;

回答(1 个)

Sugandhi
Sugandhi 2023-6-7
Hi Jessica,
I understand that you want to save preloaded videos for later use.
The possible workaround could be:
% Create a cell array to store the loaded movies
movie_All = cell(1, 10);
for i = 1:10
stimFname = imageNames{i};
moviename = stimFname;
movie = LoadMovieIntoTexturesDemo(moviename);
movie_All{i} = movie;
end
% Save the preloaded movies to a MAT file
save('preloaded_movies.mat', 'movie_All');
In this code, a cell array `movie_All` is created to store the loaded movies. Within the loop, assuming that `LoadMovieIntoTexturesDemo(moviename)` is called to load the video, and the result is assigned to the `movie` variable. Then, the `movie` is stored in the corresponding cell of `movie_All`. After the loop, the `movie_All` is saved to a MAT file called 'preloaded_movies.mat' using the `save` function.
Later, when you want to use the preloaded videos, Load the MAT file and access the videos as shown below:
% Load the MAT file
load('preloaded_movies.mat');
% Access and use the preloaded movies
for i = 1:10
movie = movie_All{i};
% Play the movie or perform any other operations
end
By loading the 'preloaded_movies.mat' file, you can access the preloaded videos stored in the `movie_All` variable and use them as needed.
For more details, kindly go through following links:

Community Treasure Hunt

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

Start Hunting!

Translated by