Eliminating redundant frames in a video using Python

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

Eliminating redundant frames in a video using Python



I was looking at a real time problem where we need to eliminate the redundant frames of a video.(May be a video with lyrics of a song)
In my example, lyrics video song, we are not concerned about the audio. Only frames containing the lyrics. but the thing is 2 line of lyrics my end up with 20seconds ending up with multiple frames having the same lyrics. So I was interested in eliminating those redundant frames.



While searching, I have found this code to extract frames from a video by this - Python - Extracting and Saving Video Frames


import cv2
vidcap = cv2.VideoCapture('Compton.mp4')
success,image = vidcap.read()
count = 0
success = True
while success:
success,image = vidcap.read()
cv2.imwrite("frame%d.jpg" % count, image) # save frame as JPEG file
if cv2.waitKey(10) == 27: # exit if Escape is hit
break
count += 1



Can you please help me how to proceed in order to eliminate the redundant frames from here on.




1 Answer
1



If you just need the frames(jpegs)then you can use ffmpeg video filter option and extract the frames at a given frame rate(fps)



ffmpeg -i "Compton.mp4" -vf fps=1 frame%04d.jpg -hide_banner


ffmpeg -i "Compton.mp4" -vf fps=1 frame%04d.jpg -hide_banner



This will extract one frame a second. You can tweak it based on how frequently your lyrics change in the video.



If you want to use it in python then ffmpeg-python is a great tool.



Hope it helps.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

Executable numpy error

PySpark count values by condition

Mass disable jenkins jobs