Skip to content

fix: 视频转码后保留旋转角度(修复手机竖屏视频转码后旋转90度) - #809

Open
ZevFung wants to merge 1 commit into
kekingcn:masterfrom
ZevFung:fix/mov-video-rotation
Open

ZevFung wants to merge 1 commit into
kekingcn:masterfrom
ZevFung:fix/mov-video-rotation

Conversation

@ZevFung

@ZevFung ZevFung commented Oct 19, 2026

Copy link
Copy Markdown

问题

手机(如 iPhone)拍摄的竖屏 mov 视频,旋转信息只存在 display matrix 元数据里。Mediatomp4Service 用 JavaCV 逐帧转码,帧本身未旋转,且 FFmpegFrameRecorder 没有写入该元数据,所以转码出来的 mp4 播放时被旋转了 90°。

修改

在 configureRecorder 中读取 grabber.getDisplayRotation(),非 0 时调用 recorder.setDisplayRotation(...) 写入输出文件(二者角度约定一致,均为 ffmpeg av_display_rotation_*)。仅新增 5 行。

验证

已用 JDK 21 编译打包通过。竖屏 iPhone mov 的实际预览效果请合并前由维护者/评审再确认。

🤖 Generated with Claude Code

手机(iPhone等)拍摄的 mov 视频,旋转信息只保存在 display matrix 元数据中,
JavaCV 逐帧转码时帧本身未旋转,而 FFmpegFrameRecorder 未写入该元数据,
导致转码后的 mp4 方向错误。现从 grabber 读取 displayRotation 并设置到 recorder。

Co-Authored-By: Claude Sonnet 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.

1 participant