Referring to the code below grab() or retrieve() never return false on reaching the end of file , instead restart reading the file causing an infinite loop
video_file = cv::VideoCapture.new(video_path)
while video_file.grab
frame = cv::Mat.new
output = video_file.retrieve(frame)
break unless output
framename = Time.now.strftime('frame%Y%m%d%H%M%S%L.jpg')
cv::imwrite(File.join(output_path,frame_name),frame)
end
Referring to the code below grab() or retrieve() never return false on reaching the end of file , instead restart reading the file causing an infinite loop
video_file = cv::VideoCapture.new(video_path)
while video_file.grab frame = cv::Mat.new output = video_file.retrieve(frame) break unless output framename = Time.now.strftime('frame%Y%m%d%H%M%S%L.jpg') cv::imwrite(File.join(output_path,frame_name),frame) end