Do we actually need to set streamheader? Are there any elements that need it, or can we just revert 320383c594c4eef821ea380b52021d32c8073056?
Yeah, we actually need that. byte-stream H264 need streamheader to be set or the streamheader should be sent to the element as the first data buffer. I think it's easier to set it as a streamheader field in caps because this is what PE side does: setting the h264 header in a standalone field.
As a side note, it would be rather nice to have more tests for the mp4 muxer, ideally tests that use realistic formats like H.264 and AAC, and tests that actually feed samples in and get data out. Testing that the data is correct is likely to be a lot harder, but currently we aren't doing any streaming at all.
I have a local test program[1] to produce a mp4 file with H264 video stream (audio stream is not tested though). After this patch, a playable mp4 file can be successfully consumed.