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

Which method turns on hardware acceleration? #638

Open
7 tasks
kuangxj opened this issue Jan 14, 2023 · 1 comment
Open
7 tasks

Which method turns on hardware acceleration? #638

kuangxj opened this issue Jan 14, 2023 · 1 comment
Labels

Comments

@kuangxj
Copy link

kuangxj commented Jan 14, 2023

Issue Title (change this title!)

The CPU has always been high,and I want to reduce the performance of the CPU through hardware acceleration. I looked at the example and spent a lot of time not finding this method or example. Please tell me if you know.

Please enter a general description for the issue. Delete sections that are not relevant and provide additional sections if necessary.

Issue Categories

  • Bug
  • Feature Request
  • Question
  • Not sure

Version Information

  • NuGet Package Enter Version Number Here
  • Build From Master branch, Commit Enter commit id. Example: 704c482
  • Build from Branch Name, Commit Enter commit id. Example: 704c482

Steps to Reproduce

  1. Step 1
  2. Step 2
  3. Step 3

Expected Results

  • Result 1
  • Result 2

Sample Code

XAML

<MainWindow>
</MainWindow>

C#

System.Console.WriteLine("Change Me Please!");

Command line ffplay

ffplay "hello.mp4"

Delete This Section

@OneB1t
Copy link

OneB1t commented Apr 3, 2023

onMediaOpening

        // Setting Advanced Video Stream Options is also possible
        if (e.Options.VideoStream is StreamInfo videoStream)
        {
            // Example of forcing a codec for a stream
            // e.Options.DecoderCodec[videoStream.StreamIndex] = "mjpeg";

            // Hardware device priorities
            var deviceCandidates = new[]
            {
                //AVHWDeviceType.AV_HWDEVICE_TYPE_CUDA,
                //AVHWDeviceType.AV_HWDEVICE_TYPE_D3D11VA,
                AVHWDeviceType.AV_HWDEVICE_TYPE_DXVA2
            };

           foreach (var deviceType in deviceCandidates)
           {
               var accelerator = videoStream.HardwareDevices.FirstOrDefault(d => d.DeviceType == deviceType);
               if (accelerator == null) continue;
               e.Options.VideoHardwareDevice = accelerator;

               break;
           }

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

No branches or pull requests

3 participants