gdcl.co.uk-mpeg4
gdcl.co.uk-mpeg4 copied to clipboard
Performance bottleneck in multiplexer, in H264 mode
It appears that NAL unit scanning has a bottleneck, which might significantly reduce performance and throughput processing H264 stream.
Presumably, the problem is around H264ByteStreamHandler::WriteData
and needs an improvement over there:
The encoder outputs H.264 as byte stream with start codes, and is processed in the Mux filter by H264ByteStreamHandler which replaces the start codes with length values, so that each NALU is length-prefixed (apparently H.264 in an MP4 file must be in length-prefixed format, not start-code format).
In H264ByteStreamHandler::WriteData(), the input H.264 sample buffer is parsed for NALUs, and each NALU ends up being written separately to the file in patm->Append() which calls MuxOutput::Replace().
So patm->Append() is being called multiple times for each input H.264 sample/buffer.