mirror of
https://github.com/storytold/storyteller-ml.git
synced 2026-10-22 08:16:08 +00:00
Add SadTalker @ ae0b26359d44c9379450a8e02a38b45eeec15549
MIT license Commit: https://github.com/OpenTalker/SadTalker commit ae0b26359d44c9379450a8e02a38b45eeec15549 (HEAD -> main, origin/main, origin/HEAD) Author: shadowcun <shadowcun@tencent.com> Date: Mon Jul 3 13:48:35 2023 +0800 fixed bug: hacking facexlib of FAN
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import shutil
|
||||
import uuid
|
||||
|
||||
import os
|
||||
|
||||
import cv2
|
||||
|
||||
def load_video_to_cv2(input_path):
|
||||
video_stream = cv2.VideoCapture(input_path)
|
||||
fps = video_stream.get(cv2.CAP_PROP_FPS)
|
||||
full_frames = []
|
||||
while 1:
|
||||
still_reading, frame = video_stream.read()
|
||||
if not still_reading:
|
||||
video_stream.release()
|
||||
break
|
||||
full_frames.append(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
|
||||
return full_frames
|
||||
|
||||
def save_video_with_watermark(video, audio, save_path, watermark=False):
|
||||
temp_file = str(uuid.uuid4())+'.mp4'
|
||||
cmd = r'ffmpeg -y -hide_banner -loglevel error -i "%s" -i "%s" -vcodec copy "%s"' % (video, audio, temp_file)
|
||||
os.system(cmd)
|
||||
|
||||
if watermark is False:
|
||||
shutil.move(temp_file, save_path)
|
||||
else:
|
||||
# watermark
|
||||
try:
|
||||
##### check if stable-diffusion-webui
|
||||
import webui
|
||||
from modules import paths
|
||||
watarmark_path = paths.script_path+"/extensions/SadTalker/docs/sadtalker_logo.png"
|
||||
except:
|
||||
# get the root path of sadtalker.
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
watarmark_path = dir_path+"/../../docs/sadtalker_logo.png"
|
||||
|
||||
cmd = r'ffmpeg -y -hide_banner -loglevel error -i "%s" -i "%s" -filter_complex "[1]scale=100:-1[wm];[0][wm]overlay=(main_w-overlay_w)-10:10" "%s"' % (temp_file, watarmark_path, save_path)
|
||||
os.system(cmd)
|
||||
os.remove(temp_file)
|
||||
Reference in New Issue
Block a user