aboutsummaryrefslogtreecommitdiff
path: root/cgi
diff options
context:
space:
mode:
authorLibravatar bai 2019-11-26 16:47:37 -0300
committerLibravatar bai 2019-11-26 16:47:37 -0300
commit55289adf78990957aa80ee1ba02f5a69f41af78d (patch)
treee8bf787cfe72de04bfd0010b8c8d4c553a39f542 /cgi
parentd61dbf963f6fa75d78fddb48098b5639a6a30ed1 (diff)
downloadweabot-55289adf78990957aa80ee1ba02f5a69f41af78d.tar.gz
weabot-55289adf78990957aa80ee1ba02f5a69f41af78d.tar.xz
weabot-55289adf78990957aa80ee1ba02f5a69f41af78d.zip
Agregado soporte para video/mp4
Diffstat (limited to 'cgi')
-rw-r--r--cgi/img.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/cgi/img.py b/cgi/img.py
index 21f326a..3561672 100644
--- a/cgi/img.py
+++ b/cgi/img.py
@@ -24,7 +24,7 @@ def processImage(post, data, t, originalname, spoiler=False):
Returns updated <post> with file and thumb values
"""
board = Settings._.BOARD
-
+
used_filetype = None
# get image information
@@ -90,7 +90,6 @@ def processImage(post, data, t, originalname, spoiler=False):
logTime("Generating thumbnail")
if used_filetype['mime'][:5] == 'video':
- #duration_half = str(int(extra['duration'] / 2))
retcode = subprocess.call([
Settings.FFMPEG_PATH, '-strict', '-2', '-ss', '0', '-i', file_path,
'-v', 'quiet', '-an', '-vframes', '1', '-f', 'mjpeg', '-vf', 'scale=%d:%d' % (file_thumb_width, file_thumb_height),
@@ -179,7 +178,7 @@ def processImage(post, data, t, originalname, spoiler=False):
def extraInfo(mime, file_name, file_path):
board = Settings._.BOARD
- if mime in ['audio/ogg', 'audio/opus', 'audio/mpeg', 'video/webm']:
+ if mime in ['audio/ogg', 'audio/opus', 'audio/mpeg', 'video/webm', 'video/mp4']:
info = ffprobe_f(file_path)
extra = {}
credit_str = ""
@@ -278,14 +277,10 @@ def getImageInfo(data):
elif (size >= 4) and data.startswith("\x1A\x45\xDF\xA3"):
content_type = "video/webm"
info = ffprobe(data)
-
- for stream in info['streams']:
- if 'width' in stream:
- width = stream['width']
- height = stream['height']
- break
-
- extra['duration'] = float(info['format']['duration'])
+
+ # handle mp4
+ elif (size >= 8) and data[4:12] in ["ftypmp42", "ftypisom"]:
+ content_type = "video/mp4"
# handle ogg formats (vorbis/opus)
elif (size >= 64) and data[:4] == "OggS":
@@ -326,6 +321,15 @@ def getImageInfo(data):
elif (size >= 2) and data[:2] == "PK":
content_type = "application/epub+zip"
+ if content_type.startswith("video"):
+ info = ffprobe(data)
+ for stream in info['streams']:
+ if 'width' in stream:
+ width = stream['width']
+ height = stream['height']
+ break
+
+
return content_type, width, height, size, extra
def ffprobe(data):