Rajiv Sharma
Rajiv Sharma

Reputation: 7152

Django upload video with automatic thumbnails generation

I want to upload mp4 and mov videos to my django website with automatic thumbnail generation. Thumbnails can be jpg or png that will save in ImageField and video to FileField.

thumbnail = models.ImageField()
video = models.FileField()

I am using Python 3.6.3, Django 1.11.8 and dropzone.

Please suggest me how to create a video upload page similar to youtube.

Is there any opensource plugin available to achieve this ?

enter image description here

Upvotes: 2

Views: 1802

Answers (1)

Andre Pereira
Andre Pereira

Reputation: 249

You can do it using ffmpeg.

import subprocess

video_path = '/tmp/video.mov'
image_path = '/tmp/video.jpg'
time = '00:00:00.000'

subprocess.call(['ffmpeg', '-i', video_path, '-ss', time, '-vframes', '1', image_path])

That'll take 1 frame at 00:00:00.000 of your video and store it as an image.

Upvotes: 2

Related Questions