Avoid using software decoder in android

This forum is about all development around libVLC.
israelillan
New Cone
New Cone
Posts: 8
Joined: 06 Oct 2016 09:37

Avoid using software decoder in android

Postby israelillan » 09 Jun 2018 20:45

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?

User avatar
InTheWings
Developer
Developer
Posts: 1275
Joined: 07 Aug 2013 13:15
VLC version: crashing
Operating System: Linux
Contact:

Re: Avoid using software decoder in android

Postby InTheWings » 10 Jun 2018 10:51

Isn't hw decoding on by default ?
:!: If you want your problem to be solved :
* First read troubleshooting guide VSG:Main
* Always provide verbose LOGS ! (command line or from gui)
* Always check your issue against a developer build from Nightly Build of VLC
* Tell us when your problem is solved !

israelillan
New Cone
New Cone
Posts: 8
Joined: 06 Oct 2016 09:37

Re: Avoid using software decoder in android

Postby israelillan » 10 Jun 2018 11:43

Thats what i thought, but i still get a software decoder

Rémi Denis-Courmont
Developer
Developer
Posts: 15267
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Avoid using software decoder in android

Postby Rémi Denis-Courmont » 10 Jun 2018 13:04

libvlc_video_set_callbacks() is incompatible with, and automatically disables hardware decoding.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

israelillan
New Cone
New Cone
Posts: 8
Joined: 06 Oct 2016 09:37

Re: Avoid using software decoder in android

Postby israelillan » 10 Jun 2018 13:57

I'm not using libvlc_video_set_callbacks, im using AWindow (libvlc_media_player_set_android_context)

israelillan
New Cone
New Cone
Posts: 8
Joined: 06 Oct 2016 09:37

Re: Avoid using software decoder in android

Postby israelillan » 13 Jun 2018 19:34

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

israelillan
New Cone
New Cone
Posts: 8
Joined: 06 Oct 2016 09:37

Re: Avoid using software decoder in android

Postby israelillan » 13 Jun 2018 19:35

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...

mfkl
Developer
Developer
Posts: 740
Joined: 13 Jun 2017 10:41

Re: Avoid using software decoder in android

Postby mfkl » 16 Jun 2018 08:11

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
https://mfkl.github.io

mfkl
Developer
Developer
Posts: 740
Joined: 13 Jun 2017 10:41

Re: Avoid using software decoder in android

Postby mfkl » 16 Jun 2018 08:18

I will gladly share the working code here when i get to a working code...
Please do. Unity is on the support roadmap.
https://mfkl.github.io


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 8 guests