0.0.8s
This commit is contained in:
+2
-1
@@ -2,7 +2,8 @@
|
|||||||
"server":{
|
"server":{
|
||||||
"host":"127.0.2.1",
|
"host":"127.0.2.1",
|
||||||
"port":80,
|
"port":80,
|
||||||
"count_page":25
|
"count_page":25,
|
||||||
|
"thumb_size":250
|
||||||
},
|
},
|
||||||
"gb":{
|
"gb":{
|
||||||
"id":"",
|
"id":"",
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
from system_module import db, gelbooru, logger
|
from system_module import db, gelbooru, logger, image_processor
|
||||||
from flask import Flask, render_template, jsonify, send_from_directory, render_template_string, request
|
from flask import Flask, render_template, jsonify, send_from_directory, render_template_string, request
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
import traceback
|
import traceback
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -36,6 +37,8 @@ def find_file(filename, file_folders):
|
|||||||
return folder_path
|
return folder_path
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
if not image_processor.check_ffmpeg(): print("WARNING!\n\nУ вас не установлен ffmpeg. Генерация превью для видео не доступна!")
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
return render_template("index.html")
|
return render_template("index.html")
|
||||||
|
|||||||
@@ -1,4 +1,34 @@
|
|||||||
import PIL
|
import subprocess
|
||||||
|
from PIL import Image
|
||||||
|
import os
|
||||||
|
|
||||||
def generate_thumb():
|
EXTENSIONS_IMG = ('.jpg', '.jpeg', '.png', '.gif', '.webp', '.bmp')
|
||||||
|
EXTENSIONS_VID = ('.mp4', '.webm')
|
||||||
|
VALID_EXTENSIONS = EXTENSIONS_IMG + EXTENSIONS_VID
|
||||||
|
|
||||||
|
def check_ffmpeg():
|
||||||
|
try:
|
||||||
|
if os.name == 'nt': creationflags = subprocess.CREATE_NO_WINDOW
|
||||||
|
else: creationflags = 0
|
||||||
|
subprocess.run(["ffmpeg", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True, creationflags=creationflags)
|
||||||
|
return True
|
||||||
|
except (FileNotFoundError, subprocess.CalledProcessError):
|
||||||
|
return False
|
||||||
|
|
||||||
|
def generate_video_thumbnail(input_path_file, output_path_file, TARGET_MIN_SIZE):
|
||||||
|
vf_scale = f"scale='if(gt(iw,ih),-1,{TARGET_MIN_SIZE})':'if(gt(iw,ih),{TARGET_MIN_SIZE},-1)'"
|
||||||
|
cmd = ["ffmpeg", "-y", "-i", input_path_file, "-ss", "00:00:00", "-vframes", "1", "-vf", vf_scale, "-q:v", "2", output_path_file]
|
||||||
|
if os.name == 'nt': creationflags = subprocess.CREATE_NO_WINDOW
|
||||||
|
else: creationflags = 0
|
||||||
|
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, creationflags=creationflags)
|
||||||
|
if result.returncode != 0:
|
||||||
|
raise Exception(f"FFmpeg error: {result.stderr.decode('utf-8', errors='ignore')}")
|
||||||
|
|
||||||
|
def video_gen():
|
||||||
|
pass
|
||||||
|
|
||||||
|
def image_and_gif_gen():
|
||||||
|
pass
|
||||||
|
|
||||||
|
def generate_thumb(source_image, thumb_folder, TARGET_MIN_SIZE):
|
||||||
pass
|
pass
|
||||||
Reference in New Issue
Block a user