Everything is working well, expect for a latency issue which I'm trying to solve.
If I'm logging every time a data is coming in from stdout, with the timestamp of arrival, I get this output:
16/06/2015 15:40:45.239 got data size = 24
16/06/2015 15:40:45.240 got data size = 7197
16/06/2015 15:40:45.241 got data size = 32768
16/06/2015 15:40:45.241 got data size = 4941
16/06/2015 15:40:45.241 got data size = 12606
16/06/2015 15:40:45.241 got data size = 6345
16/06/2015 15:40:45.241 got data size = 6339
16/06/2015 15:40:45.242 got data size = 6336
16/06/2015 15:40:45.242 got data size = 6361
16/06/2015 15:40:45.242 got data size = 6337
16/06/2015 15:40:45.242 got data size = 6331
16/06/2015 15:40:45.242 got data size = 6359
16/06/2015 15:40:45.243 got data size = 6346
16/06/2015 15:40:45.243 got data size = 6336
16/06/2015 15:40:45.243 got data size = 6338
16/06/2015 15:40:45.243 got data size = 6357
16/06/2015 15:40:45.243 got data size = 6357
16/06/2015 15:40:45.243 got data size = 6322
16/06/2015 15:40:45.243 got data size = 6359
16/06/2015 15:40:45.244 got data size = 6349
16/06/2015 15:40:45.244 got data size = 6353
16/06/2015 15:40:45.244 got data size = 6382
16/06/2015 15:40:45.244 got data size = 6403
16/06/2015 15:40:45.304 got data size = 6393
16/06/2015 15:40:45.371 got data size = 6372
16/06/2015 15:40:45.437 got data size = 6345
16/06/2015 15:40:45.504 got data size = 6352
16/06/2015 15:40:45.571 got data size = 6340
16/06/2015 15:40:45.637 got data size = 6331
16/06/2015 15:40:45.704 got data size = 6326
16/06/2015 15:40:45.771 got data size = 6360
16/06/2015 15:40:45.838 got data size = 6294
16/06/2015 15:40:45.904 got data size = 6328
16/06/2015 15:40:45.971 got data size = 6326
16/06/2015 15:40:46.038 got data size = 6326
16/06/2015 15:40:46.105 got data size = 6340
16/06/2015 15:40:46.171 got data size = 6341
16/06/2015 15:40:46.238 got data size = 6332
As you can see, the first 23 lines (which contain data of about 1.5 secs of video) are arriving almost instantly, and then the delay between each 2 consecutive lines is ~70ms which makes sense because the video is 15 frames per sec.
This behavior introduces a latency of about 1.5 sec.
It looks like a flushing issue because I don't see any reason why would ffmpeg need to hold the first 23 frames in memory, especially since each frame is a fragment of it's own inside the mp4.
I couldn't however, find any method that would cause ffmpeg to flush this data faster.