crtmpserver默认配置中没有启用rtsp服务器,需要修改以支持。buiders/cmake/crtmpserver/crtmpserver.lua中
{ ip = "0,0,0,0", port = 554, protocol = "inboundRstp" },
使用普通用户启动时,会报错权限问题,问题原因有待进一步考证
切换到root,启动成功。
使用ffmpeg将文件虚拟成rtsp流
$ ./ffmpeg -re -i film_1000.mp4 -vcodec copy -codec copy -f rtsp rtsp://192.168.5.202/live/rtsp_test
此时rtsp流名称并不是rtsp_test,查看sources/thelib/src/protocols/rtp/basertspappprotocol.cpp,获取streamName的代码如下:
打印出来,可以看到,流名称叫做No Name。
需要修改代码,795行前面加一段:
1.
string full_url = STR(requestHeaders[RTSP_FIRST_LINE][RTSP_URL]);
2.
vector<string> lines;
3.
split(full_url,
"/"
, lines);
4.
size_t rows = lines.size();
5.
streamName = lines[rows-
1
];
重新编译运行,使用vlc可以观看rtsp流了