Tag: ffmpeg

使用clang在Mac上的FFMPEG项目中包含时出错

我在运行remuxing.c示例代码时遇到问题。 我收到以下错误。 我已确认可以在/usr/local/include找到这些文件。 我正在运行macOS Sierra 10.12.6。 $ cc -v playground/remuxing.c Apple LLVM version 9.0.0 (clang-900.0.39.2) Target: x86_64-apple-darwin16.7.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin “/Library/Developer/CommandLineTools/usr/bin/clang” -cc1 -triple x86_64-apple-macosx10.12.0 -Wdeprecat ed-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-v erifier -discard-value-names -main-file-name remuxing.c -mrelocation-model pic -pic-level 2 -mthread-mo del posix -mdisable-fp-elim -fno-strict-return -masm-verbose -munwind-tables -target-cpu penryn -target -linker-version 305 -v -dwarf-column-info […]

将alpha通道写入已解码的ffmpeg帧

我正在寻找一种快速的方法将我自己的alpha通道添加到解码的ffmpeg帧。 我有一个带有RGB信息的AVI文件,我有一个描述透明度alpha通道(灰度)的同步video流。 在使用ffmpeg解码AVI文件时,我想将输出帧转换为RGBA,同时添加我自己的alpha信息。 最后,我将获得一个半透明的video流。 是否有任何优化的函数,可能在libswscale或libswresample中,做这样的事情比迭代像素更好? 基本上我希望能够编写这样的函数,如果我只有sws_scale_and_add_alpha这样的函数: void* FFmpegLib_nextFrame_withAlpha(void* _handle, uint8_t* my_alpha_channel) { FFmpegLibHandle* handle = (FFmpegLibHandle*)_handle; AVPacket packet; int frameFinished; while(av_read_frame(handle->pFormatCtx, &packet) >= 0) { // Is this a packet from the video stream? if(packet.stream_index==handle->videoStream) { // Decode video frame avcodec_decode_video2(handle->pCodecCtx, handle->pFrame, &frameFinished, &packet); // Did we get a video frame? if(frameFinished) { sws_scale_and_add_alpha ( […]

在iPhone中使用FFMPEG音频转换

我在iPhone中使用ffmpeg,从mms服务器读取wma流,但我想使用ffmpeg中的ALAC编码器将流保存到m4a文件,问题是尝试保存原始流,处理流使用avcodec_decode_audio2,文件甚至无法用wma格式识别,显然,没有播放,所以在将流转换为m4a之前(使用avcodec_encode_audio)我想确保正在处理和保存正确的流。 有没有人经历过这种事情? 谢谢 PS我正在使用CFWriteStreamWrite编写字节缓冲区,一切似乎都没问题。 我的代码: while (av_read_frame(mms_IOCtx, &_packet) >= 0) { if (_packet.stream_index == audioStreamIdx) { uint8_t *_packetData = _packet.data; int _packetSize = _packet.size; // Align output buffer uint8_t audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16]; int16_t *aligned_buffer; size_t buffer_size; int audio_size, len; buffer_size = sizeof(audio_buf); aligned_buffer = align16(audio_buf, &buffer_size); while (currentState != STATE_CLOSED && […]

CGO:如何在Golang中使用指针从C中访问数组中的数据

我正在使用FFmpeg编写一个用于Windows平台的应用程序,它是golang包装器goav,但是我无法理解如何使用C指针来访问他们指向的数据数组。 我正在尝试将数据存储在AVFrame类中,并使用Go将其写入文件,最后使用OpenGl中的纹理来制作具有很酷转换的video播放器。 我认为理解如何投射和访问C数据将使编码变得更加容易。 我已经删除了C代码的所有相关部分,包装器和我的代码,如下所示: C代码 – libavutil / frame.h #include typedef struct AVFrame { #define AV_NUM_DATA_POINTERS 8 uint8_t *data[AV_NUM_DATA_POINTERS]; } Golang goav包装器 – 我真的不知道这里有什么不安全的.Pointers和cast但它让我可以访问底层的C代码 package avutil /* #cgo pkg-config: libavutil #include #include */ import “C” import ( “unsafe” ) type Frame C.struct_AVFrame func AvFrameAlloc() *Frame { return (*Frame)(unsafe.Pointer(C.av_frame_alloc())) } func Data(f *Frame) *uint8 { return […]

使用libavfilter过滤video时出现大量内存泄漏

我有一个相对简单的FFMPEG C程序,video帧被馈送,通过滤波器图处理并发送到帧渲染器。 以下是一些代码段: /* Filter graph here */ char args[512]; enum AVPixelFormat pix_fmts[] = {AV_PIX_FMT_RGB32 }; AVFilterGraph *filter_graph; avfilter_register_all(); AVFilter *buffersrc = avfilter_get_by_name(“buffer”); AVFilter *buffersink = avfilter_get_by_name(“ffbuffersink”); AVBufferSinkParams *buffersink_params; AVFilterInOut *outputs = avfilter_inout_alloc(); AVFilterInOut *inputs = avfilter_inout_alloc(); filter_graph = avfilter_graph_alloc(); snprintf(args, sizeof(args), “video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d”, av->codec_ctx->width, av->codec_ctx->height, av->codec_ctx->pix_fmt, av->codec_ctx->time_base.num, av->codec_ctx->time_base.den, av->codec_ctx->sample_aspect_ratio.num, av->codec_ctx->sample_aspect_ratio.den); if(avfilter_graph_create_filter(&av->buffersrc_ctx, buffersrc, “in”,args, NULL, filter_graph) […]

FFmpeg原生AAC解码器

我正在开发一个需要解码AAC的Windows上的商业C \ C ++应用程序。 我已经看过这个问题AAC Codec Library(libFAAC替代)从答案来看,似乎FFmpeg有一个原生的LGPL AAC解码器。 但是,当我查看FFmpeg主页时,我发现没有关于此解码器的信息或它支持的AAC对象类型(仅有关于编码器的信息)。 我一直在寻找这个2天,但我几乎找不到任何东西。 所以我的问题是: 本机FFmpeg AAC解码器支持甚至存在哪种类型的对象类型? 如果上面的解码器不存在那么有没有其他免费库? 我也看过FDK AAC,但我不了解它的许可证,我可以将它用于商业产品吗? 请帮忙我是音频编解码器的新手。

gcc:未定义的参考错误

我想使用ffmpeg / libavfilter / lavfutils.h中定义的函数’ff_load_image’。 program.c #include “../ffmpeg/libavfilter/lavfutils.h” int main () { uint8_t* data; int linesize, width, height, log_ctx; int i = ff_load_image(&data, &linesize, &width, &height, AV_PIX_FMT_RGB24, “blue.jpg”, &log_ctx); } 运行 gcc -I$HOME/ffmpeg/include program.c -L$HOME/ffmpeg/lib -lavfilter -lavcodec -lavutil 给出未定义的引用错误。 program.c: In function \u2018main\u2019: program.c:9: warning: passing argument 1 of \u2018ff_load_image\u2019 from incompatible pointer type ../ffmpeg/libavfilter/lavfutils.h:39: […]

将VP9编码的数据复用到.webm时,FPS不正确

我正在尝试使用FFmpeg将一些video数据复用到WebM文件中。 我通过AVDictionary指定了一个AVDictionary (详见下文),但似乎time_base忽略了我指定的time_base值。 相反,它总是使用1/1000的time_base ,因此FPS为1000 。 我的初始化代码如下: HRESULT WINAPI InitializeVideoEncoding(Encoder* encoder, LPCSTR codec, LPCSTR outputContainer, LPCSTR* options, UINT optCount) { // Fill the options Log(“Loading options.”); for (UINT i = 0; i options, key, value, 0) options && optCount > 0) { Log(“Failed to initialize encoder options.”); return E_FAIL; } // Grab the buffer size […]

使用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 […]

链接libavcodec和libavformat:未定义的引用

我正在尝试编译我正在使用ffmpeg库的项目。 该项目用C语言编写。头文件适当地包含在源代码中。 特别是,它似乎使用libavcodec和libavformat ,并且这些库在Makefile中与LDFLAGS正确链接。 以下是使用的标志: -lavcodec -lavformat -lswscale -lavutil 现在,因为Ubuntu附带的打包库太过时了,我下载了ffmpeg的最新源代码,编译并安装它。 我删除了通过包管理器安装的所有打包库。 现在,尽管添加了上面的标志,我得到了很多未定义的引用,我似乎无法解决它。 以下是关于未定义引用的输出: //usr/local/lib/libavcodec.a(cscd.o): In function `decode_frame’: /home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/cscd.c:91: undefined reference to `uncompress’ //usr/local/lib/libavcodec.a(dxa.o): In function `decode_frame’: /home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/dxa.c:250: undefined reference to `uncompress’ //usr/local/lib/libavcodec.a(exr.o): In function `pxr24_uncompress’: /home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/exr.c:784: undefined reference to `uncompress’ //usr/local/lib/libavcodec.a(exr.o): In function `zip_uncompress’: /home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/exr.c:259: undefined reference to `uncompress’ //usr/local/lib/libavcodec.a(flashsv.o): In function `flashsv_decode_block’: /home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:191: undefined […]