Skip to content

feat: 新增功能!#175

Open
wacpi wants to merge 113 commits into
wangzmgit:serverfrom
wacpi:server
Open

feat: 新增功能!#175
wacpi wants to merge 113 commits into
wangzmgit:serverfrom
wacpi:server

Conversation

@wacpi

@wacpi wacpi commented Jun 17, 2026

Copy link
Copy Markdown

01:增加oss镜像容灾!
02:增加分离式转码调度微服务!
03:保留单机运行的转码完整性根据需要配置是否远程!
04:增加h265与av1编码!
05:增加字幕功能!
06:增加多音轨分离!(实验性)

acgkiss and others added 30 commits April 11, 2026 13:00
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…action safety

- Replace file-polling audio wait with channel-based signaling (audioDone)
- Handle getMP4InitRange errors instead of silently ignoring them
- Add FOR UPDATE lock in completeTransCoding to prevent race condition
- Check video/resource existence before updating status
- Detect OSS total upload failure (uploadCount == 0)
- Reduce GPU concurrency from 3 to 2 for memory safety
- Add unit tests for 9 pure transcoding functions (46 test cases)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add max_cpu_concurrency / max_gpu_concurrency to transcoding config.
Defaults to hardcoded constants (2) when not set.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add admin endpoints: getManageList, adminUpdateStatus, adminDelete
- Filter pgc_attached content from UGC video management lists
- Auto-register ContentPGC menu under content management (sort after video)
- Fix MenuListToMenuTree to sort children by sort field
- Add API docs, Casbin rules, and sync data for new endpoints

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 新增 ParseResourceID() 支持 shortId 或数字字符串解析资源
- GetVideoFile / GetResourceQuality 接受 resourceShortId 参数
- PlaylistVideoResp 添加 ShortID 字段,SQL 查询补充 video.short_id
- GetPlaylistVideoListWithParts 响应补充 shortId / resourceShortId 字段

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
convertToInt("") 返回 error 导致不传 pgc_type 时直接 500。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 新增 CommentDislike 模型与迁移
- comment service 增加点踩/取消点踩与状态查询
- 视频/文章评论 API 与路由适配点踩
- data.go 初始化数据调整

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- online 服务 groupVideoRid 由 string(rune) 改为 strconv.FormatUint,修复大 id 和代理对退化为 U+FFFD 的分组碰撞
- GetVideoOnlineConnect 透传 rid,建立 vid+rid 复合分组
- danmaku 服务按分组 ws 广播,同时对发送者回推,支持前端单条插入

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- 将顶层函数与 package-level 状态收进 TranscodeService 结构体
- 合并 encodeVideoOnly / encodeVideoOnlyGPU 为单个 runVideoEncodeTask,消除大段重复
- 新增 StorageUploader 接口,留出依赖注入口便于单测
- SharedTask 抽为通用 once+wait 模式,音频编码只跑一次多处等待
- OSS 上传重试改为 ctx 感知的 select/time.After,进程关停不阻塞
- FFmpeg 单实例线程数按并发数等分并夹在 [1, 8],避免 CPU 上下文切换风暴
旧流程对未软删的 resource 走 GORM 软删,会保留 deleted_at 非空的行;
但 resource.short_id 上有 UNIQUE 索引且不含 deleted_at 判定,新资源复用
同一 ShortID Create 时必报 Error 1062 Duplicate entry。

改为统一硬删:用户侧数据(弹幕/历史/收藏/点赞)均通过 short_id 或 vid
关联,新资源复用 ShortID 即可续上绑定;按 resource.id 关联的
video_index_file / video_file_ref 本就由转码重建。软删除在此场景没有业务价值。
- pkg/redis 新增 SetNX 原子封装,消除 Get+Set 的 TOCTOU 竞态
- internal/cache/share.go 按 (userId, vid/aid) 申请占位
- ShareVideo / ShareArticle 计数前先原子占位,命中冷却静默跳过
  (返回 nil 不向前端暴露,攻击者脚本无法通过错误码探测限流边界)

防脚本/外挂对同一稿件反复刷 shares 计数。
…重的 rc-lookahead/AQ 参数\n- bf: 3->2 减少延迟\n\nCPU:\n- 添加 refs:6 B帧参考帧\n- 添加 me_method:hex 运动搜索\n- 添加 subq:9 子像素搜索
- -fps_mode cfr;视频 setpts、音频 asetpts/adelay 与输出 -t 一致

- CPU/GPU 编码合并、线程上限与 NVENC strict_gop

- 补充 ffmpegOutputDurationArgs 等单测
…o shortId, hide internal IDs in JSON, fill shortId fallback
- config: 新增 use_h265 配置项
- dto/vo: UseH265 接口字段
- service/config: 开关持久化到 viper
- service/transcoding: 4 路分支(GPU+H264/HEVC, CPU+H264/HEVC)
- service/transcoding: DefaultHEVCCodec = hvc1.1.6.L150.B0
- service/video: ReTranscodeVideo 增加调试日志
- middleware/auth & operation: 添加 trimBearer 处理 Authorization header
- service/subtitle: 允许空字符串 label 更新,去掉自动回退 lang
- pkg/oss/cloudflare: Region / SigningRegion 从 us-east-1 改为 auto
ReTranscodeVideo 会硬删除旧 resource 并创建新记录,
subtitle_track.resource_id 仍指向已删除的旧 ID,
导致重新转码后字幕丢失。在新 resource 创建后,
将原关联的字字幕轨更新到新的 resource_id。
wacpi and others added 30 commits June 24, 2026 19:00
- model/resource.go: 加 VisibleStatus 字段 (0隐藏/1可见)
- global/resource_status.go: 加 VISIBLE_HIDDEN/SHOWN 常量
- service/upload.go: 新建分P时根据视频是否已公开设置 VisibleStatus
- service/resource.go: 加 GetVisibleResources 公开查询函数
- service/video.go: VideoWriteCache 改用 GetVisibleResources 过滤
- service/transcoding.go: 转码完成后设置 VisibleStatus=1 并清除视频缓存
安全漏洞:已公开视频替换分P时,之前直接用 OriginalVideoStatus
捷径跳到 AUDIT_APPROVED,导致替换内容不经过审核直接上线。

修复后:
1. 替换分P转码完成保持 VisibleStatus=0, Status=WAITING_REVIEW
2. 旧分P被隐藏 (VisibleStatus=0)
3. 视频状态仍保持 AUDIT_APPROVED(不降级)
4. 管理员审核通过后才设为 VisibleStatus=1
5. 审核通过时 ReviewVideoApproved 自动处理
替换流程变更:
  before: C 转码完成 → 立刻隐藏 A (审核期间少一个分P)
  after:  C 转码完成 → A 保持可见,C 进审核
         审核通过 → A 隐藏,C 上线
之前: UploadVideoAdd 时立刻把 A.ShortID 转给 C → A 的 ShortID 为空 →
      审核期间前端拿 A 的 ShortID 查弹幕/字幕返回空

现在:
  - UploadVideoAdd: A 保留 ShortID, C 用新 ShortID
  - 审核期间: A.ShortID 正常 → 弹幕/字幕查询正常
  - 审核通过 ReviewVideoApproved:
      1. 清 A.ShortID
      2. C.ShortID = 原 A.ShortID
      3. A.VisibleStatus=0 (隐藏)
… cleanup

ReviewVideoApproved:
- Add video status guard (only WAITING_REVIEW/AUDIT_APPROVED allowed)
- Exclude replaced resources' duration from totalSec
- Fix ShortID transfer (skip when oldShortID empty)
- Swap cache order: SetVideoId before DelVideoInfo
- Reorder cleanup: ref count first, then delete records

ReviewVideoFailed:
- Add video status guard
- First-time reject: also set WAITING_REVIEW resources to REVIEW_FAILED
- Replacement reject: only reject WAITING_REVIEW resources

completeTransaction (transcoding.go):
- Remove OriginalVideoStatus auto-approve shortcut
- All resources go through WAITING_REVIEW regardless of video state
- ratelimit.go: 新增 UploadCreateRateLimit(3/min/user)、
  UploadChunkRateLimit(60/min/user)、UploadImgRateLimit(10/min/user)、
  UploadCheckRateLimit(30/min/user)
- maxbody.go: 新增 MaxBodySize 中间件,上传路由按类型限制:
  分片50MB/图片10MB/JSON接口1MB
- upload_router.go: 所有上传路由挂接 RateLimiter + MaxBodySize
移除 ESCAPE '\\' 子句,MySQL 默认转义符即为 \\,
escapeLikeKeyword 已正确对 %/_/\\ 做转义
- bool→int8: Video, Article model + DTO + VO
- constants: CopyrightUnknown(0), Original(1), Reprint(2), PGC(3)
- upload default: true→CopyrightReprint (2)
- PGC binding now sets copyright=CopyrightPGC (3)
- go vet clean
FixPGCCopyright() in InitDefaultData, runs every boot to
correct any video where pgc_attached=1 but copyright!=3
- model: add PGCEpisodeID uint (column ep_id) for reverse lookup
- markVideosAsPGCAttached: subquery backfills ep_id on bind
- FixPGCCopyright: also backfills ep_id for existing records via JOIN
- model: add CopyrightOrigin int8 (column copyright_original)
- markVideosAsPGCAttached: stash copyright→copyright_original before overwrite
- FixPGCCopyright: backfill copyright_original=0 for legacy bound records
convertToInt can't parse base62 short IDs (e.g. 'htG6ztSmyANA').
Replaced with service.ParseVideoID which handles both numeric
and short_id formats.
After copyright bool→int8 migration, cached JSON with old
bool values breaks deserialization. Now deletes the stale
key on error so callers re-fetch from DB with new format.
Worker 进度回调补充 updated 字段防止 Cron 误判过期; Cron HGet status 返回 nil 时改用 HLen 检查存活而非报错

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
handleRemoteCompletion 写死 audio.m4s -> AudioFileNameForTrack(language)
处理中列表去掉 WAITING_REVIEW 避免与审核区重复

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant