FFMPEG 学习(二) ffmpe+SDL2.0制作简单的播放器(基本流程梳理)

本文介绍了如何在Ubuntu 14.04.4上使用FFmpeg 4.2.2和SDL 2.0.12创建简单的视频播放器。内容包括软件环境配置、参考资源、源码整理、Makefile编写以及编译报错的解决方法,如头文件和库文件路径的调整。
摘要由CSDN通过智能技术生成

初入ffmpeg。跑个demo压压惊

 

一、软件环境环境:

Ubuntu 14.04.4 

ffmpeg 4.2.2

SDL 2.0.12

 

二、参考文章

1、https://blog.csdn.net/leixiaohua1020/article/details/38868499

2、https://blog.csdn.net/ashqal/article/details/17640179

3、https://www.cnblogs.com/lifan3a/articles/6944157.html

三、流程

ffmpeg流程

SDL流程

源码整理

#include <stdio.h>
#include <stdlib.h>

#ifdef __cplusplus
extern"C"
{
#endif
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_thread.h>
#ifdef __cplusplus
}
#endif

//#define SDL_VERSION_1  //version:1->SDL1.2  0->SDL2.0

//Refresh
#define SFM_REFRESH_EVENT  (SDL_USEREVENT + 1)
 
int thread_exit=0;
//Thread
int sfp_refresh_thread(void *opaque)
{
	SDL_Event event;
   	while (thread_exit==0) 
	{
   		event.type = SFM_REFRESH_EVENT;
   		SDL_PushEvent(&event);
		//Wait 40 ms
   		SDL_Delay(40);
   	}
   	return 0;
}

int main(int argc, char *argv[])
{
	AVFormatContext	*pFormatCtx;			//视频上下文
	AVCodecContext	*pCodecCtx;				//解码上下文
	int				i, videoindex;
	AVCodec			*pCodec;
	AVFrame	*pFrame,*pFrameYUV;
	AVPacket *packet;
	struct SwsContext *img_convert_ctx;
	//SDL
	int ret, got_picture;
	int screen_w=0,screen_h=0;
#if defined(SDL_VERSION_1)
	SDL_Surface *screen; 
	SDL_Overlay *bmp; 
#else
	SDL_Texture    *bmp = NULL;
    	SDL_Window     *screen = NULL;
	SDL_Renderer   *renderer = NULL;
#endif
	SDL_Rect rect;
	SDL_Thread *video_tid;
	SDL_Event event;
	int numBytes;
	uint8_t* buffer;

	if(1 == argc)
	{
		printf("%s:%d parameter error \n", __func__, __LINE__);
		return -1;
	}

	//------------
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值