服装网站建设目的,罗湖中小网站建设,点击app图标进入网站怎么做,国内外知名提供邮箱服务的网站看了雷神的 100行代码实现最简单的基于FFMPEGSDL的视频播放器#xff08;SDL1.x#xff09; 后手痒难耐#xff0c;决定将里面的代码重新建一个
首先建立一个空项目#xff0c;新建一个Mysimplest.cpp的文件。在里面写代码 #include stdio.hextern C
…看了雷神的 100行代码实现最简单的基于FFMPEGSDL的视频播放器SDL1.x 后手痒难耐决定将里面的代码重新建一个
首先建立一个空项目新建一个Mysimplest.cpp的文件。在里面写代码 #include stdio.hextern C
{
#include libavcodec/avcodec.h
#include libavformat/avformat.h
#include libswresample/swresample.h
#include SDL/SDL.h
} 这是头文件引用 。ffmpeg是用C语言写的所以要用extern C来包含 将原项目中的includelib文件复制到新项目中还有相关的dll如图 同时在属性-链接器-输入-附加依赖项中输入相关的lib文件avcodec.lib;avformat.lib;avutil.lib;avdevice.lib;avfilter.lib;postproc.lib;swresample.lib;swscale.lib;SDL.lib;SDLmain.lib;
因为文件是在工作路径下的lib文件夹中所以还要设置附加库目录 进行编译如果出现 如图错误error LNK1561:必须定义入口点
一般来说如果我们没有定义main函数的话也会报这个错加上main函数声明 #include stdio.hextern C
{
#include libavcodec/avcodec.h
#include libavformat/avformat.h
#include libswresample/swresample.h
#include SDL/SDL.h
}int main(int argc, char * argv[]){printf(hello world);return 0;
} 再次编译仍然报同样的错
因为我们还要再设置一个东西 如图设置为控制台或者窗口具体根据项目需要这里设置为控制台
编译通过。
现在继续加代码
在main函数中加进如下代码运行报错显示couldnt open input stream. AVFormatContext * pFormatCtx;int i, videoindex;AVCodecContext * pCodecCtx;AVCodec * pCodec;AVFrame * pFrame;AVPacket * packet;struct SwsContext * img_convert_ctx;int screen_w, screen_h;SDL_Surface * screen;SDL_VideoInfo * vi;SDL_Overlay *bmp;SDL_Rect rect;FILE * fp_yuv;int ret, got_picture;char filepath[] bigbuckbunny_480x272.h265;av_register_all();avformat_network_init();pFormatCtx avformat_alloc_context();if (avformat_open_input(pFormatCtx, filepath, NULL, NULL) ! 0){printf(Couldnt open input stream.\n);return -1;}
这是因为我们的新工程中没有这个文件将相关文件bigbuckbunny_480x272.h265复制到工作目录下就可以了。