[x264-devel] Bit stuffing/padding

Tim Pitman tapitman11 at gmail.com
Wed Aug 8 03:13:03 CEST 2012


I'm running this on Linux and the use case is low latency video over a
lossy wireless channel.

I'm using x264 to encode and piping the results to another application
I'm developing. My application must process the data at a very
specific bitrate before transmitting it. Using --nal-hrd,
--vbv-maxrate, and --bitrate I've been able to get the output rates of
x264 very close to the desired input rate, but there is still a slight
mismatch. The solution I'm currently working on is adding my own
padding in addition to that done by --nal-hrd. Basically if my
application goes to read from the pipe x264 is writing to and there
isn't enough data to fill that frame (105 bytes), I simply insert
0xFFs until I have a complete frame. I'm making the assumption that
x264 will always output on NALU boundaries. This seems to be the case,
but I'm still getting video artifacts on the other side. I was hoping
that any random data between NALUs would simply be ignored by the
decoder (using libavcodec).

Using a hex editor to look at a dump of the stream after my padding
shows that my 0xFFs are being inserted between NALUs as expected,
except instead of seeing "...FF FF FF FF 00 00 00 01", I'm seeing
"...FF FF FF FF 08 00 00 00 01". What is that 08? It almost seems like
my 0xFFs are being added to the end of the NALUs instead of between
them.

Any ideas?

Thanks,
Tim


More information about the x264-devel mailing list