escaped / django-video-encoding

django-video-encoding helps to convert your videos into different formats and resolutions.
BSD 3-Clause "New" or "Revised" License
116 stars 45 forks source link

Video thumbnail #16

Closed lifenautjoe closed 4 years ago

lifenautjoe commented 5 years ago

Hi Alex,

Is there any way to have the library generate a video thumbnail or is this outside the scope of the package?

Cheers!

escaped commented 5 years ago

Hi,

there is some support for generating thumbnails, it's just lacking some documentation. You could simply add another task which will extract thumbnails with the provided backend. Something like the following should do the trick:

video = Video.objects.get(pk=3)  # assuming Video.file is a `VideoField`

encoding_backend = get_backend()
thumbnail_path = encoding_backend.get_thumbnail(video.file.path)

# you could now store the thumbnails on the model as well.

See here for more information.

lifenautjoe commented 5 years ago

Hi Alex,

Thanks for the reply.

I found the method in the code, however was breaking my head for about an hour figuring it out why it wouldn't work...

I just noticed get_thumbnail doesn't return a File handle but a string path 🙃.

Thanks for the reply and yeah, would be great to have this in the docs!