alexmercerind / dart_vlc

Flutter bindings to libVLC.
GNU Lesser General Public License v2.1
510 stars 136 forks source link

Hardware Decoding #152

Closed AswinParanji closed 2 years ago

AswinParanji commented 3 years ago

Hi, Is there a way to turn on hardware decoding? I created the player with arguments still it doesnt use hardware decoding. _player=Player(id:index,commandlineArguments: [':avcodec-hw=d3d11va']);

Any idea why this is not working?

Thanks Aswin

alexmercerind commented 3 years ago

How are you identifying the hardware decoding?

alexmercerind commented 3 years ago

libVLC 3.0.0's video callbacks have additional expense when copying the frame buffer. libVLC 4.0.0 will come with openGL based callbacks which will be a lot more performant. Only on Windows, we are using texture registrar API. On macOS & Linux, whole buffer is sent to Dart VM, encoded & then rendered using Image widget, which is even more expensive to do.

AswinParanji commented 3 years ago

libvlc 3.0.0 has hardware decoding, tested with libvlcsharp and hardware decoding is available, something that is being done here is not turning it on. I copied the libvlc.dll &core files from my flutter project to libvlcsharp project and I see hardware decoding is available.

use windows task manager to see decoding percentage usage.

My doubt is on setvideoformat(events.h:156)

By the way great work

alexmercerind commented 3 years ago

It's the libvlc_video_set_callbacks cost that's adding up. In libVLCSharp, possibly they use libvlc_media_player_set_hwnd which doesn't cost any additional computation. But in dart_vlc & how Flutter works, we extract each frame & render it to the UI (pixel by pixel). This cannot unfortunately be improved because libvlc_video_set_callbacks is always less efficient than direct viewport.

See this link for more details.

Apologies for delayed answer.

alexmercerind commented 2 years ago

Hey @AswinParanji,

After months of research I finally have an update.

Please use https://github.com/alexmercerind/dart_vlc#nativevideo to render performant video output inside the app (only windows is supported right now).

AswinParanji commented 2 years ago

That's great news looking forward to use it.

Quackdoc commented 2 years ago

I've noticed that flutter applications making use of dart_vlc don't make use of vaapi on linux, looking at this issue I am a bit confused.

does native video have support for host hardware accelerated decoding? but not the regular video output? will the video output get support for libvlc's hardware decoding at any point in the future?

I am a little lost why hwdec would be tied to renderer here.