Code Monkey home page Code Monkey logo

sennrisyunnga / video-editing-auxiliary-tool-based-on-barrage-analysis- Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 3.0 2.1 MB

原理是这样子的: 假设观众的弹幕是大众趣味的正确反馈,在精彩时刻就会有大量特定弹幕, 那么可以反向通过统计一段时间内特定弹幕的数量,来识别出一个长视频中受欢迎的部分。 统计是通过输入关键词来进行的,例如对于特别有趣的片段,观众倾向于发送“草”这一弹幕。 假设在一段时间内,草的弹幕超出了预设的限制(limit),工具应当记下该时间轴,并提供给剪辑者一个参考时间轴。 在一段时间内,由于网络延迟的问题,弹幕的出现不是同步的, 观众见证一个亮点时刻时,作为反应的弹幕也会分散在数秒之中。 因此将统计的范围放到当前时刻开始的5秒之内。只要总计的弹幕达到了阈值(limit) 就记下当前时刻,并且从20秒间隔(interval)后重新开始新一轮判定。 若当前时刻并不达标,将当前时间往后推进1秒。 之所以设置了20秒的冷却间隔(interval),是为了减少重复记轴—— 精彩镜头从来不是瞬间,而是从某个时间点开始的时间段 如果不设置冷却时间,那么相邻的数秒都会被纳入统计。 这样输出的数个结果的参考意义是很有限的。 统计开始容易,统计结束位置很难,但是结束位置可以人为判断,未必要越厨代庖。 因此这个工具旨在提供一个“精彩片段的开始大致时间”, 给剪辑者、补长视频的观众作为跳转参考。 这样一来工具的运行时间也能一定程度上减少。

License: MIT License

Python 100.00%

video-editing-auxiliary-tool-based-on-barrage-analysis-'s People

Contributors

sennrisyunnga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

video-editing-auxiliary-tool-based-on-barrage-analysis-'s Issues

通过av号或bv号获取在线弹幕及使用python内置xml库处理xml数据

通过av号或bv号获取在线弹幕

import requests    #第三方库,需通过pip安装
def getDanmu(vid):
    if vid.startswith("BV"):    #BV号
        resp = requests.get(f"https://api.bilibili.com/x/player/pagelist?bvid={vid}")
    elif vid.startswith("av"):    #AV号
        resp = requests.get(f"https://api.bilibili.com/x/player/pagelist?aid={vid[2:]}")
    elif vid.isdigit():    #AV号(纯数字)
        resp = requests.get(f"https://api.bilibili.com/x/player/pagelist?aid={vid}")
    else:
        raise Exception("无效的av号或bv号")
    if resp.ok:
        data = resp.json()
        return requests.get(f"https://api.bilibili.com/x/v1/dm/list.so?oid={data['data'][0]['cid']}")
    else:
        raise Exception(resp.reason)

处理xml数据

import xml.etree.ElementTree as ET
root = ET.fromstring(getDanmu("vid").content)
for danmu in root.findall('d'):
    print(danmu.attrib['p'].split(',')[0], danmu.text)    #时间,弹幕

EDIT: 修复了一些bug

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.