问题描述
我正在使屏幕共享基于Java的应用程序.我已经完成了使用JCodec Java库将帧编码为H264的工作.我在字节缓冲区中有图片数据.我将如何通过rtmp客户端将这些编码的帧发送到Wowza?Wowza可以识别由Jcodec库编码的H264编码的帧吗?
I am making screen share java based application. I am done with encoding frames into H264 using JCodec java Library. I have Picture data in Byte Buffer.How I will send these encoded frames to Wowza through rtmp client?Can Wowza recognize the H264 encoded frames, Encoded by Jcodec library?
推荐答案
几乎所有闪存"媒体服务器都可以理解流中的h264数据.您需要使用基线或主配置文件对帧进行编码,然后将编码后的字节打包"为flv流格式.第一步是创建AMF视频数据项,这意味着基于h264编码的字节数组的"NALU"内容添加前缀和后缀.用伪代码看起来像这样:
Pretty much any of the "flash" media servers will understand h264 data in a stream. You'll need to encode your frames with baseline or main profile and then "package" the encoded bytes into flv streaming format. The first step is creating an AMF video data item, what that means is prefixing and suffixing the h264 encoded byte array based on its "NALU" content; in pseudo code it looks something like this:
if idr
flv[0] = 0x17 // 0x10 key frame; 0x07 h264 codec id
flv[1] = 0x01 // 0 sequence header; 1 nalu; 2 end of seq
flv[2] = 0 // pres offset
flv[3] = 0 // pres offset
flv[4] = 0 // pres offset
flv[5] = 0 // size
flv[6] = 0 // size cont
flv[7] = 0 // size cont
flv[8] = 0 // size cont
else if coded slice
flv[0] = 0x27
flv[1] = 0x01
flv[2] = 0 // pres offset
flv[3] = 0 // pres offset
flv[4] = 0 // pres offset
flv[5] = 0 // size
flv[6] = 0 // size cont
flv[7] = 0 // size cont
flv[8] = 0 // size cont
else if PPS or SPS
.... skipping this here as its really complicated, this is the h264/AVC configuration data
copy(encoded, 0, flv, 9, encoded.length)
flv[flv.length - 1] = 0
下一步是将AMF视频数据打包到RTMP消息中.我建议您查看flazr或android rtmp库之一,以了解有关此步骤的详细信息.
The next step is packaging the AMF video data into an RTMP message. I suggest that you look at flazr or one of the android rtmp libraries for details on this step.
我有一个小的示例项目,它使用原始编码的h264并将其写入flv 此处如果您想看看它是如何完成的.
I've got a small example project that takes raw encoded h264 and writes it to an flv here if you want to see how its done.
这篇关于将Jcodec H264编码的RTMP消息发送到Wowza的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!