Tag: ffmpeg

ffmpeg缺少libavutil中的config.h(无此类文件或目录)CodeBlocks

当我在CodeBlocks中测试ffmepg编码/解码exapmle c程序时,它显示: /ffmpeg_sources/ffmpeg/libavutil/internal.h fatal error: config.h: No such file or directory ffmpeg_source / libavutil文件夹中的许多其他头文件中发生错误。 我搜索了该文件夹,但没有找到config.h文件。 其他文件夹中有config.h,但不适用于libavutil文件夹中的头文件。 我尝试下载最新的ffmepg zip文件,但也找不到config.h文件。 我应该在哪里找到该文件?

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

你如何调整AVFrame的大小?

你如何调整AVFrame大小? 一世 这是我目前正在做的事情: AVFrame* frame = /*…*/; int width = 600, height = 400; AVFrame* resizedFrame = av_frame_alloc(); auto format = AVPixelFormat(frame->format); auto buffer = av_malloc(avpicture_get_size(format, width, height) * sizeof(uint8_t)); avpicture_fill((AVPicture *)resizedFrame, (uint8_t*)buffer, format, width, height); struct SwsContext* swsContext = sws_getContext(frame->width, frame->height, format, width, height, format, SWS_BILINEAR, nullptr, nullptr, nullptr); sws_scale(swsContext, frame->data, frame->linesize, 0, frame->height, […]

使用ffmpeg从网络摄像头捕获帧,从微观捕获音频并保存到文件

在过去的几周里,我一直在努力使用ffmpeg API,因为我找不到清晰的文档,而且我也发现很难搜索,因为我在网上找到的所有解决方案都不涉及c API而是ffmpeg.c命令行程序。 我正在创建一个程序,需要从网络摄像头和音频中捕获video,在屏幕上显示帧并将音频和帧记录到video文件中。 我也使用QT作为这个项目的框架。 我已经能够在屏幕上显示帧,甚至记录它们,但我的问题是音频和video的记录。 我决定创建一个更简单的测试程序,它只将流保存到文件而不在屏幕上显示框架,从ffmpeg文档中的remuxing.c示例开始。 我的代码如下: //This is the variables on the .h AVOutputFormat *ofmt; AVFormatContext *ifmt_ctx, *ofmt_ctx; QString cDeviceName; QString aDeviceName; int audioStream, videoStream; bool done; //The .cpp #include “cameratest.h” #include #include CameraTest::CameraTest(QString cDeviceName, QString aDeviceName, QObject *parent) : QObject(parent) { done = false; this->cDeviceName = cDeviceName; this->aDeviceName = aDeviceName; av_register_all(); avdevice_register_all(); […]

在MAC上编译SDL

#include “ffmpeg/libavcodec/avcodec.h” #include “ffmpeg/libavformat/avformat.h” #include “ffmpeg/libswscale/swscale.h” #include “ffmpeg/libswscale/rgb2rgb.h” #include “ffmpeg/libswscale/swscale_internal.h” #include #ifdef __MINGW32__ #undef main /* Prevents SDL from overriding main() */ #endif #include “SDL.framework/Headers/SDL.h” #include “SDL.framework/Headers/SDL_thread.h” 是用这个命令编译的: gcc -o t1 tutorial01.c -lswscale -lavutil -lavformat -lavcodec -lz -lavutil -lm -framework SDL 但我得到这个错误: Undefined symbols: “_main”, referenced from: start in crt1.10.6.o (maybe you meant: _SDL_main) ld: […]

如何使用FFmpeg C API剪切video

如何使用FFmpeg C API剪切video? 例如从00:10:00到00:20:00。 我需要使用哪些function? 我使用此function转换video: int convert(char *file) { AVFrame *frame; AVPacket inPacket, outPacket; if(avio_open(&outFormatContext->pb, file, AVIO_FLAG_WRITE) = 0) { if(inPacket.stream_index == inVideoStreamIndex) { avcodec_decode_video2(inCodecContext, frame, &frameFinished, &inPacket); if(frameFinished) { av_init_packet(&outPacket); avcodec_encode_video2(outCodecContext, &outPacket, frame, &outputed); if(outputed) { if (av_write_frame(outFormatContext, &outPacket) != 0) { fprintf(stderr, “convert(): error while writing video frame\n”); return 0; } } […]

如何关闭libavformat错误消息

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

想要ffmpeg编码样本吗?

我发现这个教程关于ffmpeg我没有得到的是如何编码video。 可以任何一个,请提供一个教程..有解释吗? (不是我没有得到这个官方的,但我很想看到更多评论)

如何将标头元数据设置为编码video?

我正在将一些图像编码到mp4容器内的h264video中。 我基本上使用的是ffmpeg示例muxing.c。 问题是我正在尝试在mp4容器中设置一些元数据,如艺术家,标题等…… 我认为使用以下方法可行,但它没有: AVDictionary *opts = NULL; av_dict_set(&opts, “title”, “Super Lucky Dude”, 0); av_dict_set(&opts, “author”, “Jacky Chan”, 0); av_dict_set(&opts, “album”, “Chinese Movie”, 0); av_dict_set(&opts, “year”, “05/10/2013”, 0); av_dict_set(&opts, “comment”, “This video was created using example app.”, 0); av_dict_set(&opts, “genre”, “Action”, 0); // Write the stream header, if any. ret = avformat_write_header(oc, &opts); 创建整个video后,我没有看到任何元数据写入video文件。 任何指针如何正确地做到这一点?

FFmpeg:Jpeg文件到AVFrame

我需要使用FFmpeg库将几个jpg文件加入到video中。 但是我在阅读这些文件时遇到了问题。 这是一个读取图像文件并生成AVFrame的函数: AVFrame* OpenImage(const char* imageFileName) { AVFormatContext *pFormatCtx; if(av_open_input_file(&pFormatCtx, imageFileName, NULL, 0, NULL)!=0) { printf(“Can’t open image file ‘%s’\n”, imageFileName); return NULL; } dump_format(pFormatCtx, 0, imageFileName, false); AVCodecContext *pCodecCtx; pCodecCtx = pFormatCtx->streams[0]->codec; pCodecCtx->width = W_VIDEO; pCodecCtx->height = H_VIDEO; pCodecCtx->pix_fmt = PIX_FMT_YUV420P; // Find the decoder for the video stream AVCodec *pCodec = avcodec_find_decoder(pCodecCtx->codec_id); […]