How to generate animated cover image for your dev.to post's from any video using python and moviepy 😎

Free Python Code - Aug 11 '23 - - Dev Community

Hello everyone 🙂🖐
In this post, I will share with you how to generate cover image for you dev.to post from video using python and moviepy in an easy and simple way

step 1
you need to install moviepy lib from here pip install moviepy

step 2
you need any video to test this code

step 3
as we kenow the dev.to post cover image size is : 1000 x 420
For this we need to resize video to 1000 x 420


import moviepy.editor as mp

video = mp.VideoFileClip('test.mp4')
video = video.subclip(8, 10)
video = video.resize((1000, 420))
video.write_gif('out.gif')

Enter fullscreen mode Exit fullscreen mode

i used subclip to cut video from 8s to 10s only
resize function to resize video frames to 1000 x 420

result

Image description

Now you can use it to your post 🤗

Now we're done
Don't forget to like and follow 🙂

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .