how to detect shot boundary in video

23 Ansichten (letzte 30 Tage)
malathi mani
malathi mani am 15 Apr. 2015
SBD using adaptive threshold

Antworten (1)

prabhat kumar sharma
prabhat kumar sharma am 23 Jan. 2025
Hello Malathi,
Detecting shot boundaries in a video involves identifying transitions between different scenes or shots. One common approach is to use an adaptive threshold method. Here's a concise guide on how to achieve this:
1. Extract Frames:
  • Convert the video into a series of frames.
2. Compute Frame Differences:
  • Calculate the difference between consecutive frames. This can be done using pixel-wise subtraction or more sophisticated methods like histogram differences.
3. Adaptive Thresholding:
  • Compute a threshold that adapts based on the frame differences. This can be done using statistical measures like mean and standard deviation of differences over a sliding window.
4. Detect Boundaries:
  • Identify frames where the difference exceeds the adaptive threshold. These frames are likely to be shot boundaries.
Here is a basic example :
% Read video
video = VideoReader('video.mp4');
numFrames = video.NumFrames;
% Initialize variables
frameDiffs = zeros(numFrames-1, 1);
% Compute frame differences
for i = 1:numFrames-1
frame1 = read(video, i);
frame2 = read(video, i+1);
frameDiffs(i) = sum(abs(frame1(:) - frame2(:))); % Sum of absolute differences
end
% Adaptive threshold
windowSize = 30; % Example window size
thresholds = movmean(frameDiffs, windowSize) + movstd(frameDiffs, windowSize);
% Detect shot boundaries
shotBoundaries = find(frameDiffs > thresholds);
% Display results
disp('Detected shot boundaries at frames:');
disp(shotBoundaries);
I hope it helps!

Community Treasure Hunt

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

Start Hunting!

Translated by