Ao usar o comando
python generator video.mp4 2 150 80 10 thumbnails.jpg
tenho o seguinte retorno
Extracting 734 frames
[####################################] 100%
Frames extracted.
Traceback (most recent call last):
File "generator", line 90, in <module>
generate_video_thumbnail(arguments)
File "generator", line 39, in generate_video_thumbnail
generate_sprite_from_frames(outputPrefix, columns, size, output)
File "generator", line 62, in generate_sprite_from_frames
images = [Image.open(filename) for filename in framesMap]
File "C:\Python27\lib\site-packages\PIL\Image.py", line 2312, in open
fp = builtins.open(filename, "rb")
IOError: [Errno 24] Too many open files: 'c:\\users\\gpich\\appdata\\local\\temp\\tmpellfxjf728913fdda8373761ccb51c69fe51d5_00497.png'
Quando preciso gerar números menores de thumbnails ele gera sem problemas. Como faço para contornar esse problema?
O projeto está no github https://github.com/flavioribeiro/video-thumbnail-generator
abaixo o algumas funções relevantes para a geração
def generate_video_thumbnail(args):
videoFileClip = VideoFileClip(args['<video>'])
interval = int(args['<interval>'])
size = (int(args['<width>']), int(args['<height>']))
outputPrefix = get_output_prefix()
generate_frames(videoFileClip, interval, outputPrefix, size)
columns = int(args['<columns>'])
output = args['<output>']
generate_sprite_from_frames(outputPrefix, columns, size, output)
def extract_frame(videoFileClip, moment, outputPrefix, size, frameCount):
output = outputPrefix + ("%05d.png" % frameCount)
videoFileClip.save_frame(output, t=int(moment))
resize_frame(output, size)
def resize_frame(filename, size):
image = Image.open(filename)
image = image.resize(size, Image.ANTIALIAS)
image.save(filename)
def generate_sprite_from_frames(framesPath, columns, size, output):
framesMap = sorted(glob.glob(framesPath + "*.png"))
images = [Image.open(filename) for filename in framesMap]
masterWidth = size[0] * columns
masterHeight = size[1] * int(math.ceil(float(len(images)) / columns))
finalImage = Image.new(mode='RGBA', size=(masterWidth, masterHeight), color=(0,0,0,0))
merge_frames(images, finalImage, columns, size, output)
generate_video_thumbnail
seja suficiente?). Vc até pode manter o link do github, mas a pergunta tem que ter todos os detalhes.