I have made a python script to extract frames for multiple extenstions, but i dont delete the files once i convert the videos, but that can be done with an additional line of code.
frames =5
video_folder = '/media/ryan/shakira/3d-cnn-action-recognition/some_folder'
for file in os.listdir(video_folder):
if file.endswith('.webm'):
os.mkdir(os.path.join(video_folder,file.split('.')[0]))
folder_name = file.split('.')[0]
os.system('ffmpeg -t 4 -i {} -vf fps={} {}/%05d.jpg -t 10'.format(os.path.join(video_folder,file), frames,os.path.join(video_folder,folder_name )))
elif file.endswith('.mp4'):
os.mkdir(os.path.join(video_folder,file.split('.')[0]))
folder_name = file.split('.')[0]
os.system('ffmpeg -t 4 -i {} -vf fps={} {}/%05d.jpg -t 10'.format(os.path.join(video_folder,file), frames,os.path.join(video_folder,folder_name )))
elif file.endswith('.blob'):
os.mkdir(os.path.join(video_folder,file.split('.')[0]))
folder_name = file.split('.')[0]
os.system('ffmpeg -i {} -vf fps={} {}/%05d.jpg'.format(os.path.join(video_folder,file), frames,os.path.join(video_folder,folder_name )))
else:
print('*********************************************************', file)