Skip to content

Instantly share code, notes, and snippets.

@vovcacik
Last active February 18, 2024 14:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vovcacik/5cb46072f6927621acc8 to your computer and use it in GitHub Desktop.
Save vovcacik/5cb46072f6927621acc8 to your computer and use it in GitHub Desktop.
Hacking LAV Splitter to use plain old buffering

Hacking LAV Splitter to use plain old buffering

LAV Splitter is used to fetch network data in some media players (e.g. MPC-HC). The LAV buffer (aka packets queue) is not measured in data volume, but rather in packets (or frames, not sure here). Anyway, since the network throughput is limited by data volume, the number of packets in queue is multiplied by factor variable, which is bigger the higher quality video you are playing. This provides variable length buffer, however you can't really control the size and if you got slow WiFi you might have experienced choppy playback.

The following guide changes the way LAV buffer works by eliminating packet limits and putting the infamous "Maximum Queue Memory" settings in charge (you might have tried to increase this settings from default 256 MB to no avail as many have before you).

###32-bit instructions

  1. Open the mpc-hc/LAVFilters/LAVSplitter.ax file in HEX editor of your choice.
  2. Find and replace the unique 69 C5 5E 01 00 00 byte sequence with 69 C5 FF FF 00 00.
  3. Open LAV Splitter settings and set the "Maximum Queue Memory" to 256 MB if you have changed it. This is big enough and higher values may introduce instability.

Details

We are changing the m_dwQueueHigh = MAX_PACKETS_IN_QUEUE * factor; 1 line where #define MAX_PACKETS_IN_QUEUE 350 2 to m_dwQueueHigh = 65535 * factor;.

@pavlus
Copy link

pavlus commented Jan 24, 2016

It's now 69 C0 5E 01 00 00, isn't it?

@peace2000
Copy link

It looks like they have made some changes therefore making this guide outdated. Can you update your guide, please? I cannot find 69 C5 5E 01 00 00 anywhere nor the one that pavlus mentioned.

@EXPERIMENTONGOD
Copy link

EXPERIMENTONGOD commented Oct 29, 2020

I know this post is VERY old but people will stumble on this trying to find a solution for WiFi stutter with MPC-HC / MPC-BE and this post is very informative about the cause and solution for this issue. Fortunately you no longer need any "hacking", therefore the fix is the following on the current version of LAV Filters (0.74.1):

SOLUTION

  1. Open "LAV Splitter Configuration" ("Start" => "LAV Filters" => "LAV Splitter Configuration" in Windows)
  2. In "Queue Settings" (right hand side of the "LAV Splitter" tab) change "Maximum Queue Packets" from the default value of "350" to "65535" and click "OK"

Closing comments

With this solution LAV Splitter will ALWAYS try to keep a 256MB data volume buffer filled for any video file you play, which is pretty generous even for very high bitrate files. Even on an 80Mbps bitrate 4K REMUX (lossless) movie you will have (on average) over 20 seconds of buffer which should be more than enough to compensate for any WiFi transfer rate instability.

To track buffer health on MPC-BE right click on the video and choose "View => Statistics", then pay attention where it says "Buffers", you will see (up to) XXXX/262.144KB (256MB). If that number gets very low due to poor WiFi transfer speed you can raise the buffer in LAV Splitter Configuration even further (set "Maximum Queue Memory" to 512 or 1024 for example. The maximum allowed is 2048 MB).

As a last resort, if your buffer gets low/empty because your WiFi is VERY unstable/slow, you can pause the movie for a bit to let the buffer fill up. You can tweak the LAV Splitter Settings ("Maximum Queue Memory") and apply them in real time while the video plays to help you find the right balance.

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