<div dir="ltr">There is a problem in erlyvideo with generating mpeg-ts.<div><br></div><div style>I have list of video frames, they are binaries of 4K - 100K bytes size with some additional metadata. I need to split all these binaries in chunks of about 184 bytes and create lots of such chunks.</div>
<div style><br></div><div style>When mpeg-ts transformation is written in C, large binary is allocated (size = sum(frame_size)*C) and all frames with additional data are written to this block chunk by chunk.</div><div style>
<br></div><div style>Only one memory allocation is done and only one copy is done.</div><div style><br></div><div style><br></div><div style>When I write it in erlang, lots (thousands) of small binaries are allocated and iolist_to_binary makes another copy with another allocation.</div>
<div style><br></div><div style>May it be a good idea to add nif function that returns large preallocated binary and then generate such data with <<Data/binary, Chunk/binary>> so that no reallocation is done?</div>
<div style><br></div></div>