duangsuse::Echo
717 subscribers
4.26K photos
130 videos
583 files
6.48K links
import this:
美而不丑、明而不暗、短而不凡、长而不乱,扁平不宽,读而后码,行之天下,勿托地上天国。
异常勿吞,难过勿过,叹一真理。效率是很重要,盲目最是低效。
简明是可靠的先验,不是可靠的祭品。
知其变,守其恒,为天下式;穷其变,知不穷,得地上势。知变守恒却穷变知新,我认真理,我不认真。

技术相干订阅~
另外有 throws 闲杂频道 @dsuset
转载频道 @dsusep
极小可能会有批评zf的消息 如有不适可退出
suse小站(面向运气编程): https://WOJS.org/#/
Download Telegram
This media is not supported in your browser
VIEW IN TELEGRAM
这个是 stop montage,就是每个 subtitle 排版不变化的(传递 --key-thres 0 每个色块都必须绘制导致的) 没加声音因为不是成品,是替补剪辑素材
由于绘制蒙太奇图时 #FFFFFF 颜色会和小黑自己的颜色冲突导致小黑无 text fill 所以手动剪辑换边框颜色,直接用 Kdenlive 剪的(第一张),第二张是实验照。
luoxioaheimon.kdenlive
51.2 KB
好了,做完了 #media #acg
Media is too big
VIEW IN TELEGRAM
#video #acg 《罗小黑战记》番外《晚安喵》中文彩色字符画版剪辑 [相关信息]
lxh.srt
1.1 KB
这个是 montage1_c.py 字幕 (--subtitle)
This media is not supported in your browser
VIEW IN TELEGRAM
这个是原版的白色背景替换版本
duangsuse::Echo
这个是 stop montage,就是每个 subtitle 排版不变化的(传递 --key-thres 0 每个色块都必须绘制导致的) 没加声音因为不是成品,是替补剪辑素材
大概说一下必须要啥接口啊…… (不止这个项目,是我最近用过的 API,emmm) #Python
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.BufferedImagejava.awt.Graphics 也是支持绘制文字的(但不能在调用里直接自定义字体)
def channelHistogram(img):
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))
#Python #code #CV 🤔
新版 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
🌝 最后可以得出这么一个结果
西方的法制_字幕.txt
2.8 KB
🌚我居然把一个半透明质量这么差的字幕提取出来了…… 那些代码改得真不容易
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
Forwarded from 任桑 今天开始做魔王
并发量的话上个变量计数就好阿.....
Forwarded from 任桑 今天开始做魔王
b协程判断在执行的任务数达到上限就不取任务