我可以使用 FFmpeg 为视频流设置旋转字段吗? [英] Can I set rotation field for a video stream with FFmpeg?

查看:28
本文介绍了我可以使用 FFmpeg 为视频流设置旋转字段吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个视频文件.我使用 MediaInfo 实用程序打开它,我可以看到该文件中的视频流具有属性 Rotation 90(以及其他属性,例如 CodecID、比特率等).

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).

现在我有另一个没有 Rotation 90 属性的视频文件,它根本没有 Rotation 属性.

Now I have another video file which does not have that attribute Rotation 90, it does not have the Rotation attribute at all.

我可以使用 ffmpeg.exe 来生成添加了 Rotation 90 属性且没有其他更改的输出文件吗?我真的不想做任何变换,只想设置 Rotation 属性.

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.

我尝试了 -metadata 选项,但无济于事.

I've tried the -metadata option to no avail.

推荐答案

这适用于最近的 FFmpeg:

This works with recent FFmpeg:

ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=90 output.mp4

这将流复制比特流,因此不执行编码.此处仅更改第一个视频流 (v:0) 的元数据,播放器将以旋转方式显示视频.(并非所有玩家都会支持这一点.)

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.)

附加说明:

  • 如果你想物理地"旋转视频,你必须使用transpose过滤.过滤需要重新编码,因此您必须删除 -c copy.

如果你省略了-c copy,并且想要编码而不是仅仅re-muxing,那么ffmpeg会自动旋转视频,如果有的话旋转元数据.您可以使用 -noautorotate 禁用此行为.

If you omit -c copy, and want to encode instead of only re-muxing, then ffmpeg will automatically rotate the video if there is any existing rotate metadata. You can disable this behavior with -noautorotate.

这篇关于我可以使用 FFmpeg 为视频流设置旋转字段吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆