您当前的位置: 首页 >  c++

令狐掌门

暂无认证

  • 0浏览

    0关注

    513博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

C++调用ffmpeg命令推流【详细代码】

令狐掌门 发布时间:2020-03-06 15:45:19 ,浏览量:0

      我们可以使用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             
关注
打赏
1652240117
查看更多评论
0.0502s