简体   繁体   English

x264 NALU序列化和处理

[英]x264 NALUs serialization and handling

I have my x264 encoder, producing NALUs from a raw video stream. 我有我的x264编码器,从原始视频流生成NALU。 I need to send those NALUs over the network. 我需要通过网络发送这些NALU。 What is the best way of doing so? 这样做的最佳方法是什么?

Encoder is inserted into a DirectShow graph, it's a transform filter and downstream I have the filter which handles networking. 编码器插入到DirectShow图中,它是一个变换过滤器,下游我有一个处理网络的过滤器。 Can I pass NALUs, created by transform filter directly to network "render" filter? 我可以将由变换过滤器创建的NALU直接传递给网络“渲染”过滤器吗? Will it create some memory issues? 它会产生一些内存问题吗?

I would like to know how memory allocated for NALUs is handled inside x264 - who is responsible for freeing it? 我想知道如何在x264中处理为NALU分配的内存 - 谁负责释放它? Also I'm wondering if I can just serialize NALU to a bit stream manually and then rebuild it in the same way? 另外我想知道我是否可以手动将NALU序列化为比特流,然后以相同的方式重建它?

The best way to send out NALU on to the network would be through an RTP stream. 将NALU发送到网络的最佳方式是通过RTP流。 Look at RFC 6184 for details on RTP packetization for H.264. 有关H.264的RTP分组化的详细信息,请参阅RFC 6184 I think you can safely pass NALU to your renderer provided your media buffers are large enough to hold you NALUs. 我认为您可以安全地将NALU传递给渲染器,前提是您的媒体缓冲区足够大以容纳NALU。

I need to send those NALUs over the network. 我需要通过网络发送这些NALU。 What is the best way of doing so? 这样做的最佳方法是什么?

"Best" needs clarification: easiest to do, best in terms of compatibility, compatible to specific counterpart implementation etc. “最佳”需要澄清:最容易做,最好的兼容性,兼容特定的对应实现等。

Can I pass NALUs, created by transform filter directly to network "render" filter? 我可以将由变换过滤器创建的NALU直接传递给网络“渲染”过滤器吗? Will it create some memory issues? 它会产生一些内存问题吗?

There is no stock network renderer, you should read up on how it needs to be done with specific renderer you are going to use. 没有股票网络渲染器,您应该了解如何使用您将要使用的特定渲染器。

I would like to know how memory allocated for NALUs is handled inside x264 - who is responsible for freeing it? 我想知道如何在x264中处理为NALU分配的内存 - 谁负责释放它?

x264 manages buffers it fills, x264_encoder_encode returns you references on those buffers and you don't need to free data, just be sure to copy it out timely since it will be invalidated with next call. x264管理它填充的缓冲区, x264_encoder_encode返回你对这些缓冲区的引用,你不需要释放数据,只要确保及时复制它,因为它将在下次调用时失效。 Don't forget x264_encoder_close afterwards - it will release all resources managed internally. 之后不要忘记x264_encoder_close - 它将释放内部管理的所有资源。

Also I'm wondering if I can just serialize NALU to a bit stream manually and then rebuild it in the same way? 另外我想知道我是否可以手动将NALU序列化为比特流,然后以相同的方式重建它?

Yes you can do it. 是的,你可以做到。 If your network pair of filters can reproduce the same stream doing network stuff on their inner connection, then it is going to work out fine. 如果你的网络过滤器对可以重现在内部连接上做网络内容的同一个流,那么它就可以正常工作了。 The best network protocol in terms of interoperability with H.264 is RTP. 在与H.264的互操作性方面,最好的网络协议是RTP。 It is however pretty complicated if compared to simply accept/send/receive/reproduce steps for a bitstream. 然而,与简单地接受/发送/接收/再现比特流的步骤相比,它是相当复杂的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM