Got the ffmpeg command line tool working on android today. I was working on a screenshot binary for android. And the way you take a screenshot on android is to cat /dev/graphics/fb0. Now this file is in RGB565 format [on Emulator]. Initially I managed it by pulling the file to my computer and then using ffmpeg to convert it to jpg. Though porting ffmpeg for android was not my initial idea, and it has already been done before. But I didn't find any ffmpeg binaries online that I could directly download and run over my phone. Therefore I decided to see if I could build it from source and it took me a couple of hours to get it working. The binary runs all the user commands except the common options like "-h","-v" [For some reason there was no definitions to cover those in the source I used]. You can download the binaries here [Need to copy the library 'libffmpeg.so' to the '/system/lib' folder]. I did, even copy the binary to my 'system/bin' so that I can comfortably run it from the shell.
To finish of the work I wrote a shell script to do rest of the work
#Shell script to take a screenshot
cat /dev/graphics/fb0 > /sdcard/raw-input
ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s 480x800 -i /sdcard/raw-input -f image2 -vcodec mjpeg /sdcard/screenshot.jpg
rm /sdcard/raw-input
echo "Screen shot saved at scard/screenshot.jpg"
I do know that there is an inbuilt screenshot binary in android that does the work instead of this lousy process. But I am working on something more interesting. To be revealed in the days to come.
Have fun with ffmpeg
Here are some screenshots that were pulled from the device
PS: I am not sure if it works on all versions of android. I've only tried it on KitKat...
To finish of the work I wrote a shell script to do rest of the work
#Shell script to take a screenshot
cat /dev/graphics/fb0 > /sdcard/raw-input
ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s 480x800 -i /sdcard/raw-input -f image2 -vcodec mjpeg /sdcard/screenshot.jpg
rm /sdcard/raw-input
echo "Screen shot saved at scard/screenshot.jpg"
I do know that there is an inbuilt screenshot binary in android that does the work instead of this lousy process. But I am working on something more interesting. To be revealed in the days to come.
Have fun with ffmpeg
Here are some screenshots that were pulled from the device
PS: I am not sure if it works on all versions of android. I've only tried it on KitKat...
Great. But many libraries like mp3 lame are missing. I would like to learn the contents on building the bin file so that I can use on my ffmpeg.so library for which I had tutorials but not creating a binary to execute.
ReplyDeleteThank you.