I am creating an application for creating gif animations.

To create a gif, the user first works with VideoView, which turns the video.

During viewing, the user selects a segment of video that must be converted into a gif.

When the segment is selected, I launch the GIFA preview mode, which is to simply rewind the video alternately to the frames that the gif will consist of

Below is a simplified piece of the mode implementation code (there is no sense to insert the code completely, the problem is not in it, it is correct).

int interval = 1000 / fps; Observable.interval(interval, TimeUnit.MILLISECONDS) .subscribe(t -> video.seekTo(computeCurrentFrameTime()) 

This allows you to play videos with a specific frame rate so that it looks just like a gif, which will result. But only while the video is short. When I apply this mode for video lengths, for example, per hour, video playback becomes much lower frame rates than I require. In other words - freezes.

How to make it so that it does not hang?

  • For a start, it would probably be good to see who is slowing down with a profiler. Maybe you need to add some kind of cache. Select the necessary frames in a separate container and twist already out of it. - αλεχολυτ
  • one
    The video is encoded using the P-frame, in other words, in some encodings, the previous frame is used and its difference for the next one. Probably you need to increase the buffering for the arbitration transition on the tape. - Daniel Protopopov
  • RTSP stream using? - user192664
  • I do not rummage what is RSTP I do not know. I have a VideoView, which I use to put the Uri viewers, and twist this view with RxJava - P. Ilyin

0