AbedElazizShe / LightCompressor

A powerful and easy-to-use video compression library for android uses MediaCodec API.
Apache License 2.0
524 stars 116 forks source link

Slow load of compressed vs original videos when server over http #166

Open AlejandroImbox opened 1 year ago

AlejandroImbox commented 1 year ago

@AbedElazizShe and team, I noticed an strange behaviour while using LightCompressor 1.2.3. The compression works as expected, original file is 158MB vs a 97MB video (after LC). The issue comes when I serve this compressed video over http.

For example, when loading this web with chrome https://imbox.me/test.html you can see that there are 2 videos embedded (via html5 video tag). The first one is the original one (heavier) and the second one is the compressed one (lighter).

The original one loads instantly while the compressed one takes a few seconds with a spinner (its as if the compressed format forced chrome to download certain amount of the video prior to displaying the player). As a result it takes longer to load the compressed lighter video than the original heavier one O_o.

I have been looking at the differences in terms of formatting, both of them are being served from the same site (AMAZON S3), both of them are MP4, with MPEG-4 AAC, H264 Codecs.

The only difference I could find was via METADATA2GO site, where I can see that "major_brand" is MP4 v2 [ISO 14496-14] in the original one and MP4 Base Media v1 [IS0 14496-12:2003] in the compressed

Note that I am aware of this note in the documentation: "If you want an output video that is optimised to be streamed, ensure you pass [isStreamable] flag is true." but the flag does not fix it.

Any ideas?

Thank you very much in advance and keep up the good work!

Captura de pantalla 2023-08-08 a las 16 46 49

AbedElazizShe commented 1 year ago

Hi @AlejandroImbox , thanks a lot for the insights, really appreciated.

I have made the changes based on the only difference you spotted with the use of this website https://www.ftyps.com/.

Could you please give it another try? I will release a new version shortly.