转换媒体文件
如何使用 libavcodec 将媒体文件从 mp4(aac 和 libx264)转换为 mp4(mp3 和 h264)?谁能解释一下我必须执行哪些步骤? 据我所知,我必须解码然后将音频和视频流编码到目标编解码器。但是如何将这些流保存到 mp4 文件中呢?
How can I convert a media file from mp4 (aac and libx264) to mp4 (mp3 and h264) using libavcodec? Can anyone explain what steps I have to do?
As I know, I must decode and then encode audio and video stream to target codec. But how can I save these stream into a mp4 file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 libavcodec 编写 h264 和 mp3,但要将它们写入 mp4 文件,您需要 libavformat。这不是一个简单的过程,而且 FFmpeg / Libav 库是出了名的不直观。有几个 示例在他们的源代码树中很好地说明了这个过程。在decoding_encoding.c中查找video_encode_example()和audio_encode_example()。还有 muxing.c。
对于初学者,我建议您研究 ffmpegsource,它是 FFmpeg / Libav 库的包装器。
我在 此处编写了大部分代码 一个与 Tuttle 框架配合使用的插件。这也应该作为一个例子。但不要将其用作确定的。阅读 libavcodec 和 libavformat 附带的文档。
You can write h264 and mp3 using libavcodec, but to write them in an mp4 file you're gonna need libavformat. It's not a simple process, and FFmpeg / Libav libraries are notoriously unintuitive. There are a couple of examples in their source tree which illustrates the process pretty well. Look for video_encode_example() and audio_encode_example() in decoding_encoding.c. There is also muxing.c.
For beginners, I recommend that you look into ffmpegsource which is a wrapper around FFmpeg / Libav libraries.
I wrote most of the code here for a plugin which works with a framework called Tuttle. This should also serve as an example. But don't use it as definitive. Read the documentation that comes with libavcodec and libavformat.