Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[Linux] Take screenshots from Recovery with FFMPEG

OP ikslawlok

21st April 2014, 12:16 PM   |  #1  
ikslawlok's Avatar
OP Senior Member
Flag Lyon
Thanks Meter: 107
 
375 posts
Join Date:Joined: Jan 2012
More


Thanks to people behind FFMPEG, @makers_mark and his thread "[TOOL][WIN]Take screenshots of Aroma and Recovery v1.1" to gave us the correct command line in his script, and gave us the ability of taking screenshot from recovery on Linux.

I - Requirements

1 - ADB installed on your computer
Get the Android SDK

2 - Correct Nexus 5 USB ID's
Create android USB rules with your favorite text editor
Quote:

Kubuntu :

Code:
sudo kate /etc/udev/rules.d/51-android.rules

Quote:

Ubuntu :

Code:
gksudo gedit /etc/udev/rules.d/51-android.rules

Copy/Paste theses lines, and save it
Don't forget to change OWNER="your ubuntu username" with your Ubuntu/Linux username

Quote:

### Google Nexus 5
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee0", MODE="0666", OWNER="your ubuntu username"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee1", MODE="0666", OWNER="your ubuntu username"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", MODE="0666", OWNER="your ubuntu username"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee3", MODE="0666", OWNER="your ubuntu username"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee4", MODE="0666", OWNER="your ubuntu username"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee5", MODE="0666", OWNER="your ubuntu username"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee6", MODE="0666", OWNER="your ubuntu username"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d001", MODE="0666", OWNER="your ubuntu username"



3 - FFMPEG
To convert your raw framebuffer file into a *.png image file

Here, we will not install anything. We will just run the FFMPEG's executable to do what we want.
in this way, it does not affect our system.

Quote:
Originally Posted by Static FFmpeg builds

If you don't have time/will/knowledge to compile FFmpeg yourself and you just
want to download-and-run FFmpeg, then you've come to the right place!

This directory contains latest static builds of FFmpeg for testing purposes.
That means you can just download and run the executable.

3.1 - Download FFMPEG from ffmpeg.gusari.org


Depending of your distro :
64x : ffmpeg.static.64bit.latest.tar.gz
32x : ffmpeg.static.32bit.latest.tar.gz

3.2 Unarchive it where you want
I choose "/home/kowalski/.android/screenshot/ffmpeg.static.64bit.latest/"

II - Go into your recovery, plug yor Nexus 5 with the USB cable to your computer


III - Get your raw framebuffer file

In your console/terminal, enter the command

Code:
adb pull /dev/graphics/fb0 "your/directory/the_name_of_the_screenshot.raw"
I choose "/home/kowalski/.android/screenshot/raw/"

Code:
adb pull /dev/graphics/fb0 "/home/kowalski/.android/screenshot/raw/screenshot_01.raw"

See the result in console/terminal


See the result on your computer


IV - Go to the FFMPEG directory

In your console/terminal, enter the command

Code:
cd "FFMPEG directory"
For me :
Code:
cd /home/kowalski/.android/screenshot/ffmpeg.static.64bit.latest/

Then, in your console/terminal, enter the command

Quote:

according your directories, you have to change :
"your/directory/the_name_of_the_screenshot.raw"
and
"your/directory/the_name_of_the_screenshot.png"

./ffmpeg -loglevel debug -hide_banner -f rawvideo -vcodec rawvideo -pix_fmt rgb565 -s 1088x1920 -i "your/directory/the_name_of_the_screenshot.raw" -vf crop=1080:1920:0:0 -y "your/directory/the_name_of_the_screenshot.png"

For me :
Code:
./ffmpeg -loglevel debug -hide_banner -f rawvideo -vcodec rawvideo -pix_fmt rgb565 -s 1088x1920 -i "/home/kowalski/.android/screenshot/raw/screenshot_01.raw" -vf crop=1080:1920:0:0 -y "/home/kowalski/.android/screenshot/png/screenshot_01.png"

See the result on your cumputer


See the result on your cumputer


Some screenshots I made with this method :






Note 1 : The fact that English is not my native language, any help to correct it, will be appreciated.
Note 1 : The fact that I don't know very well FFMPEG's command line, I have two errors (but it works !) :

Quote:

[rawvideo @ 0x3e0f360] Invalid buffer size, packet size 65536 < expected frame_size 4177920
Error while decoding stream #0:0: Invalid argument

Quote:

[image2 @ 0x3e0fca0] Could not get frame filename number 2 from pattern '/home/kowalski/.android/screenshot/png/screenshot_01.png' (either set updatefirst or use a pattern like %03d within the filename pattern)av_interleaved_write_frame(): Invalid argument

Any help to correct these errors, will be appreciated.
Last edited by ikslawlok; 21st April 2014 at 12:23 PM.
The Following 2 Users Say Thank You to ikslawlok For This Useful Post: [ View ]
21st April 2014, 12:49 PM   |  #2  
blinqipa's Avatar
Senior Member
Flag Kosova
Thanks Meter: 362
 
797 posts
Join Date:Joined: Aug 2012
More
First!
Thanks for this feature

Sent from my Nexus 5 using XDA Premium 4 mobile app
21st April 2014, 01:31 PM   |  #3  
aheeejd's Avatar
Senior Member
Flag off the coast o the kontiki!
Thanks Meter: 1,345
 
3,053 posts
Join Date:Joined: Jan 2012
More
Or, you can use philz recovery, go to philz settings, GUI preferences & set it however you want. I have mine set to "slide left" & bingo, a screenshot in/of recovery. Just saying.

Sent from my Nexus 5 using Xparent BlueTapatalk 2
Attached Thumbnails
Click image for larger version

Name:	uploadfromtaptalk1398079914360.jpg
Views:	162
Size:	36.0 KB
ID:	2699674  
The Following 3 Users Say Thank You to aheeejd For This Useful Post: [ View ]
28th June 2014, 04:19 PM   |  #4  
makers_mark's Avatar
Senior Member
Flag Kings Mountain
Thanks Meter: 162
 
116 posts
Join Date:Joined: Sep 2013
More
Quote:
Originally Posted by ikslawlok

Note 1 : The fact that English is not my native language, any help to correct it, will be appreciated.
Note 1 : The fact that I don't know very well FFMPEG's command line, I have two errors (but it works !) :



Any help to correct these errors, will be appreciated.

If you change your command to:
Code:
./ffmpeg -loglevel fatal -hide_banner -f rawvideo -vcodec rawvideo -pix_fmt rgb565 -s 1088x1920 -i "/home/kowalski/.android/screenshot/raw/screenshot_01.raw" -vf crop=1080:1920:0:0 -y "/home/kowalski/.android/screenshot/png/screenshot_01.png"
By interchanging `-loglevel debug` with `-loglevel fatal` you will only receive console messages to inform you of program stopping (fatal) errors. If you still want to see more output from the ffmpeg console, which by the way is all written to stderr, you may try `-loglevel verbose` which is the same as not setting a loglevel at all. Using `-loglevel debug` shows everything in the console.

Quote:
Originally Posted by aheeejd

Or, you can use philz recovery, go to philz settings, GUI preferences & set it however you want. I have mine set to "slide left" & bingo, a screenshot in/of recovery. Just saying.

Sent from my Nexus 5 using Xparent BlueTapatalk 2

With all due respect, the reasons a person would find him/herself wanting to take a screenshot while in recovery mode are very limited. You have themers, people writing tutorials, and maybe someone who can't describe what may be going on in there situation. Having said that, having a screenshot option in just one of those recoveries isn't a viable solution for someone who made a theme for twrp, or .... you get the point.

Side note: back when the OP was searching for a way to pull his screenshot, it didn't even work in Philz because the stride wasn't properly accounted for in fb2png until this commit on 3/22/14.
28th June 2014, 05:25 PM   |  #5  
ikslawlok's Avatar
OP Senior Member
Flag Lyon
Thanks Meter: 107
 
375 posts
Join Date:Joined: Jan 2012
More
Thank you makers_mark

TWRP now includes screenshot feature. So it is a best way to do it.
The Following User Says Thank You to ikslawlok For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes