V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
mfsw
V2EX  ›  Windows

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

  •  
  •   mfsw · 119 天前 · 1313 次点击
    这是一个创建于 119 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    16 条回复    2023-12-31 22:22:02 +08:00
    mfsw
        1
    mfsw  
    OP
       119 天前
    跟 chatgpt 斗智斗勇了好久,他都没能提供给我一个可用的 ffmpeg 的命令。诸位大佬请发威吧。
    qwertyegg
        2
    qwertyegg  
       119 天前
    ffmpeg -i input.mp4 -vf "transpose=1" output.mp4

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

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

    targetPattern := concat3("c:\captures\", prefix, "*.mp4")
    udp_profiles := []
    loop files targetPattern
    udp_profiles.Push(A_LoopFileName)
    }
    mfsw
        10
    mfsw  
    OP
       119 天前
    @qwertyegg 没看懂。这是撒东东?您提供的代码已经很完美了。我只需要把他变成批处理即可。
    qwertyegg
        11
    qwertyegg  
       119 天前
    下面这段 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
        12
    mfsw  
    OP
       119 天前
    @qwertyegg 感谢大佬热心科普。
    能不能帮忙以批处理的方式,实现下?万分感谢。
    miaotaizi
        13
    miaotaizi  
       119 天前
    把屏幕竖起来?
    forgottencoast
        14
    forgottencoast  
       118 天前
    @mfsw
    批处理这个问题 chatGPT 保证不弱智,你问它就行了。
    mfsw
        15
    mfsw  
    OP
       118 天前
    @forgottencoast 3.5 ruozhi ,4.0 可能不 ruozhi 。但是我现在没有 4.0 的账号了。
    1014982466
        16
    1014982466  
       117 天前
    LOSSLESSCUT
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2685 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 11:40 · PVG 19:40 · LAX 04:40 · JFK 07:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.