音频和视频转码
对音频和视频进行转码以在网络上显示的最佳方法是什么?
我需要以编程方式完成它。 我想做一些像 YouTube 或 Google Video 这样的事情,用户可以上传他们想要的任何格式,然后我将其编码为 flv、mp3 和/或 mp4。 我可以在我们的服务器上执行此操作,但我宁愿使用 EC2 实例甚至 Web 服务。 我们有一台 Windows 2008 服务器。
What is the best way to transcode audio and video to show on the web?
I need to do it programmatically. I'd like to do something like YouTube or Google Video where users can upload whatever format they want, and I encode it to flv, mp3, and/or mp4. I could do it on our server, but I would rather use an EC2 instance or even a web service. We have a Windows 2008 server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
请注意 ffmpeg 的某些部分受 GPL 保护。 我相信 libpostproc 模块是,如果我没记错的话,它用于转码。 确保该许可证与您正在做的事情兼容。
Do be aware that certain parts of ffmpeg are under GPL. I believe the libpostproc module is and if I recall correctly this is used in transcoding. Make sure this license is compatible with what you're doing.
我会看一下 Main Concept 的参考 SDK:
http://www.mainconcept.com/site/developer-products-6/pc-based-sdks-20974/reference-sdk-21221/information-21243.html
它是为转码而构建的,并且由于它是经过许可的 SDK,因此不存在任何有关 ffmpeg/libavcodec 的法律问题。
I would take a look at Main Concept's Reference SDK:
http://www.mainconcept.com/site/developer-products-6/pc-based-sdks-20974/reference-sdk-21221/information-21243.html
It is built for transcoding and, since it is a licensed SDK it doesn't have any of the legal issues surrounding ffmpeg/libavcodec.
Rhozet Carbon Coder 可以处理 多种格式 另外您可以使用插件来更改视频(例如添加水印)
Rhozet Carbon Coder can handle a wide range of formats plus you can use plugins to alter the video (eg add a watermark)
ffmpeg 可以做到这一点,它是一个使用 libavcodec 的命令行工具。 可以处理大多数视频格式的转换。 它的许可证是 LPGL(如果适合您的需求)。 您可以通过编程方式将其用作单独的进程,或者如果您感觉很硬核,您可以自己使用 libavcodec 库直接编码。
ffmpeg can do it, its a command-line tool that uses the libavcodec. Can handle conversion of most video formats. Its license is LPGL, if that suits your needs. You can utilize it as a separate process programmatically, or if you're feeling hardcore, you can use the libavcodec library yourself to encode directly.
当你想转码为 Flv(这可能是网络上最好的)时,我会使用这一行:
它工作得很好,当然在 Linux 下:-)。
When you want to transcode to Flv (which is probably the best for the web) then I use this line:
It works very well, under linux of course :-).
我强烈推荐ffmpeg。 在 Windows 上,我发现此站点可以托管良好的二进制文件。
I strongly recommend ffmpeg. On Windows, I have found this site to host good binaries.
取决于你想花多少钱。 如果这是一个全新的(并且大多没有资金)想法,那么就走 ffmpeg 路线,但是当您扩展规模并希望提高质量时,请考虑可以自动化的更专业的编码工具之一(Rhozet、Inlet、Digital Rapids 等) 3 个选项)。
kind of depends on how much you want to spend. if this is a brand new (and mostly unfunded) idea, then go the ffmpeg route, but as you scale and look to iprove the quality, consider one of the more professional encoding tools that can be automated (Rhozet, Inlet, Digital Rapids are 3 options).
如果您正在寻找 GPL 的东西:
对于音频处理,请尝试 sox。 非常强大! 它的作用很多! 它包含在大多数 Linux 发行版中。
还有著名的 LAME 用于 mp3 [音频] 编码。
对于视频,mencoder 令人印象深刻! 它是 mplayer 包的一部分。 它将处理大多数视频格式的转换。 远远超出我的梦想。 (有关文档,请参阅第 9 章 MEncoder 的基本用法 和 < a href="http://www.mplayerhq.hu/DOCS/HTML/en/encoding-guide.html" rel="nofollow noreferrer">第 10 章使用 MEncoder 进行编码。
)它可以创造什么。 但它确实支持 mpeg4、mpeg2、dvd-mpeg、flv 等。 (虽然我自己没有尝试过flv,但谷歌显示其他人正在使用它。)
我已经做过像 jpeg + sound -> 之类的事情。 mpeg4 movie:
或将任意格式的视频转码为与 DVD 兼容的 mpeg:
-edl/-edlout [编辑决策列表] 用于仅剪出我想要的视频部分。
对于 DVD-mpeg-video,${VBITRATE} 通常为 5000。 但如果你稍稍搞砸了,你可以将更多视频压缩到 DVD 上。 假设您可以容忍这些伪影。
scale=720:480,harddup -- 我的 dvd 播放器的比例错误的小问题,harddup 解决了我的“el Cheapo”播放器上的音视频不同步问题。
(为了在无法处理 4x3 视频的宽屏播放器上播放,我使用了诸如 "aspect=16/9"、"-vf scale=560:480,expand= 之类的暴行720:480,harddup"。但一般来说,您不想浪费位来编码黑条。)
这不是 mencoder 到目前为止! 运行可能会很耗时。 但我心里还有其他目标……
If you are looking for GPL'ed stuff:
For audio mucking about, try sox. Very powerful! It does a lot! It's included in most linux distributions.
There is also the famous LAME for mp3 [audio] encoding.
For video, mencoder is impressive! It's part of the mplayer package. It will handle conversions from most video formats. Far more than I ever dreamed existed. (For documentation, see Chapter 9. Basic usage of MEncoder and Chapter 10. Encoding with MEncoder.)
It's somewhat more limited about what it can create. But it does support mpeg4, mpeg2, dvd-mpeg, flv, and many others. (While I haven't tried flv myself, google shows other folks are using it.)
I have done things like jpeg + sound -> mpeg4 movie:
Or transcode arbitrarily formated video to dvd-compatible mpeg:
-edl/-edlout [Edit Decision Lists] are used to snip out just the video sections I want.
${VBITRATE} is normally 5000 for DVD-mpeg-video. But if you flub it a bit you can squeeze more video onto a dvd. Assuming you can tolerate the artifacts.
scale=720:480,harddup -- Little issue with the scale being wrong for my dvdplayer, and harddup to resolve a sound-video desync issue on my "el cheapo" player.
(To playback on a widescreen player that wouldn't handle 4x3 video, I've used atrocities like "aspect=16/9", "-vf scale=560:480,expand=720:480,harddup". But in general you don't want to waste bits encoding black-bars.)
This is not the most efficient set of options to mencoder by far! It can be time consuming to run. But I had other goals in mind...