FMP4 moof box sequence number ordering

*爱你&永不变心* 提交于 2020-03-25 18:04:10

问题


I wanted to do a basic fragmented mp4 broadcast program with avformat libs and HTML5 video and MSE.

This is a live stream and I use avformat to copy h264 data to mp4 fragments.

Here is my basic drawing of clients attaching to the stream:

So, with words:

  1. C1J: First Client joins:
    • avformat process starts
    • ftyp, moov, moof, mdat boxes will be served to Client1
    • ftyp and moov atoms are both saved for later reuse
  2. C2J: Second Client joins (later in time):
    • avformat process is ongoing (because it is still serving moof and mdat boxes for Client1)
    • previously saved ftyp and moov boxes will be served first to Client2
    • after ftyp and moov boxes were served, Client2 will join to the stream at the next moof box.

I have saved an mp4 file to disk from both clients.

Atoms' order within both files looks good: ftype, moov, moof, mdat, moof, mdat...

Both files can be played by media players (like VLC) and also in browsers directly (Opera).

Client1 can be played also via MSE in the browser (Opera), but Client2's stream is not displaying with MSE (Opera).

No errors on the JS console, and media-internals looks also good (at least equivalent with Client1's one).

Now I realized that every moof box contains an mfhd box (header) with a sequenceNumber field.

Of course in Client1's first moof box this sequenceNumber is 1. However in the later joined Client2's first moof box this sequenceNumber is always >= 1 (in my case it is 16).

What do I need to modify in the moof boxes in Client2 to have a valid fmp4 from the beginning?

I think Opera's HTML5 video does not like if sequenceNumber does not start from 1, but there shall be other requirements for being it valid.

来源:https://stackoverflow.com/questions/60580531/fmp4-moof-box-sequence-number-ordering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!