lieff / minimp4

Minimalistic MP4 mux/demux single header library
Creative Commons Zero v1.0 Universal
342 stars 58 forks source link

sequential mode not seekable on windows #14

Open rhwu opened 4 years ago

rhwu commented 4 years ago

./minimp4_x86 -m stream.h264 stream.mp4 ./minimp4_x86 -m -s stream.h264 stream-s.mp4 ./minimp4_x86 -m -f stream.h264 stream-f.mp4

All of them are seakable with quicktime player on Mac. But stream-f.mp4 is not seekable with windows media player.

Is this something that can be improve?

Thanks!

lieff commented 4 years ago

Hmm, I've always used the K-Lite codec pack and Media Player Classic on the windows.. Otherwise there problems with many media files.

If default mp4 splitter do not prints anything to debug output, then we cant use it to debug this. Other media validators should be used in this case (I do not have any currently).

lieff commented 4 years ago

Without k-lite pack I do not see any generic mp4 demuxers available in directshow. There only DTV-DVD decoder and I can reproduce issue with it:

image

So it may be just not intended to use with media files instead of DTV-DVD. Any splitter/demuxer from K-Lite works fine.

rhwu commented 4 years ago

The default mode and sequential mode seem be playing fine though.

It will be ideal if there's a mode that combines the benefit of both sequential mode and fragmentation mode, i.e. decoding can start right away but at the same time with something at the end for duration/seeking.

Don't know much about the mp4 spec, maybe this is not possible. Either way, thanks for looking into this!

lieff commented 4 years ago

Yes, I've checked also default and fragmentation modes and it's played fine with DTV-DVD decoder, so it's looks like what enabled on your side.

It will be ideal if there's a mode that combines the benefit of both sequential mode and fragmentation mode

Fragmentation mode already sequential, but it's even less efficient because indexes flushed many times. Default mode and sequential combine is not possible: default

In non sequential mode each MP4E_put_sample will put new frame in this one big mdat chunk. When we ready to stop and write indexes - we need go back write correct mdat chunk size (it's located at beginning of chunk). Technically it's possible if we know all frames size we will write at start (and for all tracks), and then write exactly this amount, but this rarely the case.