This media is not supported in your browser
VIEW IN TELEGRAM
这个是 stop montage,就是每个 subtitle 排版不变化的(传递
--key-thres 0 每个色块都必须绘制导致的) 没加声音因为不是成品,是替补剪辑素材由于绘制蒙太奇图时
#FFFFFF 颜色会和小黑自己的颜色冲突导致小黑无 text fill 所以手动剪辑换边框颜色,直接用 Kdenlive 剪的(第一张),第二张是实验照。This media is not supported in your browser
VIEW IN TELEGRAM
这个是原版的白色背景替换版本
duangsuse::Echo
这个是 stop montage,就是每个 subtitle 排版不变化的(传递 --key-thres 0 每个色块都必须绘制导致的) 没加声音因为不是成品,是替补剪辑素材
大概说一下必须要啥接口啊…… (不止这个项目,是我最近用过的 API,emmm) #Python
Image 方面:
ImageDraw:
然后对 #CV 来说, fps, n_frames, width, height 是必须的
这些 API,OpenCV 不支持 unicode 字体,但可以写 C++ 扩展,用 freetype 画啊
from PIL import Image, ImageDraw, ImageFont Image 方面:
Image.open(path), Image.new(mode, size, fill)骚操作:
size, width, height
getpixel, putpixel
mode, Image.getmodebands
resize, crop, paste
palette
offset((x,y))
getchannel("R")
histogram()
getextrema() 可以算通道极值ImageDraw:
ImageFont.truetype(path)
ImageDraw.Draw(img) ImageDraw.text(pos, text, font, fill) 然后对 #CV 来说, fps, n_frames, width, height 是必须的
def cv2VideoInfo(cap):剩下
props = [cv2.CAP_PROP_FRAME_COUNT, cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT]
return (cap.get(cv2.CAP_PROP_FPS),) + tuple(int(cap.get(p)) for p in props)
VideoCapture.read, VideoWriter.write 就好了这些 API,OpenCV 不支持 unicode 字体,但可以写 C++ 扩展,用 freetype 画啊
java.awt.image.BufferedImage 和 java.awt.Graphics 也是支持绘制文字的(但不能在调用里直接自定义字体)Forwarded from duangsues.is_a? SaltedFish
def channelHistogram(img):#Python #code #CV 🤔
n_channels = Pillow.getmodebands(img.mode)
hist = img.histogram()
return tuple(hist[i:i+256] for i in range(0, n_channels*256, 256))
def imagePixels(img):
for y in range(0, img.height):
for x in range(0, img.width):
yield img.getpixel((x, y))
def count(xs): return sum(map(lambda _: 1, xs))
新版
vcat_subtitle_imgs.py 里我们支持了 #FF0000 红色标记划掉字幕的特性import os
def defaultOnAreaWrote(path, img, mark_range=range(10, 1000), show=lambda n, r: n > r.stop):
(r,_,_) = channelHistogram(img)[0:3]
if r[0xFF] > 0:
n_marks = count(filter(lambda it: it[0:3] == (0xFF,0,0), imagePixels(img)))
if n_marks not in mark_range: return
if show(n_marks, mark_range): img.show(title = f"Removed {path}")
print(f"Removing {path} (redmarks {n_marks})")
os.remove(path)
duangsuse::Echo
新版 vcat_subtitle_imgs.py 里我们支持了 #FF0000 红色标记划掉字幕的特性 import os def defaultOnAreaWrote(path, img, mark_range=range(10, 1000), show=lambda n, r: n > r.stop): (r,_,_) = channelHistogram(img)[0:3] if r[0xFF] > 0: n_marks = count(filter(lambda it: it[0:3]…
对于非常模糊的视频,可以先检测关键帧导出,然后再利用
vcat_subtitle_imgs.py 进行合并化编辑去掉重复的关键帧,最后 --only-images 添加文字序列即可,这个过程依赖 bash 一类支持 glob 的 shell,如果是 windows 可以用 bash for windows 之类的。b.png
1.2 MB
./vcat_subtitle_imgs.py unpack a.png🌝 最后可以得出这么一个结果
./vcat_subtitle_imgs.py b.png frames/subtitle_*.png
Forwarded from 依云
asyncio 下,一大堆任务怎么处理比较好呢?一个任务队列一个结果队列、若干个 worker?
Forwarded from 依云
我之前是这么干的:
async def main(proto):
q = asyncio.Queue()
ret_q = asyncio.Queue()
futures = [worker(q, ret_q) for _ in range(40)]
producer_fu = asyncio.ensure_future(producer(q, proto))
printer_fu = asyncio.ensure_future(printer(ret_q))
await asyncio.wait(futures)
printer_fu.cancel()
await producer_fu
await printer_fu
Forwarded from 依云
一个 coroutine 往 q 里放任务,一个 coroutine 从 ret_q 里取任务,再加上一堆 worker