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

Buffering for the local files #4881

Open
stingusss opened this issue Apr 16, 2024 · 9 comments
Open

Buffering for the local files #4881

stingusss opened this issue Apr 16, 2024 · 9 comments

Comments

@stingusss
Copy link

Hello!
First of all I'd like to thank you for developing such an amazing player for MacOS. Switched to Mac almost 2 years ago and I never expected that the multimedia's side switch will go so smooth. But it did, thanks to IINA player. Love it, thank you!

What you want IINA to do:
I want IINA to have a buffering setting when playing local files to enhance playback from the slow/problematic storage devices.

Why you think this should be added:
I use an SD card as a memory expansion (got an adapter that doesn't stick out of the built in card reader in M1 Pro MBP) and I store all my media on it.
It's a pretty fast SD card - 90/90 r/w, but when I watch something from it, the video always halts for 2-5 seconds every now and then. It seems that it is happening due to MacOS doing some power saving hibernation for the SD card.
So I'd like to be able to set up a buffer length for the IINA player so it will load up like 20 seconds of the video into the RAM in advance to prevent video from stopping when the player is trying to get for next pack of data but the SD card isn't responding right away.

I'm using the base M1 Pro 14 inch MBP 2021. MacOS Sonoma 14.4.1. Playback from the local SSD is fine and the SD card itself is fine too (tried several of these).

Once again, thank you for your work!

@low-batt
Copy link
Contributor

IINA uses a library from the mpv project for audio/video support. Many mpv features not exposed by the IINA user interface are still available by directly setting mpv options. This includes options that control buffering. More on that in a second.

Do we know this for certain?:

It seems that it is happening due to MacOS doing some power saving hibernation for the SD card.

Really disturbing. There have been lots of problems with macOS Sonoma.

Anyway, something similar was reported in issue #4709 with playing audio files from an external disk. In this comment at the bottom I provide instructions for setting the mpv option demuxer-readahead-secs in IINA's Advanced settings. Give that a try and see if the added buffering eliminates the stopping.

@krackers
Copy link

You may also just want to enable demux cache, since if you're going to uncap demuxer-readahead-secs you probably want the ability to seek into the readahead region as well.

@low-batt
Copy link
Contributor

In IINA's settings on the Network tab there is a Cache section with several settings:
cache-settings

This table shows the mpv options those settings correspond to:

Setting mpv Option IINA Default
Enable cache --cache yes
Default cache size (KB) --demuxer-max-bytes 153600
Seconds to prefetch --cache-secs 36000

Given those settings I've been confused about why setting demuxer-readahead-secs changed the behavior in issue #4709. I was expecting demuxer-max-bytes would be the limiting factor.

@stingusss
Copy link
Author

IINA uses a library from the mpv project for audio/video support. Many mpv features not exposed by the IINA user interface are still available by directly setting mpv options. This includes options that control buffering. More on that in a second.

Do we know this for certain?:

It seems that it is happening due to MacOS doing some power saving hibernation for the SD card.

Really disturbing. There have been lots of problems with macOS Sonoma.

Anyway, something similar was reported in issue #4709 with playing audio files from an external disk. In this comment at the bottom I provide instructions for setting the mpv option demuxer-readahead-secs in IINA's Advanced settings. Give that a try and see if the added buffering eliminates the stopping.

Hi!
Had a busy week so had not so much time to test, but it seems that it helped! There were no stuttering during about 3 hours of play-through, while before they used to happen as often as every 3-5 minutes.
I have set up the parameter to 5 seconds.

Will continue to investigate the solution and will let you know how it went.
Thank you!

@low-batt
Copy link
Contributor

Glad it seems to be helping. I'm still disturbed that we don't know what seems to be disrupting access to the SD card.

@stingusss
Copy link
Author

Glad it seems to be helping. I'm still disturbed that we don't know what seems to be disrupting access to the SD card.

I'm pretty sure that's the MacOS' behavior. When I just suddenly try to access the SD card after not using it for some time, it takes about 3 seconds to show me the files for the "first time". But after it has "spun", it works fine - transferring huge files without any issues and with a constant speed.
So my guess is that the SD card goes to some kind of sleep or something. But why is it happening during the playback is a mystery.

@low-batt
Copy link
Contributor

It does sound like macOS could be powering down the drive.

It feels like my high speed USB flash drives slowed down as of macOS Ventura.

I've read posts from macOS Sonoma users about USB problems. I vaguely remember one user tracing the problem to a printer interfering with other USB devices. When this happens are any other USB devices attached?

@ShlomoCode
Copy link

got an adapter that doesn't stick out of the built in card reader in M1 Pro MBP

BaseQI?

@stingusss
Copy link
Author

got an adapter that doesn't stick out of the built in card reader in M1 Pro MBP

BaseQI?

Yep, the BaseQi 420A one.

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

No branches or pull requests

4 participants