[英]How can I recieve an RTP stream with JavaCV?
我正在尝试从RTP服务器(当前用于测试的VLC)流式传输视频并用Java对其进行解码。 为此,我使用JavaCV解码传入的流。 这是我到目前为止的内容:
try {
grabber = new FFmpegFrameGrabber("rtp://localhost:5004/test");
grabber.setFormat("h264");
grabber.setFrameRate(30.0);
grabber.start();
Java2DFrameConverter converter = new Java2DFrameConverter();
while (true) {
Frame frame = grabber.grab();
imageToDraw = frame != null ? converter.convert(frame) : null;
// goes off to paint a widget on a window, see https://git.io/fhZSr for more context
repaint();
}
} catch (Exception e) {
// TODO: Discover what circumstances cause this
e.printStackTrace(System.out);
}
在VLC上,我的流设置如下设置:
localhost
,端口5004和流名称test
。) 我可以使用这些设置(使用“客户端” VLC从rtp://localhost:5004/test
接收)将一个VLC实例流式传输到另一个实例,它工作得很好。 (唯一的问题是由于测试机性能较弱,不适合对高分辨率视频进行转码。)
切换到Java,我所看到的就是到处都是灰色的灰色帧。 控制台也一直在尖叫。 一些代码片段(完整日志太长了,不足以构成合理的帖子,但是如果您确实需要,可以在这里找到):
[h264 @ 0x7f6c4c3502c0] cabac decode of qscale diff failed at 8 12
[h264 @ 0x7f6c4c3502c0] error while decoding MB 8 12, bytestream 670
[h264 @ 0x7f6c4c3502c0] concealing 421 DC, 421 AC, 421 MV errors in P frame
[h264 @ 0x7f6c4c3502c0] Reference 4 >= 2
[h264 @ 0x7f6c4c3502c0] error while decoding MB 25 8, bytestream 416
[h264 @ 0x7f6c4c3502c0] concealing 556 DC, 556 AC, 556 MV errors in B frame
[h264 @ 0x7f6c4c3502c0] Reference 5 >= 4
[h264 @ 0x7f6c4c3502c0] error while decoding MB 21 1, bytestream 6042
[h264 @ 0x7f6c4c3502c0] concealing 826 DC, 826 AC, 826 MV errors in P frame
[h264 @ 0x7f6c4c3502c0] Invalid NAL unit 8, skipping.
[above line repeats 5x]
[h264 @ 0x7f6c4c3502c0] top block unavailable for requested intra mode
[h264 @ 0x7f6c4c3502c0] error while decoding MB 3 0, bytestream 730
[h264 @ 0x7f6c4c3502c0] concealing 836 DC, 836 AC, 836 MV errors in P frame
我明显在做错什么吗?
我假设您必须告诉FFmpegFrameGrabber正确的格式和代码。 由于您正在发送MPEG-2传输流,因此您的格式不是H.264。 尝试将格式(setFormat)设置为“ mpegts”。 用于某些H.264解码器的视频编解码器和用于某些MPEG-2第三层解码器(MP3)的音频编解码器。
假定错误消息是由H.264解码器尝试读取MEPG-2传输流产生的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.