diff --git a/README b/README
index 7717f70..3d805c8 100644
--- a/README
+++ b/README
@@ -8,4 +8,4 @@ pip packages:
* pymediainfo
* PIL (should be there by default)
* ExifRead
- *
+ * opencv-python
diff --git a/files.py b/files.py
index c3e3d10..0f3c467 100644
--- a/files.py
+++ b/files.py
@@ -13,6 +13,7 @@ import hashlib
import exifread
import base64
import numpy
+import cv2
################################################################################
# Local Class imports
@@ -76,6 +77,24 @@ class FileData():
except:
return False
+ def generateVideoThumbnail(self, file):
+ #overall wrapper function for generating video thumbnails
+ vcap = cv2.VideoCapture(file)
+ res, im_ar = vcap.read()
+ while im_ar.mean() < 15 and res:
+ res, im_ar = vcap.read()
+ im_ar = cv2.resize(im_ar, (160, 90), 0, 0, cv2.INTER_LINEAR)
+ #save on a buffer for direct transmission
+ res, thumb_buf = cv2.imencode('.jpeg', im_ar)
+ # '.jpeg' etc are permitted
+ #get the bytes content
+ bt = thumb_buf.tostring()
+ fthumbnail = base64.b64encode(bt)
+ fthumbnail = str(fthumbnail)[2:-1]
+ print(fthumbnail)
+ return fthumbnail
+
+
##############################################################################
# HACK: At present this only handles one path (need to re-factor if we have #
# multiple valid paths in import_path) #
@@ -106,6 +125,7 @@ class FileData():
fthumbnail = self.getExif(file)
elif self.isVideo(file):
ftype = 'Video'
+ fthumbnail = self.generateVideoThumbnail(file)
else:
ftype = 'File'
diff --git a/templates/files.html b/templates/files.html
index 4847542..5fb6d0f 100644
--- a/templates/files.html
+++ b/templates/files.html
@@ -30,7 +30,7 @@
{% if obj.type=="Image" %}
{% elif obj.type == "Video" %}
-
+
{% endif %}
{{obj.name}}