momo0853 / mp4v2

mp4v2 for android
Other
19 stars 20 forks source link

Need asynchronous optimization method #120

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Is there a way to get an async version of MP4Optimize?  That is taking around 2 
minutes on my test file to complete.  I'd like to be able to display a progress 
bar during optimization to let the user know roughly how long they have left to 
wait, and also so that I don't lock up my UI while the optimization is 
happening.

Original issue reported on code.google.com by Scott.Gr...@gmail.com on 8 Sep 2011 at 3:47

GoogleCodeExporter commented 8 years ago
Well the simple way to get anything is to write it yourself and provide a 
patch.  Also, I'd point out you don't need to lock up the UI while the optimize 
call is happening; you shouldn't be calling MP4Optimize on your GUI thread.  
Call it on a separate thread, then send a signal/fire an event/set a watch 
variable/etc. once it's one.

Original comment by jnor...@logitech.com on 8 Sep 2011 at 2:24

GoogleCodeExporter commented 8 years ago
If I were familiar with your API and remembered anything about C++ I 
would...but I'd end up breaking things rather than helping.

Original comment by Scott.Gr...@gmail.com on 8 Sep 2011 at 8:38

GoogleCodeExporter commented 8 years ago
Hi, I made a simple implementation which does iterative copy of mdat.
This is just "iterative", not "asynchronous".

In this implementation, a class named MP4FileCopy does the copying job.
It does almost the same with MP4File::MP4Optimize(), in iterative manner.
Basically it works like the following:
MP4FileCopy::start(): -> Write moov with BeginOptimalWrite()
MP4FileCopy::copyNextChunk(): -> Copy next chunk in mdat (in timestamp order). 
Similar to RewriteMdat(), but copy only one chunk.
MP4FileCopy::finish(): -> Fix moov with EndOptimalWrite()

This class does nothing about temporary file handling, therefore you have to 
wrap around this if you write back the result. However, it would be fairy easy.

I use dirty trick here to access MP4File's protected member from this class.
If this is implemented officially, it could be written in more cleaner and 
saner say.
Also, MP4File::Optimize could be re-implemented based on this.

Original comment by honeycom...@gmail.com on 13 Sep 2011 at 4:08

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by kid...@gmail.com on 19 Mar 2012 at 3:01