9001 / 9001/copyparty

Add subtitle support for the web video player

未关闭
#311 6 条评论 21 个 reaction 已指派 1 人 已被 @9001 认领 在 GitHub 查看
enhancement
主要语言
Python
星标
46.7k
派生
1.9k
平均合并
9 天 2 小时
30 天内合并 PR
4

描述

### Is your feature request related to a problem? Please describe.

When playing video files (like MP4s) that contain embedded subtitles, there is no way to view them. I understand this is a fundamental limitation of web browsers, which cannot render embedded subtitle streams directly from a video file.

### Describe the solution you'd like

1. **Probe for Subtitles:** When a video page is requested, use `ffprobe` or a similar tool to detect if and which subtitle tracks are embedded in the video file. Also search for [filename][.lang][.vtt/.srt], to find external files.

2. **Insert `` Tags:** For each detected subtitle track, dynamically generate and insert an HTML `` tag into the `` element. The `src` attribute for each tag should point to a unique URL that signals to extract that specific track (e.g., `src=".../video.mp4?sub-track=1&format=vtt"`).

3. **On-Demand VTT Generation:** When the browser requests one of these `src` URLs (i.e., when the user selects a subtitle), copyparty should use `ffmpeg` to extract only the requested subtitle track on-the-fly, convert it to the WebVTT (`.vtt`) format, and serve it directly to the browser. In case of external .srt file it could be converted using `ffmpeg`.

The generated HTML for the player could look something like this to make the subtitles available to the browser:

```html



```

**Key Advantage:**
The primary benefit of this approach is the seamless user experience. The user doesn't have to manually create or manage extra subtitle files, which are, as standalone files, of no interest to them. Instead, subtitles are simply available in the browser where they are needed, reducing the manual preparation effort for a media library to zero, while still allowing for external subtitles if that's what the user already has.

### Describe alternatives you've considered
I attempted a manual workaround by extracting the subtitles myself and placing the `.vtt` and `.srt` files in the same directory, using the same filename as the video (e.g., `my-movie.mp4` and `my-movie.vtt`).

However, this approach does not work because these files do not automatically get detected and the required `` tags in the HTML do not get generated. As a result, the browser is never made aware of the external subtitle files.

贡献指南

打开贡献指南

调研方向

查看 copyparty Web 界面中的视频播放器 HTML 生成逻辑。该方案需要集成 ffprobe,以检测嵌入式字幕轨道和外部 .vtt/.srt 文件,然后动态添加 标签。当请求字幕 URL 时,后端必须按需提取字幕,并通过 ffmpeg 将其转换为 WebVTT。检查现有的媒体处理和 URL 路由,以确定应在哪里添加字幕探测和提供逻辑。

由索引模型根据 Issue 内容生成。

评估

技术栈
html, javascript, python
领域
backend, frontend, web-dev
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。