qq21497936

前言

  上一篇交叉编译了ffmpeg的海思版本,使用交叉编译的qt的ffmpeg播放器在海思上播放,本片是将ffmpeg的环境添加进海思的sample环境中。

 

在海思sample中引入ffmpeg库

步骤一:查看之前交叉编译的安装文件

  在这里插入图片描述

步骤二:打开编译的参数文件,添加头文件和库文件

   在这里插入图片描述

##### add by yangjiong 2022-03-12 start
INC_FLAGS += -I/home/yang/work/ffmpeg-hi3559av100/include
MPI_LIBS += /home/yang/work/ffmpeg-hi3559av100/lib/libavcodec.a
MPI_LIBS += /home/yang/work/ffmpeg-hi3559av100/lib/libavdevice.a
MPI_LIBS += /home/yang/work/ffmpeg-hi3559av100/lib/libavfilter.a
MPI_LIBS += /home/yang/work/ffmpeg-hi3559av100/lib/libavformat.a
MPI_LIBS += /home/yang/work/ffmpeg-hi3559av100/lib/libavutil.a
MPI_LIBS += /home/yang/work/ffmpeg-hi3559av100/lib/libswresample.a
MPI_LIBS += /home/yang/work/ffmpeg-hi3559av100/lib/libswscale.a
##### add by yangjiong 2022-03-12 stop

  如下图:
  在这里插入图片描述

步骤三:在venc另起sample添加ffmpeg测试

  (注意海思的sample子目录下,文件夹只能有一个main函数,也就是说会把子文件夹中所有的头文件和源文件当作一个应用联合编译。)
  将原来的.c的改一下后缀.bak,然后重新建立一个c文件。
  在这里插入图片描述
  在这里插入图片描述

步骤四:将目标应用在板子上跑

  (注意:需要先将库加入到运行环境中,最简单的方式就是直接copy之前的库,将lib放到海思系统的/lib文件目录下,也可以自定义路径,运行时使用脚本先加入路径然后跑应用,方法很多,条条大路通罗马)。
  在HI3559AV100运行结果如下:
  在这里插入图片描述

 

Demo源码

#ifdef __cplusplus
#if __cplusplus


extern "C" {
#endif
#endif /* End of #ifdef __cplusplus */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <netinet/in.h>
#include<arpa/inet.h>
#include <sys/types.h>

#include "sample_comm.h"

// ffmepg
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libavdevice/avdevice.h>
#include <libavformat/version.h>
#include <libavutil/time.h>
#include <libavutil/mathematics.h>

#define LOG printf("%s:%d\n", __FILE__, __LINE__);


int main(int argc, char *argv[])
{
	printf("%s\n", avcodec_configuration());
	return 0;
}

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
 

 

 

分类:

Hi35XX

技术点:

相关文章:

相关资源