我正在尝试从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实例流到具有这些设置的另一个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我是不是做错了什么事?
发布于 2019-01-11 02:29:56
我假设您必须告诉FFmpegFrameGrabber正确的格式和代码。您的格式不是H.264,因为您正在发送MPEG-2传输流.尝试将格式(setFormat)设置为"mpegts“。视频编解码器用于H.264解码器,音频编解码器用于MPEG-2层3层解码器(MP3)。
假设错误消息是由H.264解码器试图读取MEPG-2传输流而产生的。
https://stackoverflow.com/questions/54136029
复制相似问题