Skip to first unread message

Adarsh Singh

unread,
Jun 26, 2020, 9:52:57 PM6/26/20
to Kivy users support
I have googled a lot but I could not find an example or blog to fulfill my requirement. 

I am trying to create an app using Kivy 1.11.1 using youtube-dl module in python3.8 Ubuntu 20.04 LTS. I am using buildozer to create apk from python source code which usage python-for-android to create apk. I have mentioned ffmpeg in buildozer requirements. I can see ffmpeg in pythonforandroid/recipes/. After installing form apk, when I try to print ffmpeg version using the following
merger = youtube_dl.postprocessor.FFmpegMergerPP()
merger._determine_executables()
print(merger.get_versions())
 these are some code snippets


@staticmethod
def get_versions(downloader=None):
return FFmpegPostProcessor(downloader)._versions
self._versions = dict(
(p, get_exe_version(self._paths[p], args=['-version']))
for p in programs)
def get_exe_version(exe, args=['--version'],
version_re=None, unrecognized='present'):
""" Returns the version of the specified executable,
or False if the executable is not present """
try:
out, _ = subprocess.Popen(
[encodeArgument(exe)] + args,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()
except OSError:
return False
if isinstance(out, bytes): # Python 2.x
out = out.decode('ascii', 'ignore')
return detect_exe_version(out, version_re, unrecognized)
 
 
I get this output
{'avprobe': False, 'avconv': False, 'ffmpeg': False, 'ffprobe': False} 

with this code

def test_ffmpeg():
try:
import subprocess
print(subprocess.check_output(['ffmpeg', '-version']))
except Exception as e:
print(e)
print('==> ffmpeg is not good :(, nooooooooooooo')
else:
print('==> ffmpeg is good :)')

test_ffmpeg()
I get this output
[Errno 13] Permission denied: 'ffmpeg'
==> ffmpeg is not good :(, nooooooooooooo
 

which indicate that ffmpeg in not installed in android


this line is included in my buildozer.spec
 
requirements = python3,kivy,ffmpeg,youtube_dl,kivymd,kivmob,ffpyplayer,ffpyplayer_codecs,ffmpeg-python

except ffmpeg rest all package are installed properly

I am not sure whether this is useful but I saw this in pythonforandroid/recipes/ffmpeg/__init__.py 
def build_arch(self, arch):
        with current_directory(self.get_build_dir(arch.arch)):
            env = arch.get_env()

            flags = ['--disable-everything']
 Goal : I want to use ffmpeg in youtube_dl via python3 after installing application from apk created by buildozer.

Please help. Even an project successfully install ffmpeg on android by python-for-android will be useful.

Thanks.

Robert Flatt

unread,
Jun 26, 2020, 11:36:33 PM6/26/20
to Kivy users support
which indicate that ffmpeg in not installed in android
 
I think this is not exacly correct, the ffmpeg libraries are installed, it is the ffmpeg executable that is not installed or built.
So trying to use an executable that is not there is not going to work.  :(

I don't know if it will work, but you could try creating a local copy of the recipe and commenting the flag I referenced in the link.
There may be additional work in the recipe to copy the executable to the apk?
Then unpack the apk to see where the executable actually is https://python-for-android.readthedocs.io/en/latest/troubleshooting/#unpacking-an-apk
In the app invoke ffmpeg using the relative path from main.pyc
I repeat I don't know if it will work, but it is something to try.

Adarsh Singh

unread,
Jun 30, 2020, 7:03:24 AM6/30/20
to kivy-...@googlegroups.com
Yes you were about generation of ffmpeg executable. After removing this line '--disable-programs'I can see binaries getting generated but they are not present in apk.

Please suggest how I should add to apk.

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/miDze3NQ5Ck/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/2a3c4d28-8f10-4e44-92d8-a461310e69d1o%40googlegroups.com.

Robert Flatt

unread,
Jun 30, 2020, 1:03:46 PM6/30/20
to Kivy users support
Just copyfile in the same was as a .so


There are some things that may happen that I don't know the answer to, please share what you find. Thanks.

Does the executable use dynamic linking? If so can it be moved from the .so directory?
Will Android allow execution? If not what is required to enable execution?
To unsubscribe from this group and all its topics, send an email to kivy-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages