我可以在linux中成功执行以下命令:
ffmpeg -i "rtmp://42.62.95.48/live?vhost=hls/livestream timeout=2" -vcodec copy -acodec copy -f flv -y rtmp://127.0.0.1:1935/live/hd
但它在以下代码中不起作用:
std::vector<std::string> params;
params.push_back("/objs/ffmpeg/bin/ffmpeg");
params.push_back("-i");
params.push_back("\"rtmp://ossrs.net/live/livestream timeout=3\"");
params.push_back("-vcodec");
params.push_back("copy");
params.push_back("-acodec");
params.push_back("copy");
params.push_back("-f");
params.push_back("flv");
params.push_back("-y");
params.push_back("rtmp://127.0.0.1:1935/live/hd");
char** charpv_params = new char*[params.size() + 1];
for (int i = 0; i < (int)params.size(); i++) {
std::string& p = params[i];
charpv_params[i] = (char*)p.data();
}
charpv_params[params.size()] = NULL;
execv("/objs/ffmpeg/bin/ffmpeg", charpv_params)
有谁知道为什么?