【问题标题】:Video rotation with FFmpeg使用 FFmpeg 进行视频旋转
【发布时间】:2016-03-07 00:28:56
【问题描述】:

我正在为我的 iPhone 应用程序开发 PHP 网络服务,以便用户上传视频。当用户想在网站上观看视频时,他们会得到一个水平视频,所以我需要使用 FFmpeg 命令旋转视频。有人可以帮我吗?

function make_rotation($input, $output, $transpose="1") {
    $ffmpegpath = "ffmpeg";
    if(!file_exists($input)) return false;  
    //$command = "$ffmpegpath -i $input -vf 'transpose=$transpose' $output";
    //$command = "ffmpeg -vfilters 'rotate=270' -i $input $output";
    $command ="ffmpeg -i $input -vf 'transpose=$transpose'  $output";
    exec($command);
    return true;
}

谢谢大家

【问题讨论】:

    标签: php video ffmpeg rotation


    【解决方案1】:
    ffmpeg -vfilters "rotate=90" -i input.mp4 output.mp4
    

    上面的评论对我有用,添加“rotate=90”并检查。

    ffmpeg -i <input_video> -vf “transpose=1″ -r 30 -sameq <output_video>
    

    也可以

    【讨论】:

    • Hi KPBird 非常感谢...但是可以在这里告诉我输入文件和输出文件相同或不同..再次感谢
    • @KPBird 我确实尝试了第二个选项来旋转我的视频,但它没有旋转 1 到 90 度,而不是我通过了 2 它确实旋转了 180 度 请让我知道可以做什么.. 谢谢
    【解决方案2】:

    我已经用这个 mencode 命令修复了旋转问题,如下所示:

    function make_rotation($input, $output, $transpose="1") {
        $cmd="mencoder -vf rotate=1 -o $output -oac pcm -ovc lavc $input";
        exec($cmd);
        if(!file_exists($output)) return false;
        if(filesize($output)==0) return false;
        return true;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-25
      • 2020-01-11
      • 1970-01-01
      • 1970-01-01
      • 2014-05-13
      • 2016-07-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多