Skip to content

Commit e1df9d1

Browse files
committed
fix: update config
1 parent 1f319f7 commit e1df9d1

File tree

17 files changed

+51
-51
lines changed

17 files changed

+51
-51
lines changed

README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pip install -r requirements.txt
169169
> - 有关自动切片的配置在 `bilive.toml` 文件的 `[slice]` 部分。
170170
> - `auto_slice` 默认为 false, 即不进行自动切片。
171171
172-
MLLM 模型主要用于自动切片后的切片标题生成,此功能默认关闭,如果需要打开请将 `auto_slice` 参数设置为 `true`其他配置分别有:
172+
MLLM 模型主要用于自动切片后的切片标题生成,此功能默认关闭,如果需要打开请将 `auto_slice` 参数设置为 `true`,并且写下你自己的 prompt,其他配置分别有:
173173
- `slice_duration` 以秒为单位设置切片时长(不建议超过 180 秒)。
174174
- `slice_num` 设置切片数量。
175175
- `slice_overlap` 设置切片重叠时长。切片采用滑动窗口法处理,细节内容请见 [auto-slice-video](https://github.com/timerring/auto-slice-video)
@@ -178,11 +178,11 @@ MLLM 模型主要用于自动切片后的切片标题生成,此功能默认关
178178

179179
接下来配置模型有关的 `mllm_model` 参数即对应的 api-key,请自行根据链接注册账号并且申请对应 api key,填写在对应的参数中,请注意以下模型只有你在 `mllm_model` 参数中设置的那个模型会生效。
180180

181-
| Company | Google | 智谱 | 阿里云 |
182-
|----------------|-------------------|------------------|-----------------------|
183-
| Name | Gemini-2.0-flash | GLM-4V-PLUS | Qwen-2.5-72B-Instruct |
184-
| `mllm_model` | `gemini`| `zhipu` | `qwen` |
185-
| `API key` | [gemini_api_key](https://aistudio.google.com/app/apikey) | [zhipu_api_key](https://www.bigmodel.cn/invite?icode=shBtZUfNE6FfdMH1R6NybGczbXFgPRGIalpycrEwJ28%3D) | [qwen_api_key](https://bailian.console.aliyun.com/?apiKey=1) |
181+
| Company | Alicloud | zhipu | Google |
182+
|----------------|-----------------------|------------------|-------------------|
183+
| Name | Qwen-2.5-72B-Instruct | GLM-4V-PLUS | Gemini-2.0-flash |
184+
| `mllm_model` | `qwen` | `zhipu` | `gemini` |
185+
| `API key` | [qwen_api_key](https://bailian.console.aliyun.com/?apiKey=1) | [zhipu_api_key](https://www.bigmodel.cn/invite?icode=shBtZUfNE6FfdMH1R6NybGczbXFgPRGIalpycrEwJ28%3D) | [gemini_api_key](https://aistudio.google.com/app/apikey) |
186186

187187

188188
#### 2.3 Image Generation Model(自动生成视频封面)
@@ -191,8 +191,7 @@ MLLM 模型主要用于自动切片后的切片标题生成,此功能默认关
191191
> - 有关自动生成视频封面的配置在 `bilive.toml` 文件的 `[cover]` 部分。
192192
> - `generate_cover` 默认为 false, 即不进行自动生成视频封面。
193193
194-
采用图生图多模态模型,自动获取视频截图并上传风格变换后的视频封面,如需使用本功能,请将 `generate_cover` 参数设置为 `true`。接下来需要配置的参数有 image_gen_model 和对应的 api key,请自行根据链接注册账号并且申请对应 api key,填写在对应的参数中,请注意以下模型只有你在 `image_gen_model` 参数中设置的那个模型会生效。
195-
194+
采用图生图多模态模型,自动获取视频截图并上传风格变换后的视频封面,如需使用本功能,请将 `generate_cover` 参数设置为 `true`,并且写下你自己的 prompt,注意部分模型只支持英文,接下来需要配置的参数有 image_gen_model 和对应的 api key,请自行根据链接注册账号并且申请对应 api key,填写在对应的参数中,请注意以下模型只有你在 `image_gen_model` 参数中设置的那个模型会生效。
196195

197196
| Company | Model Name | `image_gen_model` | `API Key` |
198197
|--------------|--------------------------------|-------------------|---------------------------------------------------------------------------------|
@@ -208,10 +207,10 @@ MLLM 模型主要用于自动切片后的切片标题生成,此功能默认关
208207

209208
#### 3. 配置上传参数
210209

211-
上传默认参数如下,[]中内容全部自动替换。可以在 `bilive.toml` 中自定义相关配置,映射关键词为 `{artist}``{date}``{title}``{source_link}`可自行组合删减定制模板
210+
`bilive.toml` 中自定义相关配置,映射关键词为 `{artist}``{date}``{title}``{source_link}`请自行组合删减定制模板
212211

213-
- `title` 标题模板是`{artist}直播回放-{date}-{title}`,效果为"【弹幕+字幕】[XXX]直播回放-[日期]-[直播间标题]",可自行修改
214-
- `description` 简介模板是`{artist}直播,直播间地址:{source_link} 内容仅供娱乐,直播中主播的言论、观点和行为均由主播本人负责,不代表录播员的观点或立场。`,效果为"【弹幕+字幕】[XXX]直播,直播间地址:[https://live.bilibili.com/XXX] 内容仅供娱乐,直播中主播的言论、观点和行为均由主播本人负责,不代表录播员的观点或立场。",可自行修改
212+
- `title` 标题模板
213+
- `description` 简介模板
215214
- `gift_price_filter = 1` 表示过滤价格低于 1 元的礼物。
216215
- `reserve_for_fixing = false` 表示如果视频出现错误,重试失败后不保留视频用于修复,推荐硬盘空间有限的用户设置 false。
217216
- `upload_line = "auto"` 表示自动探测上传线路并上传,如果需要指定固定的线路,可以设置为 `bldsa``ws``tx``qn``bda2`

bilive.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ inference_model = "small" # If you choose "deploy", you should download the infe
1515

1616
[video]
1717
# You can change the title as you like, eg.
18-
# f"{artist}直播回放-{date}-{title}" - Streamer直播回放-20250328-Live title
19-
# f"{date}-{artist}直播回放" - 20250328-Streamer直播回放
20-
title = "{artist}直播回放-{date}-{title}" # Key words: {artist}, {date}, {title}, {source_link}
21-
description = "{artist}直播回放,直播间地址:{source_link} 内容仅供娱乐,直播中主播的言论、观点和行为均由主播本人负责,不代表录播员的观点或立场。" # Key words: {artist}, {date}, {title}, {source_link}
18+
title = "{date}直播" # Key words: {artist}, {date}, {title}, {source_link}
19+
description = "录制请征求主播同意,若未经同意就录制,所引起的任何法律问题均由该违规录制的 b 站账号承担。" # Key words: {artist}, {date}, {title}, {source_link}
2220
gift_price_filter = 1 # The gift whose price is less than this value will be filtered, unit: RMB
2321
reserve_for_fixing = false # If encounter MOOV crash error, delete the video or reserve for fixing
2422
upload_line = "auto" # The upload line to be used, default None is auto detect(recommended), if you want to specify, it can be "bldsa", "ws", "tx", "qn", "bda2".
@@ -30,13 +28,15 @@ slice_num = 2 # the number of slices
3028
slice_overlap = 30 # the overlap of slices(seconds) see my package https://github.com/timerring/auto-slice-video for more details
3129
slice_step = 1 # the step of slices(seconds)
3230
min_video_size = 200 # The minimum video size to be sliced (MB)
33-
mllm_model = "gemini" # the multi-model LLMs, can be "gemini" or "zhipu" or "qwen"
31+
mllm_model = "qwen" # the multi-model LLMs, can be "qwen" or "gemini" or "zhipu"
32+
slice_prompt = "" # Write your own slice prompt here
33+
qwen_api_key = "" # Apply for your own Qwen API key at https://bailian.console.aliyun.com/?apiKey=1
3434
zhipu_api_key = "" # Apply for your own GLM-4v-Plus API key at https://www.bigmodel.cn/invite?icode=shBtZUfNE6FfdMH1R6NybGczbXFgPRGIalpycrEwJ28%3D
3535
gemini_api_key = "" # Apply for your own Gemini API key at https://aistudio.google.com/app/apikey
36-
qwen_api_key = "" # Apply for your own Qwen API key at https://bailian.console.aliyun.com/?apiKey=1
3736

3837
[cover]
3938
generate_cover = false # whether to generate cover
39+
cover_prompt = "" # Write your own cover prompt here
4040
image_gen_model = "minimax" # the image generation model, can be "minimax" or "siliconflow" or "tencent" or "baidu" or "stability" or "luma" or "ideogram" or "recraft" or "amazon"
4141
minimax_api_key = "" # Apply for your own Minimax API key at https://platform.minimaxi.com/user-center/basic-information/interface-key
4242
siliconflow_api_key = "" # Apply for your own SiliconFlow API key at https://cloud.siliconflow.cn/i/3Szr5BVg

src/autoslice/mllm_sdk/gemini_new_sdk.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from google import genai
22
from google.genai import types
33
from src.log.logger import scan_log
4-
from src.config import GEMINI_API_KEY
4+
from src.config import GEMINI_API_KEY, SLICE_PROMPT
55

66
def gemini_generate_title(video_path, artist):
77

@@ -14,14 +14,14 @@ def gemini_generate_title(video_path, artist):
1414
model='models/gemini-2.0-flash',
1515
contents=types.Content(
1616
parts=[
17-
types.Part(text=f'视频是{artist}的直播的切片,请根据该视频中的内容及弹幕信息,为这段视频起一个调皮并且吸引眼球的标题,只需要返回一个标题即可,无需返回其他内容,标题中不要有表情符号。'),
17+
types.Part(text=SLICE_PROMPT),
1818
types.Part(
1919
inline_data=types.Blob(data=video_bytes, mime_type='video/mp4')
2020
)
2121
]
2222
)
2323
)
2424
scan_log.info("使用 Gemini-2.0-flash 生成切片标题")
25-
scan_log.info(f"Prompt: 视频是{artist}的直播的切片,请根据该视频中的内容及弹幕信息,为这段视频起一个调皮并且吸引眼球的标题,只需要返回一个标题即可,无需返回其他内容,标题中不要有表情符号。")
25+
scan_log.info(f"Prompt: {SLICE_PROMPT}")
2626
scan_log.info(f"生成的切片标题为: {response.text}")
2727
return response.text

src/autoslice/mllm_sdk/gemini_old_sdk.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import google.generativeai as genai
2-
from src.config import GEMINI_API_KEY
2+
from src.config import GEMINI_API_KEY, SLICE_PROMPT
33
from src.log.logger import scan_log
44
import time
55

@@ -22,7 +22,7 @@ def gemini_generate_title(video_path, artist):
2222
raise ValueError(video_file.state.name)
2323

2424
# Create the prompt.
25-
prompt = f"视频是{artist}的直播的切片,请根据该视频中的内容及弹幕信息,为这段视频起一个调皮并且吸引眼球的标题,只返回该标题即可,无需返回其他内容,标题中不要有表情符号。"
25+
prompt = SLICE_PROMPT
2626

2727
# Set the model to Gemini Flash.
2828
model = genai.GenerativeModel(model_name="models/gemini-2.0-flash")
@@ -32,6 +32,6 @@ def gemini_generate_title(video_path, artist):
3232
# delete the video file
3333
genai.delete_file(video_file.name)
3434
scan_log.info("使用 Gemini-2.0-flash 生成切片标题")
35-
scan_log.info(f"Prompt: 视频是{artist}的直播的切片,请根据该视频中的内容及弹幕信息,为这段视频起一个调皮并且吸引眼球的标题,只需要返回一个标题即可,无需返回其他内容,标题中不要有表情符号。")
35+
scan_log.info(f"Prompt: {SLICE_PROMPT}")
3636
scan_log.info(f"生成的切片标题为: {response.text}")
3737
return response.text

src/autoslice/mllm_sdk/qwen_sdk.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from src.config import QWEN_API_KEY
1+
from src.config import QWEN_API_KEY, SLICE_PROMPT
22
from src.log.logger import scan_log
33
from openai import OpenAI
44
import os
@@ -28,12 +28,12 @@ def qwen_generate_title(video_path, artist):
2828
"type": "video_url",
2929
"video_url": {"url": f"data:video/mp4;base64,{base64_video}"},
3030
},
31-
{"type": "text", "text": f"视频是{artist}的直播切片,请根据该视频中的内容及弹幕信息,为这段视频起一个调皮并且吸引眼球的标题,标题中不要表情符号,可以适当使用网络热词或流行语"},
31+
{"type": "text", "text": SLICE_PROMPT},
3232
],
3333
}
3434
],
3535
)
3636
scan_log.info("使用 Qwen-2.5-72B-Instruct 生成切片标题")
37-
scan_log.info(f"Prompt: 视频是{artist}的直播切片,请根据该视频中的内容及弹幕信息,为这段视频起一个调皮并且吸引眼球的标题,标题中不要表情符号,可以适当使用网络热词或流行语")
37+
scan_log.info(f"Prompt: {SLICE_PROMPT}")
3838
scan_log.info(f"生成的切片标题为: {completion.choices[0].message.content}")
3939
return completion.choices[0].message.content.strip('"')

src/autoslice/mllm_sdk/zhipu_sdk.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) 2024 bilive.
22

33
import base64
4-
from src.config import ZHIPU_API_KEY
4+
from src.config import ZHIPU_API_KEY, SLICE_PROMPT
55
from zhipuai import ZhipuAI
66
from src.log.logger import scan_log
77

@@ -24,13 +24,13 @@ def zhipu_glm_4v_plus_generate_title(video_path, artist):
2424
},
2525
{
2626
"type": "text",
27-
"text": f"视频是{artist}的直播的切片,请根据该视频中的内容及弹幕信息,为这段视频起一个调皮并且吸引眼球的标题,注意标题中如果有“主播”请替换成{artist}"
27+
"text": SLICE_PROMPT
2828
}
2929
]
3030
}
3131
]
3232
)
3333
scan_log.info("使用 Zhipu-glm-4v-plus 生成切片标题")
34-
scan_log.info(f"Prompt: 视频是{artist}的直播的切片,请根据该视频中的内容及弹幕信息,为这段视频起一个调皮并且吸引眼球的标题,注意标题中如果有“主播”请替换成{artist}")
34+
scan_log.info(f"Prompt: {SLICE_PROMPT}")
3535
scan_log.info(f"生成的切片标题为: {response.choices[0].message.content}")
3636
return response.choices[0].message.content.replace("《", "").replace("》", "")

src/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,6 @@ def get_interface_config():
8585
RECRAFT_API_KEY = config.get('cover', {}).get('recraft_api_key')
8686
AWS_ACCESS_KEY_ID = config.get('cover', {}).get('aws_access_key_id')
8787
AWS_SECRET_ACCESS_KEY = config.get('cover', {}).get('aws_secret_access_key')
88+
89+
SLICE_PROMPT = config.get('slice', {}).get('slice_prompt')
90+
COVER_PROMPT = config.get('cover', {}).get('cover_prompt')

src/cover/image_model_sdk/amazon_sdk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from botocore.exceptions import ClientError
1313
import os
1414
import time
15-
from src.config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
15+
from src.config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, COVER_PROMPT
1616

1717
class ImageError(Exception):
1818
"Custom exception for errors returned by Amazon Titan Image Generator V2"
@@ -67,7 +67,7 @@ def amazon_generate_cover(your_file_path):
6767
body = json.dumps({
6868
"taskType": "TEXT_IMAGE",
6969
"textToImageParams": {
70-
"text": "This is a video screenshot, please generate a cover in the style of a manga",
70+
"text": COVER_PROMPT,
7171
"negativeText": "",
7272
"conditionImage": input_image,
7373
"controlMode": "CANNY_EDGE"

src/cover/image_model_sdk/baidu_sdk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from io import BytesIO
77
import time
88
from src.upload.bilitool.bilitool.model.model import Model
9-
from src.config import BAIDU_API_KEY
9+
from src.config import BAIDU_API_KEY, COVER_PROMPT
1010

1111

1212
def cover_up(img: str):
@@ -72,7 +72,7 @@ def baidu_generate_cover(your_file_path):
7272
payload = json.dumps(
7373
{
7474
"model": "irag-1.0",
75-
"prompt": "这是视频截图,请根据该图生成对应的动漫类型的封面",
75+
"prompt": COVER_PROMPT,
7676
"refer_image": cover_url,
7777
}
7878
)

src/cover/image_model_sdk/ideogram_sdk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import json
33
import os
44
import time
5-
from src.config import IDEOGRAM_API_KEY
5+
from src.config import IDEOGRAM_API_KEY, COVER_PROMPT
66

77

88
def ideogram_generate_cover(your_file_path):
@@ -19,7 +19,7 @@ def ideogram_generate_cover(your_file_path):
1919
payload = {
2020
"image_request": json.dumps(
2121
{
22-
"prompt": "This is a video screenshot, please generate a cover in the style of a manga",
22+
"prompt": COVER_PROMPT,
2323
"aspect_ratio": "ASPECT_10_16",
2424
"image_weight": 75,
2525
"magic_prompt_option": "ON",

0 commit comments

Comments
 (0)