How can I obtain audio and video characteristics in multimedia info when I'm using a for loop?
1 view (last 30 days)
Show older comments
Jose Peñaloza
on 12 Aug 2015
Commented: Jose Peñaloza
on 13 Aug 2015
I'm using this code but the multimedia characteristics from avi files are not showed and Matlab send me this error after run the program: ??? ??? Index exceeds matrix dimensions What I want is to obtain characteristics from audio and video from this files but I need a loop because there are too many files
files= dir('*.avi');
numfiles=length(files);
mydata= cell(numfiles,1);
info=cell(numfiles,1);
for j=1:numfiles
info{j}=mmfileinfo(files(j).name);
audio=info(j).Audio
video=info(j).Video
end
for k=1:numfiles
mydata{k}=importdata(files(k).name);
end
0 Comments
Accepted Answer
Dinesh Iyer
on 12 Aug 2015
The code below should fix the issue:
files= dir('*.avi');
numfiles=length(files);
mydata= cell(numfiles,1);
info=cell(numfiles,1);
isFileSupported = true(numfiles, 1) ;
for j=1:numfiles
try
info{j}=mmfileinfo(files(j).name);
audio = info{j}.Audio
video = info{j}.Video
catch ME
isFileSupported(j) = false;
continue;
end
end
supportedFiles = files(isFileSupported);
for k=1:numel(supportedFiles)
mydata{k}=importdata(supportedFiles(k).name);
end
Hope this helps.
I would not recommend importing the data of all files into MATLAB at once because this can eat up a lot of memory depending upon the file size. Import data for each file as you need it.
Hope this helps.
Dinesh
More Answers (0)
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!