In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use Python code to make a video reversal artifact, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to know it.
Introduction
The normal video is as follows
Rewind the video as follows
The effect is great, when you learn this, you will find that Douyin those glasses of water backwards, running backwards and other seemingly cool and mysterious videos, in fact, is just a button upside down!
So, today the editor is going to explore how the Python code can achieve this inverted function.
Text
These funny gif and mini videos are the effect of replaying normal fluency.
In fact, it is very simple to make. The principle is to split the gif picture into each frame, and then reverse sort each frame of the split picture and save it to gif. It only takes ten lines of code.
The source code is as follows: from PIL import Image. ImageSequence# reads GIFim = Image.open ("1.gif") # iterator of the GIF image stream iter = ImageSequence.Iterator (im) index = traversing every frame of the picture stream for frame in iter: print ("image% d: mode% s, size% s"% (index, frame.mode) Frame.size) frame.save (". / images/img%d.png"% index) index + = split GIF into picture stream imgs = [frame.copy () for frame in ImageSequence.Iterator (im)] # reverse order of picture stream imgs.reverse () # Save all frame images after reverse order imgs [0] .save ("reverse.gif", save_all=True, append_images= imgs [1:]) effect display
Ha, understand this video!
When you meet an old man, you should.
A complete set of effects
If the teenager is electrocuted, the warrior will rescue him in time!
Go! Pikachu
Summary
Ha, these dynamic inversion effects are really interesting. Ha ~ hurry up and try it yourself.
Supplement
In fact, Python can realize not only the reversal of video, but also the reversal of moving pictures.
The following is the sample code that implements the reversal of the dynamic picture
Image processing library from PIL import Image under # python, ImageSequence# system module import os # used to read gif dynamic images im = Image.open ("read the name of the picture") # iterator iter = ImageSequence.Iterator (im) index = 1 for frame in iter: # print per frame ("image% d: mode% s, size% s"% (index, frame.mode, frame.size)) # if the saved path does not exist Then create a folder path = "imgs" if path not in os.listdir (): os.makedirs (path) # Save each picture to the imgs folder frame.save (". / imgs/frame%d.png"% index) index + = 1 # split the gif into a picture stream imgs = [frame.copy () for frame in ImageSequence.Iterator (im)] # output the original image # imgs [0] .save (". / out.gif") Save_all=True, append_images= imgs [1:]) # reverse order imgs.reverse () # Save and output imgs [0] .save (". / reverse_out.gif", save_all=True, append_images= imgs [1:]) Thank you for reading this article carefully I hope the article "how to use Python code to make a video replay artifact" shared by the editor is helpful to everyone. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.