Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reverse playback (with negative speeds) #274

Open
frmz opened this issue Apr 14, 2016 · 4 comments
Open

Add reverse playback (with negative speeds) #274

frmz opened this issue Apr 14, 2016 · 4 comments

Comments

@frmz
Copy link
Contributor

frmz commented Apr 14, 2016

It would be nice to be able to do reverse playing by using a negative speed value, is there any reason why min is currently 0?

@koral--
Copy link
Owner

koral-- commented Apr 14, 2016

Yeah, it would be nice but it is not so easy to implement.
First of all in general GIFs cannot be randomly sought, in some cases it is required to render all frames from the beginning to desired frame, see #262 for more details.
Even if that optimization from mentioned issue is applicable to given GIF (eg. all frames are fullscreen and opaque) and previous frame can just rendered without any other, there is another piece of code to write. Underlying input sources (byte[], File etc.) are read sequentially, to effectively seek backwards, offset of each frame need to be remembered. However InputStream cannot be sought and can only be reset to mark just before the first frame.

That's how GifDrawable works. In case of GlTextImage2D it may be possible to buffer all frames using OpenGL framebuffers.

@frmz
Copy link
Contributor Author

frmz commented Apr 15, 2016

Ah ok very clear now, works very much the same way other video format do with key frames and deltas. I don't think its a good idea to load everything on an OpenGL FB, too much memory intensive.

Maybe (if giflib supports this somehow) it would be an option to provide a way to create a reversed Gif so one could then load both and alternate rendering (so just a converter method "reverse" with in/out streams). Once you have both versions than its probably easy to implement using seek even without native support in the library.

@luojin
Copy link

luojin commented Feb 25, 2017

@frmz seek() could not called in UI thread, so can u show me your implementation ?

@koral--
Copy link
Owner

koral-- commented Feb 25, 2017

AFAIK there is no other solution than calling seek... methods family. They are asynchronous by default (in GifDrawable) so result may not be visible immediately moreover seeking backward may be slow.
New solution may appear in issue #287.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants