Why do I get black frames from a video ?

Hi everyone,
I have some problem to extract all the frames of a video. When I run my code, it returns almost only black frames. The video is recorded in 4K, 30fps. I'm using Matlab 2015 on a macbook pro version 10.12.5.
My code is the following :
close all;
clear all;
v = VideoReader('TEST.mp4');
currAxes = axes;
framecnt = 0;
blackcnt = 0;
while hasFrame(v)
framecnt = framecnt +1;
vidFrame = readFrame(v);
image(vidFrame, 'Parent', currAxes);
currAxes.Visible = 'off';
fprintf('Extracted frame %d\n', framecnt);
pause(0.5/v.FrameRate);
if all(vidFrame(:)==0)
blackcnt= blackcnt+1;
fprintf('\t frame %d is black\n', framecnt);
end
end
fprintf('Total of %d frames extracted, %d of which black.\n',framecnt,blackcnt);
return;
Any help would be great,
Thanks

1 件のコメント

Walter Roberson
Walter Roberson 2017 年 6 月 30 日
On my MacBook Pro, R2017a, readFrame says that it cannot open the file. So does step() for Vision.VideoFileReader. But the Quicktime application is happy with the file.

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2017 年 6 月 30 日

0 投票

I tried it with the demo video xylophone.mp4 and it worked fine - no black frames. Can you upload your video so I can try yours?

4 件のコメント

Guillaume Rion
Guillaume Rion 2017 年 6 月 30 日
You can download the video at this adress : https://vimeo.com/223800643
Thanks for your help !
Image Analyst
Image Analyst 2017 年 6 月 30 日
I downloaded the original resolution and see this:
Extracted frame 439
Total of 439 frames extracted, 0 of which black.
I'm using R2017a and Windows 10, 64 bit. Sorry, but I can't reproduce your situation.
John BG
John BG 2017 年 6 月 30 日
編集済み: John BG 2017 年 6 月 30 日
Guillaune
do you mean you want to remove everything darker than the white foam dots floating on the water?
Since the floating foam is white white compared to everything else except the reflection of the fluorescent on the water, you may want to first go for the pixels that for instance have RGB>210, R>210 && G>210 && B>210.
The lighting reflection is static and the foam seems to be moving most of the time. Filtering it is not difficult either diff between consecutive frames, once white filtered.
John BG
Guillaume Rion
Guillaume Rion 2017 年 7 月 1 日
Thanks anyway ! I tried it with a lower video resolution on my computer and it works ... I don't understand why the videos recorded in 4K doesn't work...

サインインしてコメントする。

質問済み:

2017 年 6 月 30 日

コメント済み:

2017 年 7 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by