首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >用FFmpeg旋转视频

用FFmpeg旋转视频
EN

Stack Overflow用户
提问于 2010-10-14 20:44:09
回答 15查看 381.7K关注 0票数 527

我一直在努力弄清楚如何用FFmpeg旋转视频。我正在工作的iPhone视频拍摄在肖像模式。我知道如何使用MediaInfo (优秀的库,顺便说一句)来确定当前的旋转度,但是我现在只能使用FFmpeg了。

据我所读,您需要使用的是vfilter选项。据我所见,它应该是这样的:

代码语言:javascript
运行
复制
ffmpeg -vfilters "rotate=90" -i input.mp4 output.mp4

但是,我不能让它起作用。首先,-vfilters已经不存在了,现在它只是-vf。其次,我得到了这个错误:

代码语言:javascript
运行
复制
No such filter: 'rotate'
Error opening filters!

据我所知,我有一个FFmpeg的所有选项。运行ffmpeg -filters显示如下:

代码语言:javascript
运行
复制
Filters:
anull            Pass the source unchanged to the output.
aspect           Set the frame aspect ratio.
crop             Crop the input video to x:y:width:height.
fifo             Buffer input images and send them when they are requested.
format           Convert the input video to one of the specified pixel formats.
hflip            Horizontally flip the input video.
noformat         Force libavfilter not to use any of the specified pixel formats
 for the input to the next filter.
null             Pass the source unchanged to the output.
pad              Pad input image to width:height[:x:y[:color]] (default x and y:
 0, default color: black).
pixdesctest      Test pixel format definitions.
pixelaspect      Set the pixel aspect ratio.
scale            Scale the input video to width:height size and/or convert the i
mage format.
slicify          Pass the images of input video on to next video filter as multi
ple slices.
unsharp          Sharpen or blur the input video.
vflip            Flip the input video vertically.
buffer           Buffer video frames, and make them accessible to the filterchai
n.
color            Provide an uniformly colored input, syntax is: [color[:size[:ra
te]]]
nullsrc          Null video source, never return images.
nullsink         Do absolutely nothing with the input video.

拥有vfliphflip的选项是很棒的,但是它们就是不能让我找到我需要去的地方。我需要至少有90度旋转视频的能力。270度也是一个很好的选择。旋转选项到哪里去了?

EN

回答 15

Stack Overflow用户

回答已采纳

发布于 2012-03-05 17:19:41

顺时针旋转90:

代码语言:javascript
运行
复制
ffmpeg -i in.mov -vf "transpose=1" out.mov

对于转置参数,可以传递:

代码语言:javascript
运行
复制
0 = 90CounterCLockwise and Vertical Flip (default)
1 = 90Clockwise
2 = 90CounterClockwise
3 = 90Clockwise and Vertical Flip

使用-vf "transpose=2,transpose=2" 180度。

确保您使用了最近的ffmpeg版本从这里开始 (静态构建将运行良好)。

注意,这将重新编码音频和视频部分.通过使用-c:a copy,您通常可以复制音频而不需要触摸它。若要更改视频质量,请设置比特率(例如,使用-b:v 1M)或查看H.264编码指南 (如果需要VBR选项)。

一个解决方案也是使用这个方便脚本

票数 877
EN

Stack Overflow用户

发布于 2015-07-28 17:52:27

如果您不想重新编码您的视频,并且您的播放器可以处理旋转元数据,则只需使用ffmpeg更改元数据中的旋转:

代码语言:javascript
运行
复制
ffmpeg -i input.m4v -map_metadata 0 -metadata:s:v rotate="90" -codec copy output.m4v
票数 220
EN

Stack Overflow用户

发布于 2010-11-21 00:05:31

你试过transpose了吗?就像(从另一个答案)

代码语言:javascript
运行
复制
 ffmpeg -i input -vf transpose=2 output

如果您使用的是旧版本,您必须更新ffmpeg,如果您想使用转置功能,因为它是在2011年10月添加的。

FFmpeg 下载页面提供静态构建,无需编译就可以直接执行。

票数 98
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3937387

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档