Skip to content

fix(api): report video/mp4 for .mov so browsers don't reject original QuickTime playback - #126

Closed
rehack wants to merge 1 commit into
nianzhibai:mainfrom
rehack:fix/mov-playback-mediatype
Closed

rehack wants to merge 1 commit into
nianzhibai:mainfrom
rehack:fix/mov-playback-mediatype

Conversation

@rehack

@rehack rehack commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

问题

.mov 视频在 Chrome/Edge 显示「浏览器无法播放当前视频」,.mp4 正常。库内 .mov 占比很大,表现为“很多视频无法播放”。

根因

playbackMediaType() 对 .mov 返回 video/quicktime(backend/internal/api/api.go),而浏览器的
canPlayType('video/quicktime') 返回空字符串 ""。前端 videoSource 用
canPlayType(mediaType)==='' 判断“不支持”并跳过源,导致唯一可用的原画源被拦截;
但浏览器其实能直接解码 H.264/AAC 的 .mov(实测 <video src> 可 canplaythrough)。

改动

  • .mov 的 mediaType 统一为 video/mp4(与本仓库 .m4v 现有行为一致)。
  • .mkv/.avi 等浏览器确实不支持的类型仍返回 "",继续走 transcoded/HLS 兜底,行为不变。
  • TestPlaybackMediaTypeDescribesSelectedResource 增加 .mov -> video/mp4 用例。

说明

根因也可在独立前端仓库 91-web / 91-web-nostalgic 里进一步加固(不要仅凭 canPlayType 硬拒绝 file 源,交给 <video> 实际尝试并按 error 回退)。本后端改动即可让现有前端恢复正常播放。

…me sources

playbackMediaType() returned video/quicktime for .mov, but browsers'
canPlayType('video/quicktime') returns an empty string, which makes the web
frontend treat the only (original) playback source as unsupported and show
"browser cannot play this video", even though Chrome/Edge can decode
H.264/AAC .mov.

Map .mov to video/mp4 (consistent with the existing .m4v case) so the
original source is not rejected. Genuinely unsupported containers (mkv/avi)
still return "" and fall back to transcoded/HLS.

Adds a case to TestPlaybackMediaTypeDescribesSelectedResource.
@nianzhibai

Copy link
Copy Markdown
Owner

比起把 .mov 映射成 video/mp4 ,不如去掉 case "mov" 、让它走 default
谢谢反馈的问题和 提交的 PR

@nianzhibai nianzhibai closed this Nov 24, 2026
nianzhibai added a commit that referenced this pull request Nov 24, 2026
## Why

Browsers answer `canPlayType("video/quicktime")` with an empty string even
though most `.mov` files carry H.264/AAC they can decode. Advertising that
media type made players reject the original source upfront and fall back to
compatible playback or fail outright.

## What changed

- `playbackMediaType` no longer maps `.mov` to `video/quicktime`, leaving the
  source untyped so players attempt it and recover on actual decode errors.
- Cover `.mov` in `TestPlaybackMediaTypeDescribesSelectedResource`.

## Testing

- `go test ./internal/api/`

Refs #126

Co-authored-by: rehack <rehack@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants