title: What's best way to playback forward and backward a high fps video programmatically?
body: <p>I need to playback video programmatically forward and backward, by having a slider that sets the playback speed and direction; with about 150-400 fps. Visually, it would be like:</p>
  
  <pre><code>[-10x][-8x][-4x][-2x][1/8x][1/4x][1/2x][1x][2x][4x][6x][8x][10x]
  </code></pre>
  
  <p>And slowly transitioning between these. </p>
  
  <p>What I've tried:</p>
  
  <ol>
  <li><p>JavaFX Media player: </p>
  
  <ul>
  <li>24fps video, forward: works fine for normal playback </li>
  <li>24fps video, backward: I tried to use the <code>seek()</code> method, but it lags and won't let me set the milliseconds, as it converts the value to seconds later and looses the actual value. </li>
  </ul></li>
  <li><p>vlcj player:</p>
  
  <ul>
  <li>24fps video, forward: work fine for 1x to 10x playback rate, and of course I see frames changing at /2x, /4x etc.</li>
  <li>24fps video, backward: I tried to use the <code>setTime()</code> method, which seems to be working fine, by pausing the video and decreasing 1ms from current time, every 1ms. But it is laggy of course. Even for 50ms, and 100ms.  </li>
  <li>400fps video, forward: lags dramatically on all speeds from 1x to 10x; but works great on /2x and lower rate.</li>
  <li>400fps video, backward: could not get it working same way by decreasing 1ms, but it worked smooth by decreasing 20ms every 20ms. Unfortunately, no slow motion could be achieved, it plays very fast.</li>
  </ul></li>
  <li><p>Usual VLC Media Player:</p>
  
  <ul>
  <li>400fps video, forward: the video still lags at 1x, and plays smooth at 1/2x and below. Inside the player below the seek bar, I could see a loading progress bar, which as I suppose, does not manage to playback at 1x the 400 fps video, as it needs to process too many frames. And most probable, to get it working this way, a powerful machine would be needed (but it seems to be a waste of power). </li>
  </ul></li>
  </ol>
  
  <p>Now I could only think of the following solutions:</p>
  
  <ol>
  <li><p>Have 2 videos prepared forward and backward, put them above each other, always do forward playback, and keep them synchronised as following:     </p>
  
  <p>backwardVideo.time = backwardVideo.totalLength - forwardVideo.time;</p>
  
  <p>And when playing forward, I would show only the forward going video; then when playing backward, I would hide the forward video from top layer, and leave the backward video visible which would look like its playing backward. Then I am left with solving the fast playback of a high fps video, so that it does not lag at higher rates.</p></li>
  <li><p>Do it by processing frames from files with a buffer depending on fps and computer power. That would be like mjpeg player, which would load all photos from a folder. </p>
  
  <p>As suggested <a href="https://stackoverflow.com/a/11260842/2673005">here</a>: <em>I strongly recommend you to save frames to files</em>. </p>
  
  <p>So, for a 90sec video with 300fps, its only 27000 photos (which is not that of a big deal for a powerful pc with a fast disk read speed). </p></li>
  <li><p>Have a video encoded that does not subtract the frame differences, and use the frames with a buffer to playback them (it should be very slow as suggested <a href="https://stackoverflow.com/a/11260842/2673005">here</a> as well)</p></li>
  </ol>
  
  <p>Notes: </p>
  
  <ul>
  <li>I will be using a PC with: i7 6th Gen, GTX980 4Gb video card, 16gb ram.     </li>
  <li>The video would be about 90 seconds long, with a resolution of about 2k. </li>
  <li>I would prefer a solution for java, but if there is a great solution in any other technology, then I'm all for it.</li>
  </ul>
  
  <p>So, what do you think is the best way to playback smoothly forward and backward a high fps video?</p>