Regular MP4 files cannot be played while being transcoded, since the MOOV atom (which is required to parse the file) is written at the end, once the encoding is finished. In many cases it then gets moved to the beginning of the file – that's what -movflags +faststart does – but you still have to wait for the file to be written once.
Fragmented MP4 (fMP4) files are a special kind of MP4 files that can be read while being written to, see this answer. Use -movflags +frag_keyframe+separate_moof+omit_tfhd_offset+empty_moov to enable the fragmentation.
MPEG-2 Transport Stream files can be played while being written to, as long as sufficient amount of data has been written. You could try writing the data to a .ts file, then waiting a few seconds, and then starting playback.
If you want to write the data in realtime, you have to add the global option -re, which makes ffmpeg read the input in realtime and consequently not write faster than what you can play.
1
Fragmented MP4s can be played while being written. See https://video.stackexchange.com/q/18177
– Gyan – 2019-12-05T04:55:08.4001@Gyan True, added a reference, thanks. – slhck – 2019-12-05T07:46:48.903