Git Product home page Git Product logo

Comments (1)

59de44955ebd avatar 59de44955ebd commented on August 22, 2024

Update: today I recompiled LAV Filters myself from master and hacked this function into LAVSplitter, attached .zip contains my adjusted version:
https://nextcloud.dasdeck.com/index.php/s/bGPRdyxtXdAD7qL

There is only this single change: if there is a REG_DWORD value called "PreferredVideoStreamHeight" under HKCU\Software\LAV\Splitter, the demuxer will select the video stream with the smallest absolute difference to this value. If there is no such value in the registry, it will select the stream with the smallest difference to 4320 (=8K), so basically the same behavior as before, since I guess there are no HLS streams with higher resolution (but 4320 could also be replaced with 0xFFFFFFFF, so to really "always select the largest").

To make this work, I added this line on top of the programs for loop in method STDMETHODIMP CLAVFDemuxer::CreateStreams() in LAVFDemuxer.cpp:
DWORD dwFavoriteHeight = m_pSettings->GetPreferredVideoStreamHeight(); // CUSTOM

And inside the loop, I changed
//DWORD dwResolutionScore = st->codecpar->width * st->codecpar->height;
to
DWORD dwResolutionScore = 0xFFFFFFFF - (st->codecpar->height >= dwFavoriteHeight ? st->codecpar->height - dwFavoriteHeight : dwFavoriteHeight - st->codecpar->height);

And that's about it. New method "GetPreferredVideoStreamHeight" is declared in LAVSplitterSettingsInternal.h - since I didn't want to touch the public COM interface - and implemented in LAVSplitter.cpp like this:

STDMETHODIMP_(DWORD) CLAVSplitter::GetPreferredVideoStreamHeight()
{
    return m_settings.PreferredVideoStreamHeight;
}

And new DWORD property "PreferredVideoStreamHeight" of CLAVSplitter's Settings struct is initialized directly inside CLAVSplitter::LoadDefaults() like this:

    HRESULT hr;
    CRegistry reg = CRegistry(HKEY_CURRENT_USER, LAVF_REGISTRY_KEY, hr, TRUE);
    DWORD dwVal = reg.ReadDWORD(L"PreferredVideoStreamHeight", hr);
    if (SUCCEEDED(hr))
        m_settings.PreferredVideoStreamHeight = dwVal;
    else
        m_settings.PreferredVideoStreamHeight = 4320; // 8K

That's because I didn't want to recompile MPC-HC as well, so I wanted it to work also in case of m_bRuntimeConfig being true, and therefor couldn't add it to the ReadSettings method. For now it's just a hidden extra feature not showing up in the settings GUI, so only for those willing to edit stuff in the Registry. But that's perfectly fine for me.

from lavfilters.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.