0

This link http://www.roman10.net/how-to-port-ffmpeg-the-program-to-androidideas-and-thoughts/ talks about port ffmpeg command to Android.

Can anyone describe more detail?

My purpose is to record user's behavior on Android device and save as video file which contains user's sound.

user1429903
  • 31
  • 1
  • 4

2 Answers2

1

Build FFMPEG for android as a shard library and using Android NDK use this in your android application, for this you don't need a root permission on device. It works like other buils library.

Look at this SO Question FFMPEG on Android

Community
  • 1
  • 1
user370305
  • 103,719
  • 23
  • 157
  • 149
  • I already build the library and translate it to JNI. Call main function of ffmpeg.c. But capturing screen needs to read /dev/graphics/fb0. I can change the permission of /dev/graphics/fb0 in emulator but I can not change in device. Your sample just plays video. It does not read /dev/graphics/fb0. – user1429903 Jun 20 '12 at 10:49
  • First of all, I didn't knew it for take screen shot using framebuffer. Ok now for this you have to root permission for device (Without root its not possible). Also you have a read permission on framebuffer. Try it with chmod 777 .. – user370305 Jun 20 '12 at 10:55
  • @user1429903 i m onto similar problem. i want to run ffmpeg commands on android. if i just call a main of ffmpeg.c will i be able to use ffmpeg commands on android??? what do i need to put in main of ffmpeg.c so that i can run commands? do i have to build executables? can u give some reference? Roman10 blog is not helping me, – Chaitanya Chandurkar Sep 10 '12 at 19:17
0

FB file /dev/graphics/fb0 is owned by root and group is set to graphics. Since regular android apps do not belong to the graphics group, they cannot read it.

To fix this you could make a native application (not a JNI one, but a native executable) that uses the ffmpeg libraries (statically), and get it installed via ADB using $adb push command. This binary will be owned by the 'shell' id but it will belong to the graphics group. And so this will have access to read the FB directly.

You could code your Java app to talk to this binary (via say sockets) and control things from it. ASL (Android Screenshot Library) does something similar but does not use ffmpeg but captures screen shots directly. Refer to http://code.google.com/p/android-screenshot-library/

  • **native executable** can you brief this? – user370305 Sep 11 '12 at 07:29
  • native executable - this is a regular linux application (typically a C/C++ based one) that is built to run directly at the linux layer. Refer to [here][http://www.kandroid.org/ndk/docs/STANDALONE-TOOLCHAIN.html] for how to use the NDK toolkit for Android as a regular compiler and generate standalone binaries that can be run directly at the linux layer. After building the binary, use 'adb push' to copy the binary onto the android device (typically /data/local or /data/local/tmp on 4.x system) and then use 'adb shell ' to run it – Kumar Rangarajan Dec 04 '12 at 00:56
  • I knew it. Actually I just want to differentiate it with regular `.so` files for SO perspective. Anyway Thanks. – user370305 Dec 04 '12 at 08:34
  • Oh okie. The primary difference between the two approaches is the permission with they run. If you build an SO and load it via JNI in your app, the SO also runs with the same privilege level as your app, which is very limited (eg: you cannot read the frame buffer). But if you build a native executable and install it via 'adb push' onto the device and run it, you will run as a 'shell' user and belong the graphics group, and have better permissions (eg: to read the frame buffer). – Kumar Rangarajan Dec 05 '12 at 05:22
  • Yes,I have applied the same thing in my one of project. For Android device screen share application. :-) – user370305 Dec 05 '12 at 06:13