在iPhone上转换视频 [英] Convert video on iPhone

查看:113
本文介绍了在iPhone上转换视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,允许用户从他们的库中选择一个视频或用相机拍摄视频,然后将其上传到服务器。当我将视频发送到服务器时,我需要将视频格式化为特定格式(m4v,h.264,AAC)。在iOS 5中,也许更早,视频记录为.mov文件(尽管有h.264和AAC)。

I have an app that allows the user to either select a video from their library or take video with the camera and them upload it to a server. I need the video to be in a particular format (m4v, h.264, AAC) when I send it to the server. In iOS 5 and perhaps earlier, the video records as a .mov file (albeit with h.264 and AAC).

如何将视频转换为m4v?不可否认,我对视频编码的细节和差异有点粗略,所以请原谅我,如果我在这里无知。

How can I convert the video to m4v? Admittedly I'm a little sketchy on the details and differences in video encoding, so forgive me if I'm being ignorant here.

推荐答案

<大卫,我可以建议你的服务器进行转码吗?在手机上进行转码既复杂又繁琐。但是,iPhone已经使用了h.264和AAC编码,所以你确定你甚至需要做任何事情吗? .mov vs .m4v对你来说可能并不重要,所有扩展指示的是容器支持的原子。我发现90%的时间视频非常基本,并使用容器格式的最小功能集。要进行比较,请查看维基页面: http://en.wikipedia.org/wiki/Comparison_of_container_formats

您可以随时使用Atom Box Viewer仔细检查文件的结构(有2天的试用版下载期,它可用于调查视频文件结构)< a href =http://www.jongbel.com/?page_id=114 =nofollow> http://www.jongbel.com/?page_id=114 。不幸的是,它不是很直观,因为它假设你对视频容器有所了解,但是,你可以很快地判断你的目标容器是否与你从iPhone上获得的容器相匹配。

You can always double check the structure of the files using Atom Box Viewer (there is a 2 day trial download period and it can be useful for investigating video file structure) http://www.jongbel.com/?page_id=114. Unfortunately, it's not very intuitive since it assumes you have an understanding of video containers, however, you can pretty quickly tell if your target container matches the container you get from the iPhone.

如果你确实需要强制执行容器/内容语义,那么我建议你不要编写自己的代码转换器来使用ffmpeg http:/ /ffmpeg.org/ 。 ffmpeg支持许多不同的音频和视频容器和格式。例如,您可以通过以下方式调用它来强制执行您的标准:

If you do need to enforce container/content semantics though, short of writing your own transcoder I suggest you look into using ffmpeg http://ffmpeg.org/. ffmpeg supports lots of different containers and formats for both audio and video. For example you can enforce your standards by calling it like this:

ffmpeg.exe -i inputFile.mp4 -vcodec libx264 -s 320x240 -acodec libfaac outputFile.m4v

我给你的例子很简单,打破它的这个:

The example I gave you is very simple, to break it down its this:

-i => input file
-vcodec libx264 => video codec set to use h.264 using the x264 encoder. to list more you can do: ffmpeg -formats
-s 320x240 => here I'm just explicitly specifying my size. If you don't set a size it will use whatever the input source size is
-acodec libfaac => use the faac AAC encoding library to transcode the audio

最后将输出文件作为最后一个参数

and finally the output file as the last parameter

如果需要,您也可以获得更具体的信息,指定您想要的编码传递次数(2次传递将为您提供更好的压缩和更少的工件),目标比特率是多少(也许您想将转码限制为一定数量的数据,以便有效地传输它?)。

You can get more specific too if you want, specifying how many passes of encoding you want (2 pass will be give you better compression with less artifacts), what your target bitrate is (maybe you want to limit your transcode to a certain amount of data so you can effectively stream it?).

我建议你去 http://forum.doom9 .org / 这是一个关于视频编码/转码的更多细节的绝佳论坛。另一个链接 http://www.catswhocode.com/blog/ 19-ffmpeg-commands-for-all-needs 有其他ffmpeg配置,你可能会发现它们很有用。

Let me suggest you go to http://forum.doom9.org/ which is an excellent forum for more details on video encoding/transcoding. This other link http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs has other ffmpeg configurations that you may find useful.

也是一个可用于玩设置的GUI是 http://handbrake.fr/ (手刹),这实际上是一个ffmpeg包装。

Also a usable GUI for you to play with settings is http://handbrake.fr/ (handbrake) which is effectively an ffmpeg wrapper.

Handbrake将ffmpeg与其安装捆绑在一起,所以我会从那里得到它。请注意ffmpeg / handbrake上的许可证,因为它们在法国分发,我不确定您是否可以将它与您的应用程序一起分发,但您可以在服务器端使用它。我总是模糊这些东西的合法性。

Handbrake bundles ffmpeg with its installation so I would get it from there. Be mindful of the licensing on ffmpeg/handbrake as they are distributed in france and I'm not sure you can distribute it with your application, but you may be able to use it server side. I'm always fuzzy on the legalities of this stuff.

我希望这至少能指出你正确的方向。

I hope this at least points you in the right direction.

这篇关于在iPhone上转换视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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