ffpyplayer icon indicating copy to clipboard operation
ffpyplayer copied to clipboard

Issue when accessing hardware h264 decoder

Open c0ff330k opened this issue 3 years ago • 2 comments

I am developing android app with kivy and ffpyplayer for watching video streams. But i'm using low performance hardware and getting lag on streams with 2500 bitrate and higher, so I decided to use hardware accelerated codecs like h264_v4l2m2m. I add 'vcodec': 'h264_v4l2m2m' parameter of MediaPlayer in kivy.core.video.video_ffpyplayer.py but get this issue:

12-28 00:44:29.802  2065  2138 I python  : [ERROR  ] [ffpyplayer  ] [h264_v4l2m2m @ 0x7b181c6100] can't configure decoder
12-28 00:44:29.803  2065  2138 I python  : [CRITICAL] [ffpyplayer  ] Failed to open file 'http://213.145.131.243:80/cam1/stream.m3u8' or configure filtergraph
12-28 00:44:29.787  2138  2138 W Thread-6: type=1400 audit(0.0:25): avc: denied { read } for name="/" dev="tmpfs" ino=7196 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:device:s0 tclass=dir permissive=0

I tried to change pixel format to 'yuv420p' but that didn't work. Also i tried to add WRITE_EXTERNAL_STORAGE permission to my buildozer.spec requirements and ask for the permission with android.permissions.request_permissions due to this line: 12-28 00:44:29.787 2138 2138 W Thread-6: type=1400 audit(0.0:25): avc: denied { read } for name="/" dev="tmpfs" ino=7196 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:device:s0 tclass=dir permissive=0 but still no any effect. ( or maybe Thread doesn't have access to that permission, but that's just my guess ) Any help please

c0ff330k avatar Dec 27 '22 20:12 c0ff330k

I found some information about this issue and it seems that W Thread-6: type=1400 audit(0.0:25): avc: denied { read } for name="/" dev="tmpfs" ino=7196 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:device:s0 tclass=dir permissive=0 is a SELinux denial. So SELinux blocks ffmpeg when trying to access the hardware codec but I don`t understand why this is happening.

c0ff330k avatar Dec 28 '22 09:12 c0ff330k

I tested hardware codecs on another android device with no SELinux installed and got this issue:

12-28 18:43:12.145  9268 10389 I python  : [ERROR  ] [ffpyplayer  ] [h264_v4l2m2m @ 0xcd16dc00] Could not find a valid device
12-28 18:43:12.146  9268 10389 I python  : [ERROR  ] [ffpyplayer  ] [h264_v4l2m2m @ 0xcd16dc00] can't configure decoder
12-28 18:43:12.147  9268 10389 I python  : [CRITICAL] [ffpyplayer  ] Failed to open file 'http://213.145.131.243:80/cam2/stream.m3u8' or configure filtergraph

So may be SELinux not a general problem. But on my windows pc the hardware codecs work fine with 'vcodec' parameter.

c0ff330k avatar Dec 28 '22 13:12 c0ff330k