0
我尝试通过RTP将H264传输到VLC,而不使用RTSP,即从IP摄像头接收H.264数据流,并将其发送到另一台主机上的VLC。 VLC打开URL“rtp:// @:12345”。 注意openRTSP使用H264VideoFileSink类做同样的事情,但数据输出到文件中,我替换的代码部分:使用live555将H264传输到VLC
if (strcmp(subsession->mediumName(), "video") == 0) {
if (strcmp(subsession->codecName(), "H264") == 0) {
// For H.264 video stream, we use a special sink that adds 'start codes',
// and (at the start) the SPS and PPS NAL units:
//fileSink = H264VideoFileSink::createNew(*env, outFileName,
// subsession->fmtp_spropparametersets(),
// fileSinkBufferSize, oneFilePerFrame);
char const* outputAddressStr = "192.168.1.123"; // this could also be unicast
struct in_addr outputAddress;
outputAddress.s_addr = our_inet_addr(outputAddressStr);
const Port outputPort(12345);
unsigned char const outputTTL = 255;
Groupsock outputGroupsock(*env, outputAddress, outputPort, outputTTL);
rtpSink = H264VideoRTPSink::createNew(*env, &outputGroupsock, 96);
}
…
然后,
subsession->sink = rtpSink;
subsession->sink->startPlaying(*(subsession->readSource()),
subsessionAfterPlaying,
subsession);
结果是openRTSP正在运行,但VLC收到没有。我使用Wireshark来检查,没有数据包发送到目标IP和端口。
我也尝试testMP3Streamer,用上面的单播地址替换多播地址。 VLC可以播放它。 有人能给我一些建议吗?
它的工作!VLC说:“SDP格式描述是需要接收RTP流。请注意,rtp:// URI不能与动态RTP有效载荷格式(96)一起使用。“这意味着VLC实际上接收到RTP数据包。谢谢。 – myggao