可以使用FFmpeg为视频流设置旋转字段吗? [英] Can I set rotation field for a video stream with FFmpeg?
问题描述
现在我有另一个视频文件没有Rotation 90属性,它根本没有Rotation属性。
我可以使用ffmpeg.exe来生成输出文件添加旋转90属性,没有其他更改?我真的不想做任何转换,只是想设置Rotation属性。
我尝试过 -metadata
选项无效。
这适用于最近的FFmpeg:
ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate = 90 output.mp4
pre>
这将流拷贝 v:0 )的元数据在此处更改,播放器将以旋转方式显示视频。 (不是所有的玩家都会支持这一点。)
其他注释:
- p>如果要实际旋转视频,则必须使用
转置
过滤器。过滤将需要重新编码,因此您必须删除-c copy
。 -
如果您省略
-c copy
,并且想要进行编码,而不是只进行重新复制,那么ffmpeg
会自动旋转视频if有任何现有的旋转元数据。您可以使用-noautorotate
禁用此行为。
I have a video file. I open it with MediaInfo utility and I can see a video stream in this file having attribute Rotation 90 (along with other attributes such as CodecID, bitrate etc).
Now I have another video file which does not have that attribute Rotation 90, it does not have the Rotation attribute at all.
Can I use ffmpeg.exe so that it produces output file with Rotation 90 attribute added and with no other changes? I don't really want to do any transform, just want to set the Rotation attribute.
I've tried the -metadata
option to no avail.
This works with recent FFmpeg:
ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=90 output.mp4
This will stream copy the bitstreams, so no encoding is performed. Only the metadata of the first video stream (v:0
) is changed here and the player will show the video in a rotated way. (Not all players will support this.)
Additional notes:
If you want to "physically" rotate the video, you have to use the
transpose
filter. Filtering will require re-encoding, so you will have to remove-c copy
.If you omit
-c copy
, and want to encode instead of only re-muxing, thenffmpeg
will automatically rotate the video if there is any existing rotate metadata. You can disable this behavior with-noautorotate
.
这篇关于可以使用FFmpeg为视频流设置旋转字段吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!