videoReader and wmv files - not accurately retreaving frames after multiple calls
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have variable frame-rate wmv files. I know the time stamps belonging to each frame, using mmread.
I want to extract the video frames associated with trials embedded in the video. There are a number of trials, and I know the start and end video frames for each. This is basically the code I'm using to do this:
for i = startTrial:endTrial
Obj = VideoReader([originalVideoFile videoFile '.wmv']);
startFrame = %beginning frame for this trial
endFrame = %ending frame for this trial
for j = 1:length(trialFrames)
temp = read(Obj, frame);
imwrite(temp,[num2str(j) '.png'],'png');
end
end
Sometimes, the frames that are extracted are NOT correct. It seems like an offset is added (e.g., instead of extracting frames 1 - 40, 8 - 48 will be extracted). These errors seem to accumulate. However, this seems to have nothing to do with a systematic error in the code or data, because upon re-running the script after making NO changes, the correct frames will be extracted.
These errors present a huge problem, because they seem to be idiosyncratic - I don't know when they will happen. Furthermore, they are extremely hard to detect.
Originally I thought it might have to do with making one Obj = videoReader per video file (e.g., move the Obj = VideoReader([originalVideoFile videoFile '.wmv']); to above the first for). Which makes the code run MUCH faster. However, recreating the Obj variable for each trial does not seem to resolve the problem.
1 Commento
K E
il 26 Set 2012
It appears that VideoReader has problems getting the frame index right when the file is a variable frame rate. At least this is my experience for MPEG-2 video files read in with 32-bit Matlab R2011a.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Audio and Video Data 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!