Hello,
Not sure if I'm doing something incorrectly, or if this is a feature that is not implemented in the MP4 Muxer. I can't get it to properly record H264 streams when each frame/picture is sliced into multiple NAL units.
For some context, I am working on a Directshow-based application that renders and records up to 24 video and audio feeds, coming from IP cameras, hardware encoders/streamers and/or desktop screen captures encoded using x264. I have the following constraints:
- All feeds have to be synchronized, with minimal latency
- Due to large number of feeds, I cannot transcode them (too much CPU), so I have to mux the signals as they arrive
When I use RTSP/H264, or x264 encoding with single NALU for each frame, the app and muxer works great. However, as I lower the fps on the x264 encoding (say 5 fps), this introduces a 4-5 seconds latency. To get an acceptable latency, I use the "superfast" preset, then I try the tune zerolatency (which includes the sliced-threads option). With sliced-threads, frames are broken down into multiple NALUs (1 per CPU core). The LAV Video Decoder correctly decodes the sliced frames, but the muxer only saves the first slice (bottom macroblock of the picture). The rest of the picture flashes gray/green (in NV12 pixel format), and when I try seeking this recorded video, it crashes my GPU.
I have looked into a few options:
- Concatenate the NALUs into a single NALU per frame, leaving start codes in between. This works with LAV decoder, but not the muxer.
- Concatenate the NALUs by removing the start codes and nal_unit_type byte. Doesn't work.
- Tried multiple options on x264 to mimic the zerolatency tune, but without slicing the frames, but I can't get below a few seconds of latency (at 5 fps)
I'd like to get some help, ideally by having the mp4muxer work with sliced frames, or if you can point me to code/sample on how to concatenate sliced frame NALUs, or if someone knows x264 options that can achieve the lowest latency without slicing frames. I am using very recent versions of ffmpeg and Live555 (from december 2018/january 2019).
Thank you