windows 下,如何无损旋转 mp4 视频?

131 天前
 mfsw

我的视频是佳能相机拍的 MP4 文件。拍的时候是竖版。但是 POTPLAYER 播放的时候是以横版来播放的。 我想把这些横版视频,旋转 90 度,变成拍摄时候的视角。 请问,是否可以利用 ffmpeg,来批量的旋转一下? 如果 ffmpeg 不能实现,是否有其他的软件能快捷的实现批量无损旋转?

1337 次点击
所在节点    Windows
16 条回复
mfsw
131 天前
跟 chatgpt 斗智斗勇了好久,他都没能提供给我一个可用的 ffmpeg 的命令。诸位大佬请发威吧。
qwertyegg
131 天前
ffmpeg -i input.mp4 -vf "transpose=1" output.mp4

transpose=1 或者=2
mfsw
131 天前
@qwertyegg 感谢大佬指教。实测不行,跟 gpt 的答案差不多,视频被旋转了,但是容量变得很小。只有原来的二十分之一。
qwertyegg
131 天前
ffmpeg -display_rotation:v:0 90 -i input.mp4 -c copy output.mp4

这样 stream copy/remux 出来的视频,不重新编码
AoEiuV020JP
131 天前
%bin%ffmpeg -i "%name%%ext%" -c copy -metadata:s:v:0 rotate=%rotate% "%name%-%rotate%%ext%"
mfsw
131 天前
大佬威武,在大佬面前,gpt 就是个弱智。
再请教下,我要把您的这行代码,修改为一个批处理脚本。
我要把指定目录下的所有 mp4 文件,都旋转 90 度,并替换删除原始文件,我该怎么修改? 我希望这个批处理,能提供一个输入选项,让我可以输入指定的目录。
感谢大佬搭救。
mfsw
131 天前
@qwertyegg 6 楼内容是回复您的。忘记引用了。
mfsw
131 天前
@AoEiuV020JP 感谢指教。4 楼大佬的方法好用。就不尝试其他方案了。辛苦您啦。
qwertyegg
131 天前
用 ahk(v2)可以参考如下

targetPattern := concat3("c:\captures\", prefix, "*.mp4")
udp_profiles := []
loop files targetPattern
udp_profiles.Push(A_LoopFileName)
}
mfsw
131 天前
@qwertyegg 没看懂。这是撒东东?您提供的代码已经很完美了。我只需要把他变成批处理即可。
qwertyegg
131 天前
下面这段 ahk 代码,"把 ffmpeg 加到 path 里面"和"mp4 文件不要带空格“两个要求满足的时候应该就可以批量转了

#Requires AutoHotkey v2.0
#SingleInstance Force

; Get list of files matching a prefix under a folder.
; Set prefix an empty string "" if we want all, otherwise add prefix to limit selection
prefix := ""


;=============== init script ===============
targetPattern := concat3("D:\captures\", prefix, "*.mp4")
video_files := []
loop files targetPattern
video_files.Push(A_LoopFileName)
lastIndex := video_files.Length

;;;;;;;;;;; F2 to cycle through rotation jobs
#MaxThreadsPerHotkey 1
F2::{
static counter := 1
while (counter <= lastIndex){
ffmpeg_rotate(video_files[counter])
counter := counter + 1
}
; MsgBox "That was the last, exit."
ExitApp
}


ffmpeg_rotate(video_file){
SetWorkingDir "D:\captures"
Run concat4("ffmpeg -display_rotation:v:0 90 -i ", video_file, " -c copy rotated_", video_file)
}

concat3(x, y, z) {
Return x y z
}

concat4(w, x, y, z) {
Return w x y z
}
mfsw
131 天前
@qwertyegg 感谢大佬热心科普。
能不能帮忙以批处理的方式,实现下?万分感谢。
miaotaizi
130 天前
把屏幕竖起来?
forgottencoast
130 天前
@mfsw
批处理这个问题 chatGPT 保证不弱智,你问它就行了。
mfsw
130 天前
@forgottencoast 3.5 ruozhi ,4.0 可能不 ruozhi 。但是我现在没有 4.0 的账号了。
1014982466
129 天前
LOSSLESSCUT

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1004550

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX