h264 mpeg avi_如何旋转以人像拍摄的AVI或MPEG文件

h264 mpeg avi

h264 mpeg avi

I've got a little Casio Exilim that I use to make little videos to post on this blog. Sometimes, though, I rotate the camera and end up creating a video that's, well, rotated in portrait, not landscape, and I want to rotate the Video to a vertical orientation.

我有一些Casio Exilim,可用来制作一些视频以发布到此博客中。 不过,有时我会旋转相机并最终创建一个以纵向旋转而不是横向旋转的视频,并且我想将视频旋转到垂直方向。

There's an open source tool called MPlayer out of Hungary that you can download. Get the MPlayer 1.0rc1 Windows package, NOT the Windows GUI package. We're not looking for a Video Player here  but rather a utility called MEncoder that comes with the MPlayer package.

您可以下载匈牙利以外的一个名为MPlayer的开源工具。 获取MPlayer 1.0rc1 Windows软件包,而不是Windows GUI软件包。 我们不是在这里寻找视频播放器,而是在MPlayer软件包中附带了一个名为MEncoder的实用程序。

This command-line tool is rather obscure, as it seems is the whole culture of video wonks, but I just want to do my work and move on. If you like, however, there's a whole world of Unofficial Packages that sit in front of this obscure tool and do the hard work for you.

这个命令行工具相当晦涩,因为它看起来像是整个视频的文化,但是我只想做我的工作并继续前进。 但是,如果您愿意,在这个晦涩难懂的工具前面有很多非官方软件包,它们会为您辛苦工作。

Here's the magic I used to rotate my video 90 degrees to the right:

这是我用来将视频向右旋转90度的魔术:

C:\Users\Scott\Desktop\mplayer>
mencoder -vf rotate=1 -o OUTPUT.AVI -oac copy -ovc lavc INPUT.AVI

C:\ Users \ Scott \ Desktop \ mplayer> mencoder -vf rotation = 1 -o OUTPUT.AVI -oac复制-ovc lavc INPUT.AVI

The -vf is for "Video Filter" and you can chain them, like -vf rotate=1,flip,scale=640:480 if you like. The -oac and -ovc are the audio and video outputs. In this case, I "copy" the audio over, and use the "libavcodecs" for the output. You can do mencoder -ovc help to get a list of choices or read the massive docs.

-vf用于“视频过滤器”,您可以将它们链接起来,例如-vf rotation = 1,flip,scale = 640:480-oac-ovc是音频和视频输出。 在这种情况下,我“复制”了音频,并使用“ libavcodecs”作为输出。 您可以通过mencoder -ovc帮助获得选择列表或阅读大量文档

At this point, I have a really tall 480x640 video, since it used to be at 640x480. Certainly I can leave it there, or I can expand it to a more regular 4:3 ratio. As it's now 640 tall, it'll need to be 853x640 to be 4:3.

在这一点上,我有一个非常高的480x640视频,因为它以前是640x480。 当然,我可以将其保留在此处,也可以将其扩展为更常规的4:3比例。 由于现在的高度为640,因此必须为853x640才能为4:3。

C:\Users\Scott\Desktop\mplayer>
mencoder -vop expand=853:640 -oac copy ovc lavc -lavcopts vcodec=mjpeg  OUTPUT.AVI -o BIGOUTPUT.AVI

C:\ Users \ Scott \ Desktop \ mplayer> mencoder -vop expand = 853:640 -oac复制ovc lavc -lavcopts vcodec = mjpeg OUTPUT.AVI -o BIGOUTPUT.AVI

Notice that the portrait is now centered between black bars like a vertical DVD. The aspect ratio is correctish now and we have a vertically oriented video inside a horizontally oriented "container."

请注意,人像现在像垂直DVD一样居中于黑条之间。 现在长宽比是正确的,我们在水平的“容器”中有一个垂直的视频。

I probably (and you as well) should use "raw" as your output format as you move through these steps, as we're making copies of copies here and the quality is getting worse and worse. You'll end up with gigabyte-size temp files, for a bit, but your output will be much better.

在执行这些步骤时,我可能(以及您也)应该使用“原始”作为输出格式,因为我们在此处制作副本,并且质量越来越差。 最终,您将得到千兆字节大小的临时文件,但是输出将更好。

Next I'll just scale the video back to 640x480 for posting on the web.

接下来,我将视频缩放到640x480,以便在网络上发布。

C:\Users\Scott\Desktop\mplayer>
mencoder -ovc lavc -lavcopts vcodec=mjpeg -vop scale=640:480 -oac copy BIGOUTPUT.AVI -o FINAL.AVI

C:\ Users \ Scott \ Desktop \ mplayer> mencoder -ovc lavc -lavcopts vcodec = mjpeg -vop scale = 640:480 -oac复制BIGOUTPUT.AVI -o FINAL.AVI

Again, pick the codec that is right for you in order to tune your output size and quality.

再次,选择适合您的编解码器以调整输出大小和质量。

UPDATE: Someone emailed saying that the AVI format made by mencoder doesn't always work on Windows Media. (I use VLC Player, works fine) and they suggested the final encoding pass be done by FFMPEG, rather than mencoder:

更新:有人通过电子邮件发送电子邮件,说说mencoder制作的AVI格式在Windows Media上并不总是有效。 (我使用VLC Player,效果很好),他们建议最终的编码过程应由FFMPEG完成,而不是由编码器完成:

C:\Users\Scott\Desktop\mplayer>
c:\utils\ffmpeg_mp2.exe" -i finaltest.avi -sameq -acodec pcm_u8 -vcodec mjpeg FFMPEGOUTPUT.AVI

C:\ Users \ Scott \ Desktop \ mplayer> c:\ utils \ ffmpeg_mp2.exe“ -i finaltest.avi -sameq -acodec pcm_u8 -vcodec mjpeg FFMPEGOUTPUT.AVI

Worked for me.

为我工作。

翻译自: https://www.hanselman.com/blog/how-to-rotate-an-avi-or-mpeg-file-taken-in-portrait

h264 mpeg avi

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值