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

技术相干订阅~
另外有 throws 闲杂频道 @dsuset
转载频道 @dsusep
极小可能会有批评zf的消息 如有不适可退出
suse小站(面向运气编程): https://WOJS.org/#/
Download Telegram
不用 smooth 处理的版本虽然要多做很多次 OCR 速度更慢,但提取的时间线也更精确
test.srt
1.7 KB
效果比较好,生成命令:./extract_subtitles.py -crop '(617,955)(685,32)' --crop-debug -filter-code '~cvInGrayRange(it, 0xbf,0xff)' --draw-plot --use-sharp --chunk-size 1000 SomethingNew.mp4
./timeline_ops.py merge frames/timeline_SomethingNew.mp4.txt 0.25|./timeline_ops.py to-lrc 29.97 srt> mux.srt
从这个小细节都可以看出 --use-sharp 多进行了多少次 OCR
而用 smooth 则会少进行很多次 OCR,但这样时间轴就不准确了
有意思的小细节:
def postprocessDifferences(self, a: array) -> array: return smooth(a, self.window_size, self.window)
def findPeaks(self, a: array) -> array: return np.asarray(signal.argrelextrema(a, np.greater))[0] #< argrelextrema(_) always (x,)

^利用 scipy.signal 的新关键帧算法,修复了原来盲目对 argrelextrema 用 numpy.subtract 操作的做法

processChunk = lambda it: self.ocrWithLocalMaxima(it, reducer)
diff_array_parts = map(processChunk, chunked(self.chunk_size, frames))
def concatResults(a, b) -> Tuple[array, array]:
a0, a1 = a
b0, b1 = b
ab0 = concatenate(array([a0, b0]))
ab1 = concatenate(array([a1, b1+len(a0)]))
return (ab0, ab1)
(diff_array, indices) = reduce(concatResults, diff_array_parts)
^把帧差 array 和检测出的关键帧 index array 拼合起来的 reduce function
b1+len(a0) 正好可以把 b1[0] 映射到 a0.lastIndex+1
This media is not supported in your browser
VIEW IN TELEGRAM
好不容易做成现在这个玩具,我得好好拿来玩几天才可以
新玩具真好玩
This media is not supported in your browser
VIEW IN TELEGRAM
其实我觉得这个『多crop』功能,还是可以给加上
也不需要什么数据结构,TreeSet 的 binary search 是为了优化空间复杂度做的,我也可以直接弄 Frame.no 预填充啊
gui_crop_select.py 已经把这个 multi crop 的功能给做了,我也可以顺水推舟下去嘛
mux.srt
2.8 KB
……视频我直接给删了,因为它帧率不正确,而且还没声音
This media is not supported in your browser
VIEW IN TELEGRAM
🤔这个是带字幕的,但 Telegram Desktop 好像不能看字幕
🤔开启了 --use-sharp 后真的把时轴打得非常好
./extract_subtitles.py --crop-debug -crop '(1106,905)(680,62)' -filter-code '~cvInGrayRange(it, 0x00, 0xaa)' -lang chi_sim --draw-plot --use-sharp --chunk-size 1200 HxN.mkv

./timeline_ops.py merge frames/timeline_HxN.mkv.txt 0.25 |./timeline_ops.py to-lrc 60 srt >mux.srt
new.txt 是第一次提取结果手动做了十分钟左右的修改后弄出来的,它的准确度几乎令我惊讶
HxN.srt
2.7 KB
十分钟就修完了,直接可以用的字幕
This media is not supported in your browser
VIEW IN TELEGRAM
改了一些 typo