我一直在努力弄清楚如何用FFmpeg旋转视频。我正在工作的iPhone视频拍摄在肖像模式。我知道如何使用MediaInfo (优秀的库,顺便说一句)来确定当前的旋转度,但是我现在只能使用FFmpeg了。
据我所读,您需要使用的是vfilter选项。据我所见,它应该是这样的:
ffmpeg -vfilters "rotate=90" -i input.mp4 output.mp4但是,我不能让它起作用。首先,-vfilters已经不存在了,现在它只是-vf。其次,我得到了这个错误:
No such filter: 'rotate'
Error opening filters!据我所知,我有一个FFmpeg的所有选项。运行ffmpeg -filters显示如下:
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.拥有vflip和hflip的选项是很棒的,但是它们就是不能让我找到我需要去的地方。我需要至少有90度旋转视频的能力。270度也是一个很好的选择。旋转选项到哪里去了?
发布于 2012-03-05 17:19:41
顺时针旋转90:
ffmpeg -i in.mov -vf "transpose=1" out.mov对于转置参数,可以传递:
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选项)。
一个解决方案也是使用这个方便脚本。
发布于 2015-07-28 17:52:27
如果您不想重新编码您的视频,并且您的播放器可以处理旋转元数据,则只需使用ffmpeg更改元数据中的旋转:
ffmpeg -i input.m4v -map_metadata 0 -metadata:s:v rotate="90" -codec copy output.m4v发布于 2010-11-21 00:05:31
你试过transpose了吗?就像(从另一个答案)
ffmpeg -i input -vf transpose=2 output如果您使用的是旧版本,您必须更新ffmpeg,如果您想使用转置功能,因为它是在2011年10月添加的。
FFmpeg 下载页面提供静态构建,无需编译就可以直接执行。
https://stackoverflow.com/questions/3937387
复制相似问题