功能概要:
  • 功能概述:简化ffmpeg调用流程,让ffmpeg命令开发与ffmpeg库开发结合
  • 操作系统:Windows、Linux、各种操作系统可定向编译
  • 适用场景:开发者(免费)


EasyAVFilter本质上就是将ffmpeg.exe改造成了动态库, 方便应用程序集成ffmpeg的各项功能;

函数名称

说明

EasyAVFilter_Create

创建句柄

EasyAVFilter_Release

释放句柄

EasyAVFilter_SetCallback

设置回调函数和自定义指针

EasyAVFilter_AddInput

添加输入参数()

EasyAVFilter_AddFilter

添加中间参数,:转码

EasyAVFilter_SetOutput

设置输出参数(目标)

EasyAVFilter_GetFilters

获取所有参数

EasyAVFilter_Start

开始工作

EasyAVFilter_Stop

停止工作

 

 

所有APIint类型返回值0则表示成功,否则为失败;

 

EasyAVFilter_Create

输入:   

输出:    句柄

返回值: 0:成功other:失败

说明:      创建句柄

 

EasyAVFilter_SetCallback

输入:     handle: 句柄

callback: 回调函数

userPtr: 用户自定义指针

输出:     

说明:      设置回调函数和用户自定义指针

 

 

EasyAVFilter_AddInput

输入handle: 句柄

     inputUrl:源地址

     connectType: 连接类型  1:tcp other:udp

输出

返回值: 0:成功  other: 失败

说明添加输入源

 

EasyAVFilter_AddFilter

输入handle: 句柄

filterCommand: 中间参数,如转码

     用法1: 在调用EasyAVFilter_AddInput添加了参数后,再调用EasyAVFilter_AddFilter添加的便为中间参数,本质上就是将EasyAVFilter_AddInputEasyAVFilter_AddFilterEasyAVFilter_SetOutput的参数组合成一条完整的命令

用法2:直接调用EasyAVFilter_AddFilter命令将ffmpeg完整命令输入,随后直接调用EasyAVFilter_Start;      

输出

返回值: 0:成功  other: 失败

说明添加中间处理参数

 

EasyAVFilter_SetOutput

输入handle: 句柄

    outputUrl: 输出地址,即目标地址.rtmp://xxx d:/12.mp4

    transCodeType: 0:自动 1:强制转码为H264

输出:

返回值: 0:成功  other: 失败

说明设置输出地址

 

 

EasyAVFilter_GetFilters

输入handle: 句柄

输出:  outFilterCommand: 完整命令

返回值: 0:成功  other: 失败

说明获取所有参数

 

EasyAVFilter_Start

输入handle: 句柄

    loop: 1: 循环执行  0:执行过程中如有异常或执行完成则终止

    connectTimeoutSecs: 连接超时时长()

    readTimeoutSecs:读取数据超时时长()

输出:

返回值: 0:成功  other: 失败

说明开始工作

 

EasyAVFilter_Stop

输入handle: 句柄

输出:

返回值: 0:成功  other: 失败

说明: 停止工作

 

EasyAVFilter_Release

输入handle: 句柄

输出:

返回值: 0:成功  other: 失败

说明: 释放句柄

 

Linux链接库



-lpthread -ldl -lva -lva-drm -lm


因产品中主要用到了拉转推,调用如下:

int main(intargc, char** argv)
{
    Easy_HandleavFilterHandle = NULL;
    EasyAVFilter_Create(&avFilterHandle);

#if 0
    // 用法1
    EasyAVFilter_AddInput(avFilterHandle[i], "rtsp://admin:12345@192.168.1.100", 1);
    EasyAVFilter_AddFilter(avFilterHandle[i], "-vcodec copy -acodec aac");
    EasyAVFilter_SetOutput(avFilterHandle[i], "rtmp://192.168.1.200:1935/live/ch1", 0);
#else
    // 用法2
    //const char* pCommand = "-rtsp_transporttcp -i rtsp://admin:12345@192.168.1.100 -vcodec copy -acodec copy -f flv rtmp://192.168.1.200:1935/live/ch1";
    char command[512] = { 0 };
    char* pCommand = (char*)command;
    for (inti = 1; i<argc; i++)
    {
        pCommand += sprintf(pCommand, " %s", argv[i]);
    }
    EasyAVFilter_AddFilter(avFilterHandle, command);
#endif

    charfilterCommand[256] = { 0 };
    EasyAVFilter_GetFilters(avFilterHandle, filterCommand);
    printf("command: %s\n", filterCommand);
    EasyAVFilter_Start(avFilterHandle, 1, 8, 10);

    getchar();
    EasyAVFilter_Stop(avFilterHandle);
    EasyAVFilter_Release(&avFilterHandle);

    return 0;




 

点赞(4)
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部