如何了解视频中每一帧的开始时间?

How can I learn the starting time of each frame in a video?

学习视频每一帧的开始时间是非常关键的。 我需要使用以下 matlab 代码手动确定起点(例如此处的 848):

v = VideoReader('video1.avi','CurrentTime',848);
while hasFrame(v)
    video_frame = readFrame(v);
    counter=counter+1;

    if counter==1
        imshow(video_frame)
        imhist(video_frame(:,:,1))
    end
end

我想要的是通过使用直方图将一些视频帧与其他视频帧区分开来。最后我的目标是达到 杰出帧 .

的准确显示时间

编辑后: 这是帧直方图输出:

某些帧的直方图大小与上一帧不同,您知道原因吗?

     difference=[difference sum(abs(histcounts(video_frame)-histcounts(lastframe)))];

由于取差值,我删除了不同直方图大小的帧,但这会导致丢失一些帧。

我还没有找到与您描述的相似的视频示例。请考虑总是有一个例子。

此示例代码计算 histcounts 的差异。请注意 waitforbuttonpress 在循环中,因此您必须在测试时点击每一帧,或者在视频太长时将其删除。这对你的文件有用吗?

v = VideoReader('sample.avi','CurrentTime',1);
figure1=figure('unit','normalized','Position',[0.2 0.2 0.4 0.6]);
axes1=subplot(3,1,1);
axes2=subplot(3,1,2);
axes3 = subplot(3,1,3);

counter=0;
difference=[];
video_frame=readFrame(v);
while hasFrame(v)
    lastframe=video_frame;
    video_frame = readFrame(v);
    counter=counter+1;

    imshow(video_frame,'Parent',axes1);
    [a,b]=histcounts(video_frame(:,:,1));
    plot(b(1:end-1),a,'Parent',axes2);

    difference=[difference sum(abs(histcounts(video_frame,0:255)-histcounts(lastframe,0:255)))];
    bar(1:counter,difference,'Parent',axes3);
    waitforbuttonpress
end
  [~,onedistinguished]=max(difference);
  %defining a threshold like every value that is bigger 4000
   multidistinguished=find(difference>4000);

  disp(['majorly changed at: ' num2str(distinguished)]);