Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to fake a (mp4) moov atom?

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?

like image 360
Raffi Avatar asked Mar 15 '11 13:03

Raffi


2 Answers

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 :-)

like image 85
Dmitri Sosnik Avatar answered Jan 02 '23 20:01

Dmitri Sosnik


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...

like image 31
michael Avatar answered Jan 02 '23 18:01

michael