# VideoPlayerFFMPEG buffer issues

**URL:** https://openrndr.discourse.group/t/videoplayerffmpeg-buffer-issues/560
**Category:** How to?
**Created:** [May 26, 2023, 6:47pm UTC](https://openrndr.discourse.group/t/videoplayerffmpeg-buffer-issues/560 "2023-05-26T18:47:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![LH99](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/lh99/32/575_2.png) [@LH99](https://openrndr.discourse.group/u/LH99)
#### Post date: [May 26, 2023, 6:47pm UTC](https://openrndr.discourse.group/t/videoplayerffmpeg-buffer-issues/560/1 "2023-05-26T18:47:22Z")

</div>

I struggled with `VideoPlayerFFMPEG` quite a lot recently.

Upon posting this issue, I found a solution which I’d like to share.

**Faulty setup** (on macOS with M1 chip):

```auto
val videoPlayer = VideoPlayerFFMPEG.fromFile("path/to/myVideo.mp4")
videoPlayer.ended.listen { videoPlayer.restart() }
videoPlayer.play()

extend {
    videoplayer.draw(drawer)
}

```

Command line output:

```auto
error? -35
error? -35
error? -35
error? -35
error? -35
error? -35
... 

```

_(keeps spamming each frame)_  
Eventually, the replay stops and stays on the last image. Also the spam changes to:

```auto
 WARN [Thread-4(decoder)] o.o.f.Decoder ↘ video queue is almost full. [video queue: 49, audio queue: 0]
...

```

A few seconds later, the app crashes with:

```auto
├─ kotlin.concurrent.Threads.thread.thread.{ }.run(Thread.kt:30)
├─ ...
↑ queue overflow: 42 43 (Error) 

```

---

<div class="post-metadata">

### Author: ![LH99](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/lh99/32/575_2.png) [@LH99](https://openrndr.discourse.group/u/LH99)
#### Post date: [May 26, 2023, 6:47pm UTC](https://openrndr.discourse.group/t/videoplayerffmpeg-buffer-issues/560/2 "2023-05-26T18:47:29Z")

</div>

_ **Fix:** _  
By deafult, the `mode` parameter of `fromFile` is on `PlayMode.BOTH` (for video + audio).  
As I was interested in video only and audio was introducing heavy lag, I changed the `mode` to `PlayMode.VIDEO`. The frames were available in time again, and the frame queue was cleared fast enough to not overflow and crash.

---

<div class="post-metadata">

### Author: ![LH99](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/lh99/32/575_2.png) [@LH99](https://openrndr.discourse.group/u/LH99)
#### Post date: [May 26, 2023, 6:56pm UTC](https://openrndr.discourse.group/t/videoplayerffmpeg-buffer-issues/560/3 "2023-05-26T18:56:37Z")

</div>

On that topic, I found the classes `VideoStatistics` and `VideoPlayerConfiguration` that are related to `VideoPlayerFFMPEG`.

Those could be data classes.  
One benefit: They could be used in their “canonic” string representation. I found that to be useful during debugging this issue.

This way, you could use them like this:

```auto
println(VideoStatistics())
// "VideoStatistics(videoFrameQueueSize=50, ...)"

```

---

<div class="post-metadata">

### Author: ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)
#### Post date: [May 26, 2023, 8:30pm UTC](https://openrndr.discourse.group/t/videoplayerffmpeg-buffer-issues/560/4 "2023-05-26T20:30:12Z")

</div>

Thank you for sharing your discoveries! I have also in the past resorted to VIDEO only mode.

I guess we need to do some check why it’s not playing as smooth as it should, why sound causes issues, and avoid repeating the same message over and over. I like that in the console in browsers it can say indicate that the message was printed multiple times.
