Creating GIFs from imges in any order using python

I am trying to make a gif from a pics png format sequence with python language in ubuntu 12.04. I have a file in which my photos are located. they are called as lip_shapes1.png for lip_shapes11.png. I also have a list with the names of the images in which I want to make this gif in this sequence. The list is as follows:

list = [lip_shapes1.png, lip_shapes4.png , lip_shapes11.png, lip_shapes3.png]

but my problem is that I found this code:

import os
os.system('convert   -loop 0   lip_shapes*.gnp   anime.gif')

but he only makes the gif in gnp name order, but I want it to be in any order that I want. is it possible?

if anyone can help me i really appreciate that.

early

PS: I also want to make a movie out of it. I tried this code (forms is my list of image names):

    s = Popen(['ffmpeg', '-f', 'image2', '-r', '24', '-i'] + shapes + ['-vcodec', 'mpeg4', '-y', 'movie.mp4'])
s.communicate()

but it gives me this in the terminal and does not work:

ffmpeg script . Libav , avconv ( . " " ). avconv.

# 0, image2, 'shz8.jpeg':   : 00: 00: 00.04, : 0,000000, : N/A     Stream # 0.0: : mjpeg, yuvj420p, 266x212 [PAR 1:1 DAR 133: 106], 24 tbr, 24 tbn, 24 tbc

shz8.jpeg - .

+4
2

, , gif python. . ,

img_list = ['lip_shapes1.png', 'lip_shapes4.png' , 'lip_shapes11.png', 'lip_shapes3.png'] img_list.sort()

, list , .

os.system(convert ...) .

os.system('convert -loop 0 %s anime.gif' % ' '.join(img_list))

+1

subprocess.call, . , , , , .

import subprocess
shapes = ['lip_shapes1.png', 'lip_shapes4.png' , 'lip_shapes11.png', 'lip_shapes3.png']
cmd = ['convert', '-loop0'] + shapes + ['anime.gif']
retcode = subprocess.call(cmd)
if not retval == 0:
    raise ValueError('Error {} executing command: {}'.format(retcode, cmd))    
+2

Source: https://habr.com/ru/post/1626510/


All Articles