enzo1982 / mp4v2

Reviving the MP4v2 project...
https://mp4v2.org
Other
140 stars 52 forks source link

optimize option causes file seeks #43

Open L2501 opened 1 year ago

L2501 commented 1 year ago

on a file created with ffmpeg +faststart: no stream level seek

after: mp4chaps -Q -z -c file.m4b mpv -v file.m4b

[file] stream level seek from 9008064 to 10035944
[file] stream level seek from 10167016 to 11084349
[file] stream level seek from 11215421 to 27858534
[file] stream level seek from 27989606 to 40439182
[file] stream level seek from 40570254 to 54068525
[file] stream level seek from 54199597 to 79229879
[file] stream level seek from 79360951 to 99149198
[file] stream level seek from 99280270 to 125359467
[file] stream level seek from 125490539 to 147375359
[file] stream level seek from 147506431 to 167293594
[file] stream level seek from 167424666 to 197696661
[file] stream level seek from 197827733 to 221809244
[file] stream level seek from 221940316 to 248018732
[file] stream level seek from 248149804 to 261647056
[file] stream level seek from 261778128 to 279470226
[file] stream level seek from 279601298 to 289954147
[file] stream level seek from 290085219 to 300437685
[file] stream level seek from 300568757 to 316163013
[file] stream level seek from 316294085 to 336082906
[file] stream level seek from 336213978 to 347614988
[file] stream level seek from 347746060 to 361244261
[file] stream level seek from 361375333 to 379065464
[file] stream level seek from 379196536 to 387452404
[file] stream level seek from 387583476 to 400033096
[file] stream level seek from 400164168 to 416807524
[file] stream level seek from 416938596 to 444065553
[file] stream level seek from 444196625 to 457694285
[file] stream level seek from 457825357 to 471323266
[file] stream level seek from 471454338 to 487049284
[file] stream level seek from 487180356 to 502774753
[file] stream level seek from 502905825 to 511162368
[file] stream level seek from 511293440 to 534227119
[file] stream level seek from 534358191 to 547856455
[file] stream level seek from 547987527 to 562534223
[file] stream level seek from 562665295 to 574066807
[file] stream level seek from 574197879 to 590840529
[file] stream level seek from 590971601 to 608662831
[file] stream level seek from 608793903 to 623339239
[file] stream level seek from 623470311 to 634872091
[file] stream level seek from 635003163 to 649549270
[file] stream level seek from 649680342 to 663177550
[file] stream level seek from 663308622 to 677855370
[file] stream level seek from 677986442 to 697775345
[file] stream level seek from 697906417 to 708259166
[file] stream level seek from 708390238 to 720839513
[file] stream level seek from 720970585 to 730274415
[file] stream level seek from 730405487 to 740757648
[file] stream level seek from 740888720 to 764871034
[file] stream level seek from 765002106 to 780596717
[file] stream level seek from 780727789 to 795274512
[file] stream level seek from 795405584 to 801565278
[file] stream level seek from 801696350 to 809952318
[file] stream level seek from 810083390 to 811000876
[file] stream level seek from 811131948 to 8987551
enzo1982 commented 1 year ago

After optimization, QuickTime chapters are interleaved with the data stream. So when reading the chapters, the application has to seek to the chunk position of each chapter entry. That's normal and expected with the current implementation.

However, it does not necessarily have to be this way. The chapters could also be stored all in a separate mdat atom at the beginning or end of the file (which would make it easier to read the chapters).

I'm not sure why it was implemented with interleaved chapters here. Need to check how original QuickTime does it. If QuickTime also interleaves, it's probably better to keep the current implementation and continue doing the same. If it doesn't interleave, then we shouldn't either.