Tag: libavcodec

使用libavcodec,C解码H264video

我正在尝试使用ffmpeg / libavcodec解码原始h264文件,但无法使其正常工作。 输出应该是现在的原始YUV文件。 可以使用GCC编译代码 gcc -o decoder decoder.c -L./lib/ -llibavcodec -llibavutil avcodec.dll,avutil.dll和swresample.dll必须放在.exe开始的目录中。 CMD中的输出看起来像这样(只是它的一部分,但它总是这样): [h264 @ 00a80f20] reference picture missing during reorder [h264 @ 00a80f20] Missing reference picture, default is 65562 [h264 @ 00a80f20] error while decoding MB 80 54, bytestream -10 [h264 @ 00a80f20] concealing 1649 DC, 1649 AC, 1649 MV errors in B […]

FFMPEG无法显示video的持续时间

我正在尝试使用ffmpeg从video文件中捕获帧,但我甚至无法获得video的持续时间。 每次当我尝试使用pFormatCtx->duration来访问它时我得到0.我知道指针初始化并包含正确的持续时间,因为如果我使用av_dump_format(pFormatCtx, 0, videoName, 0); 那么我实际上得到了持续时间数据以及有关video的其他信息。 这是我使用av_dump_format(pFormatCtx, 0, videoName, 0); : 输入#0,avi,来自’futurama.avi’: 持续时间:00:21:36.28,开始:0.000000,比特率:1135 kb / s 流#0.0:video:mpeg4(高级简单配置文件),yuv420p,512×384 [PAR 1:1 DAR 4:3],25 tbr,25 tbn,25 tbc 流#0.1:音频:ac3,48000Hz,立体声,s16,192kb / s 我不明白为什么av_dum_format可以显示持续时间而我不能。 我检查了函数定义,显示持续时间,该函数也使用pFormatCtx-> duration。 当我在main.cpp中调用它们时,其他成员变量也不会显示正确的数据 这是我的main.cpp: extern “C” { #include #include #include } int main(int argc, char *argv[]) { AVFormatContext *pFormatCtx = NULL; const char videoName[] = “futurama.avi”; // […]

由ffmpeg和SDL制作的奇怪声音

我正在关注原始dranger.com/ffmpeg教程的更新版本, url为https://github.com/mpenkov/ffmpeg-tutorial 第三步(源代码: https : //github.com/mpenkov/ffmpeg-tutorial/blob/master/tutorial03.c )增加声音,但产生的声音很奇怪。 当音频流是AAC时,我只听到静电。 当音频流是MP3时,我听到声音非常高的音调。 怎么了?

FFMpeg复制流没有转码

我试图将所有来自多个文件的流复制到一个文件而不转码流。 你通常使用ffmpeg实用程序做的事情ffmpeg -i “file_with_audio.mp4” -i “file_with_video.mp4” -c copy -shortest file_with_audio_and_video.mp4 这是代码: int ffmpegOpenInputFile(const char* filename, AVFormatContext **ic) { int ret; unsigned int i; *ic = avformat_alloc_context(); if (!(*ic)) return -1; // Couldn’t allocate input context if((ret = avformat_open_input(ic, filename, NULL, NULL)) < 0) return ret; // Couldn't open file // Get format info (retrieve stream […]

如何关闭libavformat错误消息

默认情况下,libavformat将错误消息写入stderr ,如: Estimating duration from bitrate, this may be inaccurate 我怎么能把它关掉? 或者更好的是,把它管道到我自己的整洁记录function? 编辑:将stderr重定向到其他地方是不可接受的,因为我需要它用于其他日志记录目的,我只是希望libavformat不写入它。

如何用libavcodec / x264编码h.264?

我试图使用libavcodec / libavformat编码video。 音频效果很好,但当我尝试编码video时,我收到以下错误: [libx264 @ 0x10182a000]broken ffmpeg default settings detected [libx264 @ 0x10182a000]use an encoding preset (vpre) 使用命令行ffmpeg很容易修复,但我试图在C中执行此操作。我的选项是 AVStream *pVideoOutStream = av_new_stream(pOutFormatCtx, 0); AVCodecContext *pVideoOutCodecCtx = pVideoOutStream->codec; pVideoOutCodecCtx->codec_id = CODEC_ID_H264; pVideoOutCodecCtx->codec_type = CODEC_TYPE_VIDEO; pVideoOutCodecCtx->bit_rate = pVideoInCodecCtx->bit_rate; pVideoOutCodecCtx->width = pVideoInCodecCtx->width; pVideoOutCodecCtx->height = pVideoInCodecCtx->height; pVideoOutCodecCtx->pix_fmt = pVideoInCodecCtx->pix_fmt; pVideoOutCodecCtx->sample_rate = pVideoInCodecCtx->sample_rate; pVideoOutCodecCtx->gop_size = 30; 但是avcodec_open()失败了。 我需要设置哪些其他值才能使x264满意?

使用libavcodec将音频编码到aac

我正在使用libavcodec(截至3/3/10的最新git)将原始pcm编码为aac(启用了libfaac支持)。 我这样做是通过每次使用codec_context-> frame_size样本重复调用avcodec_encode_audio来实现的。 前四个调用成功返回,但第五个调用永远不会返回。 当我使用gdb中断时,堆栈已损坏。 如果我使用audacity将pcm数据导出到.wav文件,那么我可以使用命令行ffmpeg转换为aac而没有任何问题,所以我确定这是我做错了。 我写了一个小的测试程序来复制我的问题。 它从文件中读取测试数据,可在此处获取: http : //birdie.protoven.com/audio.pcm (签名16位LE pcm约2秒) 如果我直接使用FAAC,我可以完成所有工作,但如果我可以使用libavcodec,那么代码会更清晰,因为我也编码video,并将两者都写入mp4。 ffmpeg版本信息: FFmpeg version git-c280040, Copyright (c) 2000-2010 the FFmpeg developers built on Mar 3 2010 15:40:46 with gcc 4.4.1 configuration: –enable-libfaac –enable-gpl –enable-nonfree –enable-version3 –enable-postproc –enable-pthreads –enable-debug=3 –enable-shared libavutil 50.10. 0 / 50.10. 0 libavcodec 52.55. 0 / 52.55. 0 libavformat […]

使用libavformat读取位于内存中的文件

我目前正在尝试阅读从服务器发送的小型video文件 为了使用libavformat读取文件,您应该调用 av_open_input_file(&avFormatContext, “C:\\path\\to\\video.avi”, 0, 0, 0); 问题是在这种情况下,文件不在磁盘上,而是在内存中。 我现在正在做的是下载文件,使用临时名称将其写入磁盘,然后使用临时文件名调用av_open_input_file ,这不是一个非常干净的解决方案。 事实上,我想要的是像av_open_custom(&avFormatContext, &myReadFunction, &mySeekFunction);这样的函数av_open_custom(&avFormatContext, &myReadFunction, &mySeekFunction); 但我没有在文档中找到任何内容。 我想这在技术上是可行的,因为文件的名称不能帮助库确定它使用的格式。 那么有这样的函数,还是av_open_input_file的替代品?