使用FFmpeg进行视频旋转


Video rotation with FFmpeg

我正在为我的iPhone应用程序开发一个PHP web服务,以便用户上传视频。当用户想在网站上观看视频时,他们会得到一个水平视频,所以我需要使用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;
}

感谢所有

ffmpeg -vfilters "rotate=90" -i input.mp4 output.mp4

以上评论对我有效,添加"rotate=90"并检查。

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

也工作

我已经用这个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;
}