iphone竖屏视频旋转_在Linux上从iPhone旋转视频

张博涛
2023-12-01

iphone竖屏视频旋转

iPhone is nice to take videos. However, one headache is the video may be rotated by 90 degree if you play it with non-Apple software such as MPlayer on Linux or Windows. This tutorial will introduce how to rotate the video taken from iPhone or other sources on Linux by 90 degree.

iPhone非常适合拍摄视频。 但是,令人头疼的是,如果您使用非Apple 软件(例如Linux或Windows上的MPlayer)播放视频,则视频可能会旋转90度。 本教程将介绍如何将从iPhone或Linux上的其他来源拍摄的视频旋转90度。

The tool we choose to use is ffmpeg which can rotate video with video filters.

我们选择使用的工具是ffmpeg ,它可以使用视频滤镜旋转视频。

ffmpeg supports several “transpositions”:

ffmpeg支持几种“换位”:

0 = 90CounterCLockwise and Vertical Flip (default)
1 = 90Clockwise
2 = 90CounterClockwise
3 = 90Clockwise and Vertical Flip

To rotate 90 clockwise, we will choose “1” like:

要顺时针旋转90,我们将选择“ 1”,例如:

ffmpeg -i in.mov -vf "transpose=1" -strict -2 out.mov

However, this can work but still has problems: 1) the video aspects are wrong. 2) the quality is relatively low.

但是,这可以工作,但仍然存在问题:1)视频方面是错误的。 2)质量相对较低。

To solve the problems, we can do it by one single shot: setting the aspect during rotating the video by specifying -s to ffmpeg. Now, the problem is how to get the video aspect. MPlayer can help here.

为了解决这些问题,我们可以单拍完成:通过将-s指定为ffmpeg来设置旋转视频时的宽高比。 现在,问题是如何获得视频方面的信息。 MPlayer可以在这里提供帮助。

mplayer -frames 0 -identify ./in.mov 2>/dev/null | grep ^VIDEO

It will print out the aspect of the video like:

它将打印出视频的外观,例如:

VIDEO:  [H264]  1920x1080  24bpp  29.970 fps  21551.4 kbps (2630.8 kbyte/s)

After it is rotated, it should be “1080×1920”. It may be quite large and usually can be reduced to some smaller one like “540×960” respectively if you like.

旋转后,应为“ 1080×1920”。 它可能很大,通常可以减小到较小的一个,例如“ 540×960”。

The ffmpeg command will be like:

ffmpeg命令将类似于:

ffmpeg -i in.mov -vf "transpose=1" -s 540x960 -strict -2 out.mov

Bonus: MPlayer can also rotate the video during playing:

奖励:MPlayer也可以在播放期间旋转视频:

mplayer -vf-add rotate=1 in.mov

It has the same problem as ffmpeg: it does not know the new aspect and you will need to set it manually. Making the video fullscreen and then turn it back will usually set the correct video aspect.

它与ffmpeg有相同的问题:它不知道新的方面,您将需要手动进行设置。 使视频全屏显示然后再将其转回通常可以设置正确的视频宽高比。

翻译自: https://www.systutorials.com/rotating-video-from-iphone-on-linux/

iphone竖屏视频旋转

 类似资料: