How to rotate a video using FFmpeg

本文介绍了如何使用FFmpeg的transpose和rotate滤镜将横屏视频转换为竖屏或不同方向的旋转。两种方法都保留原始音频流,且无需重新编码。确保FFmpeg已安装并可以在命令行中访问。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

To rotate a video using FFmpeg, you can use the transpose filter or the rotate filter. Here are examples of both methods:

Using the transpose filter:

ffmpeg -i input.mp4 -vf "transpose=1" -c:a copy output.mp4

In this example, input.mp4 is the horizontal screen video file, and output.mp4 is the resulting vertical screen video file.

The transpose filter with a value of 1 is used to rotate the video 90 degrees clockwise, effectively converting it from horizontal to vertical orientation. The -c:a copy option is used to copy the audio stream without re-encoding.

You can adjust the transpose value based on your specific requirements. Here are the available transpose values:

  • 0: Rotate 90 degrees counterclockwise and flip vertically (default).
  • 1: Rotate 90 degrees clockwise.
  • 2: Rotate 90 degrees counterclockwise.
  • 3: Rotate 90 degrees clockwise and flip vertically.

Using the rotate filter:

ffmpeg -i input.mp4 -vf "rotate=90*PI/180" -c:a copy output.mp4

In this example, input.mp4 is the input video file, and output.mp4 is the resulting rotated video file. The rotate filter is used with an angle specified in radians. In this case, 90*PI/180 rotates the video 90 degrees clockwise. You can adjust the angle to rotate the video in different directions.

Both methods preserve the original audio stream without re-encoding using the -c:a copy option.

Make sure you have FFmpeg installed on your system and accessible in the command line before running the command.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值