用EasyAVFilter(ffmpeg.dll)实现RTSP流转RTMP推流的demo示例Linux版

ffmpeg.exe做拉流转推流不靠谱,不能产品化;avcodec、avfilter做拉流转推流门槛又太高;用EasyAVFilter将ffmpeg.c改成ffmpeg.dll,用起来刚刚好,直接上示例代码:

cpp 复制代码
#ifdef _WIN32
#include <winsock2.h>
#endif

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "EasyAVFilterAPI.h"


int Easy_APICALL __EasyAVFilterCallBack(void* userPtr, EASY_AV_FILTER_STATE_T status, int progress, int errCode, const char *errMsg)
{
    
    printf("__EasyAVFilterCallBack status: %d  errCode:%d  errMsg:%s\n", __EasyAVFilterCallBack, errCode,  errMsg);
    
    return 0;
}


int main(int argc, char** argv)
{
    printf("main...\n");
    
	Easy_Handle avFilterHandle = NULL;

	EasyAVFilter_Create(&avFilterHandle);
        EasyAVFilter_SetCallback(avFilterHandle, __EasyAVFilterCallBack, 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_transport tcp -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 (int i = 1; i < argc; i++)
	{
		pCommand += sprintf(pCommand, " %s", argv[i]);
	}

	EasyAVFilter_AddFilter(avFilterHandle, command);
#endif

	char filterCommand[256] = { 0 };
	EasyAVFilter_GetFilters(avFilterHandle, filterCommand);
	printf("command: %s\n", filterCommand);

	EasyAVFilter_Start(avFilterHandle, 1, 30, 20);

        printf("Press Enter key to exit...\n");
	getchar();

	EasyAVFilter_Stop(avFilterHandle);

	EasyAVFilter_Release(&avFilterHandle);
        
        
        
        return 0;
}

Demo下载地址:https://www.easydarwin.org/tools/153.html

相关推荐
赖small强8 小时前
【Linux 内存管理】Linux系统中CPU内存访问机制与性能优化(32位/64位系统)
linux·内存对齐·tlb·对齐访问·aligned access
逸之猿8 小时前
HackRF One 实现GPS欺骗
linux
退役小学生呀8 小时前
二十六、K8s集群备份恢复
linux·云原生·容器·kubernetes·k8s
dragoooon348 小时前
[Linux网络基础——Lesson14.「高性能网络模式:Reactor 反应堆模式」]
linux·运维·网络
赖small强8 小时前
【Linux 内存管理】深入解析 Linux Cache Line 的原理、价值及 MIPS CPU 处理机制
linux·缓存·内存对齐·cache line
CaracalTiger8 小时前
在openEuler操作系统中多样性算力支持与性能压力测试操作
linux·运维·git·开源·开放原子·压力测试·开源软件
风123456789~9 小时前
【Linux专栏】rsync实验-同步指定日期前的文件
linux·脚本·rsync
呆子罗9 小时前
[解决方案]企业级ASP.NET CORE项目部署方案 IIS NGINX Win/Linux
linux·nginx·asp.net
艾莉丝努力练剑9 小时前
【Linux基础开发工具 (六)】Linux中的第一个系统程序——进度条Linux:详解回车、换行与缓冲区
java·linux·运维·服务器·c++·centos
liliangcsdn9 小时前
conda环境jupyter-lab GLIBCXX_3.4.29问题探索
linux·conda