- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我编译成功 libavcodec 与 斯皮克斯 启用。
我修改了 FFMPEG 文档中的示例,将示例音频编码为 Speex。
但结果文件无法使用 VLC Player(具有 Speex 解码器)播放。
有小费吗?
static void audio_encode_example(const char *filename)
{
AVCodec *codec;
AVCodecContext *c= NULL;
int frame_size, i, j, out_size, outbuf_size;
FILE *f;
short *samples;
float t, tincr;
uint8_t *outbuf;
printf("Audio encoding\n");
/* find the MP2 encoder */
codec = avcodec_find_encoder(CODEC_ID_SPEEX);
if (!codec) {
fprintf(stderr, "codec not found\n");
exit(1);
}
c= avcodec_alloc_context();
/* put sample parameters */
c->bit_rate = 64000;
c->sample_rate = 32000;
c->channels = 2;
c->sample_fmt=AV_SAMPLE_FMT_S16;
/* open it */
if (avcodec_open(c, codec) < 0) {
fprintf(stderr, "could not open codec\n");
exit(1);
}
/* the codec gives us the frame size, in samples */
frame_size = c->frame_size;
printf("frame size %d\n",frame_size);
samples =(short*) malloc(frame_size * 2 * c->channels);
outbuf_size = 10000;
outbuf =( uint8_t*) malloc(outbuf_size);
f = fopen(filename, "wb");
if (!f) {
fprintf(stderr, "could not open %s\n", filename);
exit(1);
}
/* encode a single tone sound */
t = 0;
tincr = 2 * M_PI * 440.0 / c->sample_rate;
for(i=0;i<200;i++) {
for(j=0;j<frame_size;j++) {
samples[2*j] = (int)(sin(t) * 10000);
samples[2*j+1] = samples[2*j];
t += tincr;
}
/* encode the samples */
out_size = avcodec_encode_audio(c, outbuf, outbuf_size, samples);
fwrite(outbuf, 1, out_size, f);
}
fclose(f);
free(outbuf);
free(samples);
avcodec_close(c);
av_free(c);
}
int main(int argc, char **argv)
{
avcodec_register_all();
audio_encode_example(argv[1]);
return 0;
}
最佳答案
Speex(我不知道)是否偶然需要一种容器格式来放置这些帧,并带有某种标题?您只是获取编码器的输出并转储到文件中,而无需经过任何格式化( libavformat
)。
尝试使用 ffmpeg
将相同的数据编码到 Speex命令行实用程序并查看生成的文件是否播放。
我正在查看 www.speex.org
上的一些信息似乎 speex
数据放入.ogg
文件。您正在使用的播放器可能无法识别原始 Speex 数据,但前提是它包含在 .ogg
中。 .
虽然不是 100% 确定的答案,但我希望这对您有所帮助!
关于使用 libavcodec (FFMpeg) 编码 Speex?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9716130/
我需要在H.264容器中快速搜索MP4编码的视频流。我使用libav解码帧,因此偶然发现avformat_seek_file()方法。 我的问题是,假设H.264流以关键帧开头,而当我寻求时间戳0(无
我正在尝试解码用 H264 编码的视频。我将 AVPacket 的数据及其大小发送到解码器代码。我正在尝试解码帧并将其显示在 GUI 上。问题是当我解码帧时,它返回的帧字节数与数据包的大小相同,这意味
我想使用 libavcodec对于一个项目,问题是我不明白我应该从哪里获得官方版本,这个库非常受欢迎,我不知道官方网站是什么。 例如有 2 个主要项目,如 libav和 ffmpeg正在使用它,但我找
这是我使用 ffmpeg 的 libav* 解码音频流的过程 [videofile]--> (read audio packets) --> [pkts queue] --> (decoder) --
我有一个用 .3gp h.264 编码的视频,我希望在 C 中获得它的帧率和持续时间。这是我在打开后使用的代码文件并找到合适的编解码器: AVRational rational = gVideoCod
我正在通过 v4l 从相机中抓取视频帧,我需要将它们转码为 mpeg4 格式,以便通过 RTP 连续流式传输它们。 一切实际上都“有效”,但在重新编码时有些东西我没有:输入流产生 15fps,而输出为
我正在学习使用 libavcodec 进行编程。但我卡住了。我使用的所有教程都是视频文件,我需要一个音频文件。我正在使用 Ubuntu。 我应该如何从音频流中读取 AVCodecContext? 顺便
我正在使用 9.7 版的 libavcodec 编写一个简单的演示,几乎与 official example 中的示例完全相同。 . 但是,我无法打开编码器。另外,av_opt_set(context
我按照 Dranger 的教程使用 libav 和 FFMPEG 显示视频。 http://dranger.com/ffmpeg/ avcodec_decode_video2 似乎是视频解码过程中最慢
我正在尝试使用 ffmpeg 库制作一个最简单的应用程序。 这是我的代码: 主.c: #include #include #include int main() { avformat_n
什么AvPixelFormat我应该使用 *.png(PNG-24 和 PNG-8)图像吗? 我正在尝试使用 sws_scale 从 png 转换为 PIX_FMT_YUV420P 编辑,代码: av
我正在尝试使用 FFMpeg 中的 libavcodec 库来解码然后重新编码 h264 视频。 我有解码部分工作(很好地渲染到一个 SDL 窗口)但是当我尝试重新编码帧时,我在重新编码的视频样本中得
我有一个与 ffmpeg 库链接的 C++ 计算机视觉应用程序,该库提供从视频流到分析例程的帧。这个想法可以提供一个中等通用的视频流标识符,并且视频源将被解压缩并逐帧传递给分析例程(运行用户的分析功能
我想改变 gop 动态以适应玩家。较小的 gop 有助于降低首屏成本; Big gop 有助于降低比特率以节省带宽。 我发现nvenc有一个可以解决上述问题的功能。 https://docs.nvid
我想制作一个从 h.264 到 h.265 的转码视频应用程序。 我对 有疑问libavcodec 图书馆。我的项目中有这个库,所有功能都在工作,但是当我尝试设置编解码器时:avcodec_find_
当尝试获取 AVFrame 的时间戳时,有一个名为 best_effort_timestamp 的字段它描述为: frame timestamp estimated using various heu
除了调用 av_register_all(),是否有选择使用单个解码器的示例? 我想我将不得不调用 avcodec_register()、av_register_codec_parser() 等...
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 7年前关闭。 Improve th
我下载了一个软件( info-beamer ),我想使用 GPU 加速来解码 H.264 视频。我知道我的平台能够使用 GPU 解码 H.264 视频。我使用以下命令对 gstreamer 进行了一些
我正在 try catch 相机输出并使用 libavcodec 制作视频。作为如何完成此操作的示例,我使用了 ffmpeg muxing example . 问题是 4 秒视频的大小约为 15mb,
我是一名优秀的程序员,十分优秀!