As suggested by the topic, I'm wondering if it's possible to send metadata about the stream contents periodically in a fragmented MP4 live stream.
I'm using the following command (1) to get fragmented MP4:
ffmpeg -i rtsp://admin:[email protected] -c:v copy -an -movflags empty_moov+omit_tfhd_offset+frag_keyframe+default_base_moof -f mp4 ...
My main program reads the fragments from this command from either stdout or from a (unix domain) socket and gets:
ftyp
moov
moof
mdat
moof
mdat
moof
mdat
...
So, the first fragments I get are ftyp and moov which are metadata and describe the stream contents.
Now a client program connects at a later time to the main program. The problem is, that at that point, the ftype and moov fragments are long gone.
Is there a way (=ffmpeg command option) to make this work similar to MPEGTS (aka mpeg transport stream), and resend metadata periodically with the stream? Like this:
ftyp
moov
moof
mdat
moof
mdat
moof
mdat
ftyp
moov
moof
mdat
moof
mdat
moof
mdat
...
.. or is my only option to cache the ftyp and moov packets in my main program and re-send them to the client program when it requests the stream?
A related link: What exactly is Fragmented mp4(fMP4)? How is it different from normal mp4?
Caching and resending ftyp and moov each time a new client connects is not that straightforward either .. as it somehow brokes the stream (at least the browser MSE extensions don't like such a stream). There seems to be lots of sequence numbers and stuff in the moof packets that should be modified. (+)
Another option is to pass the stream through another FFmpeg process that does the remuxing (and corrects moof packets). Things are further complicated by the fact that command (1) does not give cleanly-separated ftyp, moov, moof, etc. packets.
Any thoughts / solutions appreciated.
EDIT : regarding (+), MSE seems to have problems playing fragmented MP4 with gaps: https://bugs.chromium.org/p/chromium/issues/detail?id=516114