我们可以使用ffmpeg命令进行很多工作,也可以在代码中调用ffmpeg指令进行相关操作,例如推流,录屏等,线面介绍C++调用ffmpeg命令进行rtmp推流。命令如下:
ffmpeg.exe -re -i qqq.flv -c copy -f flv rtmp地址
推流前,先打开rtmp服务器。下面的代码是C++调用ffmpeg指令本地flv文件rtmp推流:
#include
#include
using namespace std;
int main()
{
wstring strFfmpegPath = L"D:\\DevLib\\FFmpeg\\ffmpeg.exe"; //ffmpeg.exe所在的位置的完整路径
wstring strCmdContent = L"/c " + strFfmpegPath + L" -re -i " + L"D:\\TestFiles\\qqq.flv -c copy -f flv rtmp://192.168.227.129/live";
SHELLEXECUTEINFO ShExecInfo = { 0 };
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = L"C:\\Windows\\System32\\cmd.exe";
ShExecInfo.lpParameters = strCmdContent.c_str();
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_HIDE;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
cout
关注
打赏