FFMPEG编译安装、简单使用

本文介绍了如何下载并编译FFmpeg源码,配置选项,API的简单使用,如视频流处理和帧转换,以及工具的参数说明和解封装操作,最后提到了相关学习资源。

源码下载

地址: https://github.com/FFmpeg/FFmpeg

git clone https://github.com/FFmpeg/FFmpeg.git

编译和安装

  • 因为使用在板端编译,因此没有使用交叉编译链的部分。
  • 将如下内容复制到build.sh, 执行sh build.sh
./configure \
        --prefix="$PWD/install" \
        --enable-shared \
        --target-os=linux \
        --arch=aarch64 \
        --enable-gpl \
        --extra-libs=-ldl \
        --extra-cflags="-fPIC" \
        --extra-ldflags=-Wl,-Bsymbolic \
        --extra-libs="-lpthread -lm"

  • 如果没有报错,执行make -j4;make install
    • 以上版本工具有ffmpegffprobe
    • 接口在install目录下的include和lib

API简单使用

源代码

xxxxxxxxxxxxxxxxxxxx.hpp

#ifndef FILE_2_FRAME_H__
#define FILE_2_FRAME_H__

#include <thread>
#include <string>
extern "C" {
	#include <libavformat/avformat.h>
}



class CFile2Frame {
public:
	
	static constexpr char *RED_START = (char*)"\033[1;31m";
	static constexpr char *GREEN_START = (char*)"\033[1;32m";
	static constexpr char *COLOR_END = (char*)"\033[0m";

	typedef void (*func_data)(char*, int, void*pUser);
	
public:
	CFile2Frame(const std::string &filePath);
	~CFile2Frame();

	int start();

	int videoFormatConversion();
	void file2FrameExecLoop(void);
	
	void loop();
	static unsigned frameNo_;
private:
	bool isExit_;
	std::thread *pff_;
	func_data frameCb_;

	std::string strfileNamePath_;
	//ffmpeg
	AVFormatContext *ic_{nullptr};
	AVDictionary *opts_{nullptr};
	AVPacket *pkt;

	bool initSucc  ;		/*初始化成功完成标志, 读帧准备前的初始化*/
	int VideoStreamIndex_;

		
	

};

#endif 
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值