.output(
f"E:\\{uuid.hex}_{path.name}",
vf=f"movie='{watermark_file.name}' [watermark]; [in][watermark] overlay='{overlay}' [out]"
)
[Parsed_movie_0 @ 0000029858633380] Failed to avformat_open_input 'C'
[AVFilterGraph @ 00000298568ebc80] Error initializing filters
[vost#0:0/libvpx-vp9 @ 0000029858817840] Error initializing a simple filtergraph
Error opening output file E:\eb6b7d236d6848939034cbe8bde23c88_000.webm.
Error opening output files: No such file or directory
[Parsed_movie_0 @ 0000029858633380] Failed to avformat_open_input 'C'
.output(
f"E:\\{uuid.hex}_{path.name}",
vf=f"movie={"test.png"} [watermark]; [in][watermark] overlay='{overlay}' [out]"
)
(
ffmpeg
.input(str(path))
.output(
os.environ.get("TEMP")+f"\\{uuid.hex}_{path.name}",
vf=f"movie='{watermark_file.name}' [watermark]; [in][watermark] overlay='{overlay}' [out]"
)
.global_args('-copyts')
.run()
)
[Parsed_movie_0 @ 0000019ee4a10300] Failed to avformat_open_input 'C'
[AVFilterGraph @ 0000019ee30bb140] Error initializing filters
[vost#0:0/libvpx-vp9 @ 0000019ee30c7e40] Error initializing a simple filtergraph
Error opening output file C:\Users\smeta\AppData\Local\Temp\8825c1357e2744c38efcd170322c0c4f_000.webm.
Error opening output files: No such file or directory
from uuid import uuid4
from PIL import Image, ImageDraw, ImageFont
import pickle
import io
uuid = uuid4()
text = uuid.hex
image = Image.new("RGBA", (355, 20), (0, 0, 0, 0))
font = ImageFont.truetype("arial.ttf", 20)
draw = ImageDraw.Draw(image)
bbox = draw.textbbox((0, 0), text, font=font)
text_width = bbox[2] - bbox[0]
text_height = bbox[3] - bbox[1]
text_x = (text_width - text_width) // 2
text_y = (text_height - text_height) // 2
# Рисуем белую обводку
draw.text((text_x - 1, text_y - 1), text, font=font, fill='white')
draw.text((text_x + 1, text_y - 1), text, font=font, fill='white')
draw.text((text_x - 1, text_y + 1), text, font=font, fill='white')
draw.text((text_x + 1, text_y + 1), text, font=font, fill='white')
# Рисуем черный текст
draw.text((text_x, text_y), text, font=font, fill='black')
buff = io.BytesIO()
image.save(buff, format="PNG")
buff.seek(0)
import tempfile
import ffmpeg
from pathlib import Path
import os
with tempfile.TemporaryFile("wb", delete=False, suffix=".png") as watermark_file:
watermark_file.write(buff.read())
paths = Path(os.getcwd()) / "uploads/video/3214f2d8-1092-42b7-ae4e-8b2e2d2cedcd/splitted"
paths = paths.glob("*.webm")
video_duration = 236
# Выражение для координат движения водяного знака
points = [
("10", "10"), # Левый верхний угол
(f"W-{image.width}-10", "10"), # Правый верхний угол
(f"W-{image.width}-10", f"H-{image.height}-10"), # Правый нижний угол
("10", f"H-{image.height}-10") # Левый нижний угол
]
overlay_filters_x = ''
overlay_filters_y = ''
for i in range(4):
current_x, current_y = points[i]
next_x, next_y = points[(i + 1) % 4]
duration = video_duration / 4
start_time = i * duration
end_time = (i + 1) * duration
overlay_expr_x = (
f"if(between(t,{start_time},{end_time}),"
f"{current_x}+((t-{start_time})*(({next_x})-({current_x}))/{duration}),"
")"
)
overlay_expr_y = (
f"if(between(t,{start_time},{end_time}),"
f"{current_y}+((t-{start_time})*(({next_y})-({current_y}))/{duration}),"
")"
)
if i == 0:
overlay_filters_x = overlay_expr_x
overlay_filters_y = overlay_expr_y
else:
overlay_filters_x = overlay_filters_x[:-i] + overlay_expr_x + overlay_filters_x[-i:]
overlay_filters_y = overlay_filters_y[:-i] + overlay_expr_y + overlay_filters_y[-i:]
overlay_filters_x = overlay_filters_x[:-4] + "0" + overlay_filters_x[-4:]
overlay_filters_y = overlay_filters_y[:-4] + "0" + overlay_filters_y[-4:]
overlay = f"{overlay_filters_x}:{overlay_filters_y}"
# Соединяем все overlay фильтры
path = next(paths)
# Наложение водяного знака на видео с движением
(
ffmpeg
.input(str(path))
.output(
os.environ.get("TEMP")+f"\{uuid.hex}_{path.name}",
vf=f"movie='{watermark_file.name}' [watermark]; [in][watermark] overlay='{overlay}' [out]"
)
.global_args('-copyts')
.run()
)
watermark_file.close()
let video = this.api.get_info_about_video(this.video_uuid);
get_info_about_video(video_uuid:string){
let result = this.sendMethod(
"get_info_about_video",
{
video_uuid: video_uuid,
}
).then(result => {
return result;
});
console.log(result)
return result
}
И зачем использовать жс в 2024?
В жс нет типизации, во что именно ты хочешь конвертировать этот класс?
Не знал, что можно было проверить, спасибо за информацию!