Page 1 of 1

Avoid using software decoder in android

Posted: 09 Jun 2018 20:45
by israelillan
Hi,

I'm developing an app using libvlc for android (to allow to be used from unity) but when I play a movie it seems it uses the software decoder and performance is very bad:

Code: Select all

06-09 15:05:30.507 19044-19396/es.arklay.uvlc D/VLC: [b9815b28/4bc4] avcodec decoder: CPU flags: 0x0000003f 06-09 15:05:30.511 19044-19396/es.arklay.uvlc D/VLC: [b9815b28/4bc4] avcodec decoder: allowing 4 thread(s) for decoding 06-09 15:05:30.514 19044-19396/es.arklay.uvlc D/VLC: [b9815b28/4bc4] avcodec decoder: codec (h264) started 06-09 15:05:30.514 19044-19396/es.arklay.uvlc D/VLC: [b9815b28/4bc4] avcodec decoder: using frame thread mode with 4 threads 06-09 15:05:30.514 19044-19396/es.arklay.uvlc D/VLC: [b9815b28/4bc4] core decoder: using decoder module "avcodec" 06-09 15:05:30.515 19044-19396/es.arklay.uvlc D/VLC: [e9fec028/4bc4] core decoder: looking for decoder module matching "mediacodec_ndk,all": 40 candidates 06-09 15:05:30.515 19044-19396/es.arklay.uvlc D/VLC: [e9fec028/4bc4] avcodec decoder: CPU flags: 0x0000003f 06-09 15:05:30.517 19044-19073/es.arklay.uvlc I/MediaSurfacePlugin: MediaSurface:: UnityRenderEvent UPDATE 06-09 15:05:30.521 19044-19396/es.arklay.uvlc D/VLC: [e9fec028/4bc4] avcodec decoder: codec (aac) started 06-09 15:05:30.522 19044-19396/es.arklay.uvlc D/VLC: [e9fec028/4bc4] core decoder: using decoder module "avcodec" 06-09 15:05:30.522 19044-19396/es.arklay.uvlc D/VLC: [eaa49a78/4bc4] core demux meta: looking for meta reader module matching "any": 2 candidates 06-09 15:05:30.524 19044-19396/es.arklay.uvlc D/VLC: [eaa49a78/4bc4] core demux meta: using meta reader module "taglib" 06-09 15:05:30.524 19044-19396/es.arklay.uvlc D/VLC: [eaa5e9a8/4bc4] core demux: removing module "taglib" 06-09 15:05:30.524 19044-19396/es.arklay.uvlc D/VLC: [d8436028/4bc4] core input: `file:///storage/emulated/0/Android/data/es.arklay.uvlc/files/temp.mp4' successfully opened 06-09 15:05:30.525 19044-19396/es.arklay.uvlc D/VLC: [eaa5e9a8/4bc4] mp4 demux: elst (0) gives 0ms (movie)-> 0ms (track) 06-09 15:05:30.525 19044-19396/es.arklay.uvlc D/VLC: [eaa5e9a8/4bc4] mp4 demux: track[Id 0x1] using Sync Sample Box (stss) 06-09 15:05:30.525 19044-19396/es.arklay.uvlc D/VLC: [eaa5e9a8/4bc4] mp4 demux: stss gives 0 --> 0 (sample number) 06-09 15:05:30.525 19044-19396/es.arklay.uvlc D/VLC: [eaa5e9a8/4bc4] mp4 demux: elst (0) gives 0ms (movie)-> 0ms (track) 06-09 15:05:30.525 19044-19396/es.arklay.uvlc D/VLC: [d8436028/4bc4] core input: Buffering 0% 06-09 15:05:30.525 19044-19397/es.arklay.uvlc D/VLC: [b9815b28/4bc5] avcodec decoder: available software decoder output format 0 (yuv420p) 06-09 15:05:30.525 19044-19394/es.arklay.uvlc E/VLC-std: [h264 @ 0xb9816200] Reinit context to 3840x2160, pix_fmt: 0
While debugging VLC it seems to choose ffmpeg (and performance is perfect):

Code: Select all

06-09 19:25:53.125 26218-26311/org.videolan.vlc.debug D/VLC: [bc02ac30/66c7] libvlc decoder: allowing 6 thread(s) for decoding 06-09 19:25:53.127 26218-26311/org.videolan.vlc.debug D/VLC: [bc02ac30/66c7] libvlc decoder: codec (h264) started [bc02ac30/66c7] libvlc decoder: using frame thread mode with 6 threads [bc02ac30/66c7] libvlc decoder: using video decoder module "avcodec" 06-09 19:25:53.128 26218-26311/org.videolan.vlc.debug D/VLC: [bc02aeb0/66c7] libvlc decoder: looking for audio decoder module matching "mediacodec_ndk,all": 17 candidates [bc02aeb0/66c7] libvlc decoder: using ffmpeg Lavc58.6.103 [bc02aeb0/66c7] libvlc decoder: CPU flags: 0x0000003f 06-09 19:25:53.134 26218-26311/org.videolan.vlc.debug D/VLC: [bc02aeb0/66c7] libvlc decoder: codec (aac) started [bc02aeb0/66c7] libvlc decoder: using audio decoder module "avcodec" [ab798b10/66c7] libvlc demux meta: looking for meta reader module matching "any": 2 candidates 06-09 19:25:53.137 26218-26311/org.videolan.vlc.debug D/VLC: [ab798b10/66c7] libvlc demux meta: using meta reader module "taglib" [ab7fe870/66c7] libvlc demux: removing module "taglib" [c2abd830/66c7] libvlc input: `file:///storage/emulated/0/vlctemp.mp4' successfully opened [ab7fe870/66c7] libvlc demux: elst (0) gives 0ms (movie)-> 0ms (track) 06-09 19:25:53.137 26218-26218/org.videolan.vlc.debug I/VLC/MediaDatabase: Media.Event.ParsedChanged
Any ideas?

Re: Avoid using software decoder in android

Posted: 10 Jun 2018 10:51
by InTheWings
Isn't hw decoding on by default ?

Re: Avoid using software decoder in android

Posted: 10 Jun 2018 11:43
by israelillan
Thats what i thought, but i still get a software decoder

Re: Avoid using software decoder in android

Posted: 10 Jun 2018 13:04
by RĂ©mi Denis-Courmont
libvlc_video_set_callbacks() is incompatible with, and automatically disables hardware decoding.

Re: Avoid using software decoder in android

Posted: 10 Jun 2018 13:57
by israelillan
I'm not using libvlc_video_set_callbacks, im using AWindow (libvlc_media_player_set_android_context)

Re: Avoid using software decoder in android

Posted: 13 Jun 2018 19:34
by israelillan
I even tried LibVLCSharp (https://forum.videolan.org/viewtopic.php?f=32&t=144807) libraries but I still get the same problem...

Tried using Java wrappers, tried calling directly the JNI functions, latest libvlc commit, latest libvlc stable release (both of them compile, build and run properly from android studio in my device) but the error remains... im getting out of ideas

Re: Avoid using software decoder in android

Posted: 13 Jun 2018 19:35
by israelillan
BTW, my final target is to show the video in a unity texture, I will gladly share the working code here when i get to a working code...

Re: Avoid using software decoder in android

Posted: 16 Jun 2018 08:11
by mfkl
Hi israelillan,

LibVLCSharp author here.

Try adding

Code: Select all

media.AddOption(":codec=mediacodec_ndk");
And see if you see MediaCodec logs appearing during playback initialization.

Planning to add soon a convenience crossplatform media configuration object for LibVLCSharp https://github.com/videolan/libvlcsharp ... dd0a36e89b

Have a look at this https://code.videolan.org/videolan/vlc- ... .java#L740 for covering most bases.

Good luck

Re: Avoid using software decoder in android

Posted: 16 Jun 2018 08:18
by mfkl
I will gladly share the working code here when i get to a working code...
Please do. Unity is on the support roadmap.