官方链接 https://ffmpeg.org/doxygen/trunk/encode_audio_8c-example.html
这个例子是演示音频编码的,代码生成了一段pcm16的音乐,时长6秒。播放听起来就像电视台还没开播时
的嘟声。
然后用mp2编码器编码。然后输出。还有英文解释。不算太难。无非申请frame对象去读输入数据。申请packet对象去写数据
/*
* Copyright (c) 2001 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OT

本文介绍了ffmpeg官方提供的encode_audio.c示例,该示例展示了如何将6秒的pcm16音频编码为mp2格式。通过创建frame对象处理输入数据,利用packet对象写入编码后的数据,实现音频编码过程。对于初学者来说,这是一个直观易懂的学习资源。
最低0.47元/天 解锁文章
575

被折叠的 条评论
为什么被折叠?



