8

I'm trying to play a MP4-Stream. The stream is send from my android phone. The problem is, that the moov atom, which is needed to play the mp4, is only written if the phone is done with the recording progress. So at the moment I'm only to play the streamed data, after the recording has finished. My idea was to write the ftyp and moov atom by myself, so that the streamed data can be played, while the phone is recording. I tried to use the moov atom from another videofile but this didn't work. I also have read, that normally it's impossible to build a moov atom, if only the mdat atom is given. But in my case I know the recording conditions, like framerate, etc..

So my question is, is it possible to generate a valid/useable moov atom for the incoming stream if I know the recording parameters?

Elnur Abdurrakhimov
  • 44,533
  • 10
  • 148
  • 133
Raffi
  • 81
  • 1
  • 3

2 Answers2

5

It's possible. I've done it 4 years ago to implement "live streaming" to original iPhone. Just fill STSZ and STCO atoms with constant size frames, then pad each frame with zeros. Yeah, size will be huge, but you'll get real live streaming :-)

Dmitri Sosnik
  • 517
  • 1
  • 12
  • 20
2

It seems to be rather impossible to stream not yet finished mp4 file because player would need special tables with chunks and offsets to locate every data sample. You can fake FTYP, MOOV and other atoms, but you can't generate all tables without having file complete. Better strategy would be to generate many short mp4 files and send them file by file...

michael
  • 216
  • 2
  • 2
  • But there is overhead in stopping the recorder, saving the file, then restarting the recorder in order to generate many short files (on Android). In fact, it causes a second or two of video to be skipped each time this happens. – David Doria Oct 15 '13 at 15:00
  • @DavidDoria This strategy would be used without closing the recorder. You'd need to grab the frames for 1 sec. and compress them independently from the next 1 sec. ... I'm not too sure how you'd do that on an Android, though. – Alexis Wilke Jul 09 '21 at 21:41