• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[TOOL][WIN][v1.5]Take Screenshots in Recovery & Aroma - All devices

Search This thread

makers_mark

Senior Member
Sep 21, 2013
192
476
Kings Mountain
This is a tool to capture screenshots while in Recovery or the Aroma Installer.

Your Recovery MUST have ADB enabled or no matter what you do you'll NEVER pull a Screenshot

v1.5
Feb 9, 2014
-Total rewrite of structure and function
-Added check for framebuffer in /dev/fb0
-Added a manual mode where you don't have to have ADB connected as long as you have a file
-Added loops for every pixel format supported as input for FFmpeg
-Added folders for pngs to go into when they are rendered
-Added the option to convert both framebuffers into two seperate images; or grab the top or botom images​

One big problem people are having when trying to capture screenshots in recovery, on some devices, is the extra framebuffer info that is tacked on to the end of each pixel row. Through a lot of digging and not finding too much information on it, I've finally found a way to determine what dimensions to use for, I believe, all android devices.

Fb2png is a great open source program, but unfortunately it only works with framebuffers that don't have a stride. FFmpeg is what I use here. FFmpeg is a great open source command line transcoder. It's pretty hefty and can do a vast amount of conversions (audio/video/codecs/images) all from the command line. They are two different beasts with, Fb2png made for the sole purpose of grabbing the framebuffer then converting it into a png file. While FFmpeg is more of a computer side program, and you tell it exactly what you want it to do.

Dealing with the framebuffer we are dealing with raw data. There is 0 extra information in this file, no line size, title, header, no nothing except a continuous write of pixel data. That's great for guessing the exact file size, and that's about it. But to get it to a view-able image, you have to specify where each line starts/stops, and convert the pixel format to whatever you want to use, your file-type.

I found that if you divide your width; the Nexus 5 for example is 1080; by 32, your stride will equal the value to add to that 1080 to go up and make it evenly divisible by 32. The next number up from 1080 that is evenly divisible by 32 is 1088, and those 8 extra pixels is your stride. Height is not as important, as far as what we are doing, simply because everything is read left to right, then advance down. Resolution being divisible by 32, or MOD 32 to graphics people, is becoming not as common on devices nowadays, AND those are the devices fb2png gives distorted screenshots with. Maybe @Phil3759 knows how to fix this for fb2png.

I made this batch script that takes into account your stride, if you have one. If your width is 768 for example, you won't have one because 32 goes into 768 an even 24 times.

You can also use manual mode and use any raw image you have saved.
Please read the instructions below.

Recovery Screenshot v1.5 batch script
Code:
@ECHO OFF
IF NOT EXIST ffmpeg.exe CALL :NOFILES
IF NOT EXIST adb.exe CALL :NOFILES
CLS
SETLOCAL
SET pixfmt=""
SET FINAME=frmbfr
:TOP
	TITLE Recovery Screenshot v1.5 For all devices.
	MODE CON:COLS=60 LINES=48
	COLOR 0B
	ADB kill-server -d >nul 2>&1
	SET "ffshowb=-hide_banner"
	SET "ffdebug=-loglevel fatal"
	IF "%~1"=="-d" (
		REM @ECHO ON
		SET "ffdebug=-loglevel debug"
		SET "ffshowb=%"
		MODE CON:COLS=140 LINES=250
		COLOR 07
		ECHO ______________________________________________________
		ECHO DEBUG INFO
		ECHO ______________________________________________________
	)
IF NOT EXIST "settings.cfg" GOTO CHECK 
IF EXIST "settings.cfg" GOTO MAINMENU
:CHECK
	CALL :DRAWHEAD
	ECHO[
	ECHO You don't have a configuration set up...
	ECHO[
	ECHO Please choose 1 or 2
	ECHO[
	ECHO 1 - Make a configurations setting
	ECHO[
	ECHO 2 - Manual Mode
	ECHO[
	CHOICE /C:12
	IF ERRORLEVEL 1 SET K=1
	IF ERRORLEVEL 2 SET K=2
	IF %K%==1 GOTO SETTINGS
	IF %K%==2 CALL :MANUALMODE

:MAINMENU
	CALL :LOADCONFIG
	ECHO[
	ECHO Your Settings are....
	ECHO Native Resolution %width%X%height% 
	ECHO Stride=%stride%
	ECHO Pixel Format=%pixfmt%
	ECHO Save Folder for screenshots is ^"%DATE:/=-%\^"
	CALL :DRAWHEAD
	ECHO Please choose one of the following...
	ECHO[
	ECHO 1 - Get the top framebuffer.
	ECHO[
	ECHO 2 - Get the bottom framebuffer.
	ECHO[
	ECHO 3 - Get both framebuffers.(2 images)
	ECHO[
	ECHO 4 - Reset your settings.
	ECHO[
	ECHO 5 - Manual Mode!
	ECHO[
	ECHO 6 - Exit
	ECHO[
	CHOICE /C:123456
		IF ERRORLEVEL 1 SET K=1
		IF ERRORLEVEL 2 SET K=2
		IF ERRORLEVEL 3 SET K=3
		IF ERRORLEVEL 4 SET K=4
		IF ERRORLEVEL 5 SET K=5
		IF ERRORLEVEL 6 SET K=6
		IF %K%==1 (CALL :GETFBO
			CALL :UPPERGET)
		IF %K%==2 (CALL :GETFBO
			CALL :LOWERGET)
		IF %K%==3 (CALL :GETFBO
			CALL :UPPERGET)
		IF %K%==4 GOTO SETTINGS
		IF %K%==5 GOTO MANUALMODE
		IF %K%==6 GOTO FINISH
		CLS
	GOTO MAINMENU

:UPPERGET
	CALL :SSNAMINGCONVENTION
	SET stoy=" -s %widthwithstride%x%height% -i %FINAME% -vframes 1 -vf crop=%width%:%height%:0:0 -y %folderdate%\%TS%"
	CALL :TRANSCODE %stoy%
	ECHO[
	ECHO SCREENSHOT SAVED AS %folderdate%\%TS%	
	IF %K%==3 GOTO :LOWER
	DEL frmbfr
	ECHO Press any key to continue to menu...
	PAUSE >NUL & CLS
	GOTO :EOF

:LOWERGET
	CALL :SSNAMINGCONVENTION
	:LOWER	
	SET /a "cheight=2 * height"
	SET stoy=" -s %widthwithstride%x%cheight% -i %FINAME% -vframes 1 -vf crop=%width%:%height%:0:%height% -y %folderdate%\%TSL%"
	CALL :TRANSCODE %stoy%
	ECHO SCREENSHOT SAVED AS %folderdate%\%TSL%
	DEL frmbfr
	ECHO Press any key to continue to menu...
	PAUSE>NUL & CLS
	GOTO MAINMENU

:TRANSCODE
	FFMPEG %ffdebug% %ffshowb% -f rawvideo -vcodec rawvideo -pix_fmt %pixfmt% %~1 || GOTO FFHELP "-loglevel debug -f rawvideo -vcodec rawvideo -pix_fmt %pixfmt% %stoy%
	GOTO :EOF

:GETLOTSOFPNGS
	FOR /D %%A IN (%pixfmt%) DO CALL FFMPEG %ffshowb% %ffdebug% -f rawvideo -vcodec rawvideo -pix_fmt %%A -s %widthwithstride%x%height% -i %FINAME% -vframes 1 -vf crop=%width%:%height%:0:0 -y Pixel_formats\%%A%TS% || GOTO FFHELP LOTSOFPPNGS
	GOTO :EOF

:LOADCONFIG
	FOR /F "tokens=1,2,3,4,5,6" %%A IN (settings.cfg) DO CALL :PROCESS %%A %%B %%C %%D %%E %%F || GOTO :SETTINGS
	GOTO :EOF

:PROCESS
	SET width=%1
	SET height=%2
	SET stride=%3
	SET widthwithstride=%4
	SET fb0size=%5
	SET pixfmt=%6
	GOTO :EOF

:SETTINGS
	IF EXIST settings.cfg DEL settings.cfg
	IF NOT EXIST Pixel_formats\ MKDIR Pixel_formats\
	DEL Pixel_formats\*.png
	CLS
	CALL :DRAWHEAD
	ECHO[
	ECHO[
	ECHO Settings
	ECHO[
	ECHO Enter your screen width...
	ECHO[
	SET /P width=Width?
	ECHO[
	ECHO Enter your screen height...
	ECHO[
	SET /P height=Height?
	CALL :GETFBO
	CALL :DOMATH
	SET "pixfmt=rgb565,rgb565be,bgr24,rgb24,rgb32,argb,rgba,abgr,bgra,0rgb,rgb0,0bgr,bgr0,gbrp"
	SET TS=%_%.png
	ECHO[
	ECHO[
	ECHO Generating test images......
	ECHO They will be in the folder 'Pixel_formats'
	ECHO[
	CALL :GETLOTSOFPNGS
	ECHO[
	ECHO[
	ECHO Check the folder and make a note of the filename of the
	ECHO correct screenshot.
	ECHO[
	ECHO Press any key to continue..
	PAUSE >NUL
	CLS
	CALL :DRAWHEAD
	ECHO[
	ECHO Please select a menu number...
	ECHO[
	ECHO 1 - You see your image...
	ECHO[	
	ECHO 2 - Don't see your image..use more formats..?
	ECHO[
	ECHO 3 - Enter Manual Mode to try your own settings.
	ECHO[
	ECHO 4 - Exit
	ECHO[
	CHOICE /C:1234
	IF ERRORLEVEL 1 SET K=1
	IF ERRORLEVEL 2 SET K=2
	IF ERRORLEVEL 3 SET K=3
	IF ERRORLEVEL 4 SET K=4
	IF %K%==1 GOTO INPUTPFMT
	IF %K%==2 (DEL Pixel_formats\*.png
		ECHO[
		CALL :1TO2BYTESPP
		ECHO GETTING 1 ^& 2 BYTE/pp formats..
		CALL :GETLOTSOFPNGS
		ECHO[
		CALL :3BYTESPP
		ECHO .Getting 3 Byte/pp formats..
		CALL :GETLOTSOFPNGS
		ECHO[
		CALL :4BYTESPP
		ECHO ..Getting 4 Byte/pp formats..
		CALL :GETLOTSOFPNGS
		ECHO[
		CALL :5BYTESPP
		ECHO ...Getting 5 Byte/pp formats..
		CALL :GETLOTSOFPNGS
		ECHO[
		CALL :6TO8BYTESPP
		ECHO ....Getting 6 ^& 8 Byte/pp formats..
		CALL :GETLOTSOFPNGS
		ECHO[)
	IF %K%==3 CALL :MANUALMODE
	IF %K%==4 GOTO FINISH
	CLS
	CALL :DRAWHEAD
	ECHO[
	ECHO Please select a menu number...
	ECHO[
	ECHO 1 - You found your screenshot.
	ECHO[
	ECHO 2 - You didn't find your screenshot.
	ECHO[
	ECHO 3 - Enter Manual Mode to try your own settings.
	ECHO[
	ECHO 4 - Exit
	ECHO[
	CHOICE /C:1234
	IF ERRORLEVEL 1 SET K=1
	IF ERRORLEVEL 2 SET K=2
	IF ERRORLEVEL 3 SET K=3
	IF ERRORLEVEL 4 SET K=4
	IF %K%==1 GOTO INPUTPFMT
	IF %K%==2 CALL :HELP
	IF %K%==3 GOTO MANUALMODE
	IF %K%==4 GOTO FINISH
	GOTO :EOF

:HELP
	REN frmbfr Framebuffer.raw
	REM MODE CON:COLS=80 LINES=68
	ECHO[
	ECHO[
	ECHO[
	ECHO[
	ECHO If you don't have a valid/correct screenshot in your "Pixel_formats\ folder
	ECHO something has happened.  I would really appreciate it if you would upload it
	ECHO so I could try and find the problem. 
	ECHO[
	ECHO http://forum.xda-developers.com/showthread.php?t=2635736
	ECHO[
	ECHO There is absolutely no harm in doing this, because the only data stored in it
	ECHO is pixel data, that is unless you had something private on your screen;
	ECHO then you can keep your framebuffer!
	ECHO[
	ECHO I have named your framebuffer...'Framebuffer.raw' in 
	ECHO %~dp0
	ECHO Thank You for trying!
	ECHO[
	ECHO Press any key to exit...
	PAUSE >NUL
	GOTO FINISH

:DRAWHEAD
	ECHO[
	ECHO _________________________________________________________-_-
	ECHO[
	ECHO                   Recovery Screenshot v1.5
	ECHO[
	ECHO ____________________________________________________________
	ECHO[
	ECHO             Thanks to Whiskey103 for the idea!!
	ECHO                  Written by makers_mark
	ECHO[
	ECHO ____________________________________________________________
	GOTO :EOF

:INPUTPFMT
	CLS
	CALL :DRAWHEAD
	ECHO[
	ECHO Please enter the pixel format to use.
	ECHO[
	ECHO YOU MUST USE LOWERCASE LETTERS!
	ECHO[
	ECHO ____________________________________________________________
	ECHO Example: If the filename of the image, that is correct, is 
	ECHO          rgb565.png
	ECHO          Then you would enter 'rgb565'
	ECHO ____________________________________________________________
	ECHO[
	ECHO[	
	SET /p pixfmt=Pixel format?
	CALL :WRITETOFILE %width% %height% %stride% %widthwithstride% %fb0size% %pixfmt%
	DEL frmbfr
	CLS
	GOTO MAINMENU
		
:SSNAMINGCONVENTION
	SET folderdate=%DATE:/=-%
	SET folderdate=%folderdate: =%
	IF NOT EXIST "%folderdate%\" MKDIR "%folderdate%\"
	SET TS=%TIME::=_%
	SET TS=%TS:.=%
	SET TS=%TS: =%
	SET TSL=%TS%
	SET TS=%TS%upper.png
	SET TSL=%TSL%lower.png
	GOTO :EOF

:DOMATH
	SET /a "stride=width %% 32"
	IF %stride% NEQ 0 SET /a "stride=32 - stride"
	SET /a "widthwithstride=stride + width"
	FOR /F "usebackq" %%A IN ('frmbfr') DO set fb0size=%%~zA
	GOTO :EOF

:GETFBO
	CLS
	CALL :DRAWHEAD
	ECHO[
	ECHO[
	ECHO Pulling Framebuffer from your device.....
	ECHO[
	ADB kill-server -d >NUL 2>&1
	ADB pull /dev/graphics/fb0 frmbfr>NUL 2>&1 || ADB pull /dev/fb0 frmbfr>NUL 2>&1
	IF ERRORLEVEL 1 (cls
		ECHO ______________________________________________________
		ECHO Adb is not properly connected.
		ECHO Try "Safely Removing" your device from your computer
		ECHO Then unplug your usb cable, and reinsert it.
		ECHO ______________________________________________________
		ECHO[
		ECHO[
		ECHO Press any key to try again.
		ECHO[
		ECHO[
		PAUSE >nul
		CLS
		GOTO GETFBO)
GOTO :EOF


:WRITETOFILE
	ECHO %~1 %~2 %~3 %~4 %~5 %~6 > settings.cfg
	GOTO :EOF

:FFHELP
	MODE CON:COLS=108 LINES=200
	COLOR 07
	FFMPEG %~1
	echo WIDTH=%width%
	echo HEIGHT%height%
	ECHO STRIDE=%stride%
	ECHO Pixel Format is %pixfmt%
	echo S to Y=%stoy%
	echo Width with stride=%widthwithstride%
	ECHO K=%K%
	ECHO FINAME=%FINAME%
	echo[
	echo %1
	echo %~1
	echo[
	ECHO There was an error in ffmpeg.
	PAUSE >NUL 
GOTO FINISH

:MANUALMODE
	IF NOT EXIST Manual_mode\ MKDIR Manual_mode\
	CLS
	ECHO[
	ECHO _________________________________________________________-_-
	ECHO                        MANUAL MODE!
	ECHO[
	CALL :DRAWHEAD
	ECHO[
	ECHO I DO NOT ACCOUNT FOR STRIDE IN THIS MODE!
	ECHO[
	ECHO YOUR WIDTH YOU INPUT WILL BE THE PIXEL THAT TELLS
	ECHO FFMPEG TO GO TO THE NEXT LINE!
	ECHO[
	ECHO TIP: IF YOU ARE WORKING WITH A FRAMEBUFFER, DOUBLE YOUR 
	ECHO HEIGHT, TO GET THE DOUBLE FRAMEBUFFER. 
	ECHO[ 
	SET /p width=Width?
	ECHO[
	SET /p height=Height?
	ECHO[
	SET "widthwithstride=width"
	ECHO ENTER THE FILENAME OF THE RAW IMAGE YOU
	ECHO WANT TO LOAD...
	ECHO[
	ECHO JUST PRESS ENTER TO USE ADB TO PULL FRAMEBUFFER
	ECHO[
    :NONEXIST
	SET /p FINAME=Filename? || SET FINAME=usefb
	IF %FINAME%==usefb CALL :GETFBO
	IF %FINAME%==usefb (SET FINAME=frmbfr
		GOTO MANUALMODEIN)
	IF EXIST %FINAME% GOTO MANUALMODEIN
	IF NOT EXIST %FINAME% (
		ECHO FILE, %FINAME% DOESN'T EXIST.
		GOTO NONEXIST)

:MANUALMODEIN
	CLS
	ECHO[
	ECHO _________________________________________________________-_-
	ECHO                        MANUAL MODE!
	ECHO[
	ECHO FILE= %FINAME%
	IF %FINAME%==frmbfr ECHO       ^^^^^^^^^^^^THAT IS YOUR DEVICES FRAMEBUFFER!
	ECHO[
	ECHO WIDTH= %width%    HEIGHT= %height%
	ECHO[
	ECHO Please select the Pixel Formats to use.
	ECHO I've grouped them in sets of Bytes Per Pixel
	ECHO[
	ECHO Please choose one of the following...
	ECHO[
	ECHO 1 - ALL FORMATS!
	ECHO[
	ECHO 2 - 2 Bpp
	ECHO[
	ECHO 3 - 3 Bpp
	ECHO[
	ECHO 4 - 4 Bpp
	ECHO[
	ECHO 5 - 5 Bpp
	ECHO[
	ECHO 6 - 6 ^& 8 Bpp
	ECHO[
	ECHO 7 - Start Manual mode over (new WxH and file)
	ECHO[
	ECHO 8 - Go to regular mode.
	ECHO[
	ECHO 9 - EXIT
	CHOICE /C:123456789
	IF ERRORLEVEL 1 SET K=1
	IF ERRORLEVEL 2 SET K=2
	IF ERRORLEVEL 3 SET K=3
	IF ERRORLEVEL 4 SET K=4
	IF ERRORLEVEL 5 SET K=5
	IF ERRORLEVEL 6 SET K=6
	IF ERRORLEVEL 7 SET K=7
	IF ERRORLEVEL 8 SET K=8
	IF ERRORLEVEL 9 SET K=9
	IF %K%==1 (CALL :MMNAMINGCONVENTION
		CALL :2BPP
		CALL :3BPP
		CALL :4BPP
		CALL :5BPP
		CALL :6BPP
		ECHO[
		ECHO DONE!
		ECHO[
		ECHO Press any key to continue..
		PAUSE>NUL
		GOTO MANUALMODEIN)
	IF %K%==2 (CALL :MMNAMINGCONVENTION
		CALL :2BPP
		ECHO[
		ECHO DONE!
		ECHO[
		ECHO Press any key to continue..
		PAUSE >NUL
		GOTO MANUALMODEIN)
	IF %K%==3 (CALL :MMNAMINGCONVENTION
		CALL :3BPP
		ECHO[
		ECHO DONE!
		ECHO[
		ECHO Press any key to continue..
		PAUSE >NUL
		GOTO MANUALMODEIN)
	IF %K%==4 (CALL :MMNAMINGCONVENTION
		CALL :4BPP
		ECHO[
		ECHO DONE!
		ECHO[
		ECHO Press any key to continue..
		PAUSE >NUL	
		GOTO MANUALMODEIN)
	IF %K%==5 (CALL :MMNAMINGCONVENTION
		CALL :5BPP
		ECHO[
		ECHO DONE!
		ECHO[
		ECHO Press any key to continue..
		PAUSE >NUL	
		GOTO MANUALMODEIN)
	IF %K%==6 (CALL :MMNAMINGCONVENTION
		CALL :6BPP
		ECHO[
		ECHO DONE!
		ECHO[
		ECHO Press any key to continue..
		PAUSE >NUL	
		GOTO MANUALMODEIN)
	IF %K%==7 (DEL frmbfr >NUL
		GOTO MANUALMODE)
	IF %K%==8 (DEL frmbfr >NUL 2>&1
		GOTO TOP)
	IF %K%==9 (DEL frmbfr >NUL 2>&1
		GOTO FINISH)
	GOTO MANUALMODEIN
:2BPP
	ECHO[
	ECHO CONVERTING 1 ^& 2 Byte/pp IMAGES!
	ECHO[
	CALL :MMNAMINGCONVENTION
	CALL :1TO2BYTESPP
	CALL :MAKEPNGSMM
	ECHO IMAGES SAVED IN 'Manual_mode\' FOLDER
	ECHO[
	GOTO :EOF

:3BPP
	ECHO[
	ECHO ..CONVERTING 3 BYTE/PP IMAGES!
	ECHO[
	CALL :3BYTESPP
	CALL :MAKEPNGSMM
	ECHO IMAGES SAVED IN 'Manual_mode\' FOLDER
	ECHO[	
	GOTO :EOF

:4BPP
	ECHO[
	ECHO ...CONVERTING 4 BYTE/PP IMAGES!
	ECHO[
	CALL :4BYTESPP
	CALL :MAKEPNGSMM
	ECHO IMAGES SAVED IN 'Manual_mode\' FOLDER
	ECHO[
	GOTO :EOF
:5BPP
	ECHO[
	ECHO ....CONVERTING 5 BYTE/PP IMAGES!
	ECHO[
	CALL :5BYTESPP
	CALL :MAKEPNGSMM
	ECHO IMAGES SAVED IN 'Manual_mode\' FOLDER
	ECHO[
	GOTO :EOF
:6BPP
	ECHO[
	ECHO ....CONVERTING 6 ^& 8 BYTE/PP IMAGES!
	ECHO[
	CALL :6TO8BYTESPP
	CALL :MAKEPNGSMM
	ECHO IMAGES SAVED IN 'Manual_mode\' FOLDER
	ECHO[
	GOTO :EOF

:MAKEPNGSMM
	FOR /D %%A IN (%pixfmt%) DO CALL FFMPEG %ffshowb% %ffdebug% -f rawvideo -vcodec rawvideo -pix_fmt %%A -s %width%x%height% -i %FINAME% -vframes 1 -y Manual_mode\%%A_%width%X%height%_%TS% || GOTO FFHELP
	GOTO :EOF
:1TO2BYTESPP
	SET "pixfmt=yuv410p,gray,monow,monob,pal8,bgr8,bgr4_byte,rgb8,rgb555be,rgb555le,bgr555be,bgr555le,yuv420p10be,yuv420p10le,yuv420p9be,yuv420p9le,yuv420p,yuv411p,yuv420p,nv12,nv21,rgb444le,rgb444be,bgr444le,bgr444be,yuvj411p,yuyv422,yuv422p,yuvj422p,uyvy422,gray16be,gray16le,yuv440p,yuvj440p,rgb565be,rgb565le,bgr565be,bgr565le,gray8a"
	GOTO :EOF
:3BYTESPP
	SET "pixfmt=rgb24,bgr24,yuv444p,yuvj444p,yuva420p,yuv420p16le,yuv420p16be,yuv422p10be,yuv422p10le,yuv422p9be,yuv422p9le,yuva420p9be,yuva420p9le,gbrp,0rgb,rgb0,0bgr,bgr0,yuva422p,yuv420p12be,yuv420p12le,yuv420p14be,yuv420p14le,yuv422p12be,yuv422p12le"
	GOTO :EOF
:4BYTESPP
	SET "pixfmt=argb,rgba,abgr,bgra,yuv422p16le,yuv422p16be,yuv444p9be,yuv444p9le,yuv444p10be,yuv444p10le,gbrp9be,gbrp9le,gbrp10be,gbrp10le,gbrp9be,gbrp9le,gbrp10be,gbrp10le,yuva422p9be,yuva422p9le,yuva420p10be,yuva420p10le,yuva422p10be,yuva422p10le,yuva444p,yuv422p14be,yuv422p14le,gbrap"
	GOTO :EOF
:5BYTESPP
	SET "pixfmt=yuva444p9be,yuva444p9le,yuva444p10be,yuva444p10le,yuva420p16be,yuva420p16le,xyz12le,xyz12be,yuv444p12be,yuv444p12le,gbrp12be,gbrp12le"
	GOTO :EOF
:6TO8BYTESPP
	SET "pixfmt=rgb48be,rgb48le,yuv444p16le,yuv444p16be,bgr48be,bgr48le,gbrp16be,gbrp16le,yuva422p16be,yuva422p16le,yuv444p14be,yuv444p14le,gbrp14be,gbrp14le,yuva444p16be,yuva444p16le,rgba64be,rgba64le,gbrap16be,gbrap16le"
	GOTO :EOF

:MMNAMINGCONVENTION
	SET TS=%TIME::=_%
	SET TS=%TS:.=%
	SET TS=%TS: =%.png
	GOTO :EOF

:FINISH
	ADB kill-server -d >nul 2>&1
	ENDLOCAL
	EXIT

Instructions:
If you have already downloaded a previous version, you do not have to download everything again. The bat file is the only difference between any of the versions. You can copy the script up above for v1.5 and edit the one you already have in Notepad, or any other text editor; Paste the new version in there and save it. And thats it.
Download Recovery Screenshot v1.5
Extract it to a new folder.
You will have the programs FFmpeg & ADB.
Two .dll files for ADB. And the batch script RUNrs.bat
I assume you have your ADB drivers squared away!!

Reboot into your recovery.
Run RUNrs.bat and it will ask you if you want to set up a configuration or go into manual mode.
If you have ADB good and ready to go, I would reccommend going ahead and setting up your configuration now.
Enter you native resolution, with width being the short side! Don't adjust for stride either. Your native resolution should be entered.
It will then pull the framebuffer, and convert it into several pngs with different pixel formats.
Go to the folder "Pixel_formats" and look through them and make note of the correct one, specifically the filename of the correct one.
If you see your image, then hit "1" to input the name of the pixel format (which is the name of the png that is right)
If you don't see your screenshot in that folder hit "2" and it will generate a bunch more from various pixel formats.
Look through those, it might take some time LOL, and see if you can skip over the cool looking ones until you see yours.
Hit 1 and go input it.
From there you are good to go. You'll see your configuration in the upper left corner of the main menu window, and it will be persistent when you close the program out. You have the option to grab both framebuffers with this version. You are probably wandering why there's two. Well android uses a double framebuffer. Have you ever noticed that sometimes when you got a screenshot before, it will be a previous screen on there? Android has one screen that is displayed, and another one adjacent to it (they are butted top to bottom) that is meant for drawing on (really quick I might add). The idea behind that (on a fast scale) is: When the device switches to a new frame, the device can render the next screen in a different buffer while the current screen stays displayed. And then pop up that screen when it is ready. If it didn't do that, and used just one framebuffer, then when you go to a different screen, the new screen would have to be processed and drawn over the old screen and just wouldn't look as good. When ANY little bit of information changes on you screen, yes even the minute number on the clock, it draws it quickly and swaps the two buffers. So now all of the sudden your main framebuffer is opposite what it was before. And the other one is the artboard.

Manual mode does not take into account stride. It is just a tool to convert any raw image into pngs, and at the same time figure out what pixel format something, like a splash screen, might be. You don't have to have ADB enabled to use it. You can use a file of you own, just place it in the main folder, and after you supply the width and height, input the file name. If you just press enter instead, it will pull you framebuffer, and you will need ADB for that.

In Manual mode you can select between different pixel formats grouped by Bytes per pixel (1&2 Byte/pp, 3Bpp, 4Bpp, 5Bpp, and 6&8 Byte/pp)
Or you can run them all. If you run into errors with FFmpeg in manual mode, try not to seek too far down with your height in the resolution selection. If you overshoot the expected filesize looking for data, FFmpeg will not convert it.

Notes:
If you change your recovery, you may have to clear the settings, it depends if there is a different pixel format. You can do so easily in the program, or you can just delete 'settings.cfg'

Sometimes your screenshot may seem disorganized or torn. This may happen when the very first screen is drawn, and also in between framebuffer swaps and writes. This is totally normal. This tool grabs your current framebuffer in its current state (in your devices memory). It can't automatically discern if the image is in fact what you see on your device in a given moment. If your screenshot is torn, you can:
  • Grab both framebuffers (option 3 in normal mode)
  • Quit hitting buttons to change the screen when you are pulling the framebuffer! lol
  • Wait for the framebuffer to swap with a clock change, or force it to change by going anywhere in the menu and then back to where you want to get your screenshot. A sub note on that: A button highlighting, and then a screen change will result in two swaps of the framebuffer and your next image will be on the same side of the framebuffer. If your screen was on the top and you hit a button (that highlights), then the next screen will also be on top. If there is no button highlight, hence just a draw of the next screen and a swap: The next screen will be on the opposite side. Same goes for any other change to your device screen, such as a clock digit changing. What was up now is down, and vice versa.
  • Aroma only uses the top framebuffer. It never calls for a swap, and the bottom framebuffer will stay whatever was last on it.

I do need to thank @Whiskey103 for his work over here. And I promise this is the last time I'll mention you, lol :good:

Changelog:
v1.5
Feb 9, 2014
-Total rewrite of structure and function
-Added check for framebuffer in /dev/fb0
-Added a manual mode where you don't have to have ADB connected as long as you have a file
-Added loops for every pixel format supported as input for FFmpeg
-Added folders for pngs to go into when they are rendered
-Added the option to convert both framebuffers into two seperate images; or grab the top or botom images

v1.1
Feb. 5, 2014
- Fixed algorithm for calculating stride on devices that don't have one.
 
Last edited:

nijel8

Senior Member
Dec 24, 2011
2,357
5,561
All over US
You're welcome. I'm glad you could decipher my babble. I'm going to rewrite it tomorrow to make it a little clearer.:confused:

Wasn't hard at all if you know what to look for...:D
I was missing the crop option and didn't know about this stride thing also. Was getting images like broken analog TV lol. Now all is good thanks to you. Here is my vbs code I am using for screenshots with my device in return:

Code:
Dim number', file
number = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")



Do

   If (objFSO.FileExists("" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\recovery_" & number & ".png" & "")) Then
       number = number +1
      ' Wscript.Echo number
   End If
   If (objFSO.FileExists("" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\recovery_" & number & ".png" & "")) Then
   Else
      Set objShell = WScript.CreateObject("WScript.Shell")
      Return =  objShell.Run ("adb pull /dev/graphics/fb0", 1, true)
      objShell.Run ("""" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\ffmpeg.exe" & """" & " -vcodec rawvideo -f rawvideo -pix_fmt rgb0 -s 1088x1920 -i " & """" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\fb0" & """" & " -vf crop=1080:1920:0:0 -y "  & """" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\recovery_" & "" & number & ".png""")
      objShell.Run ("adb kill-server")
    End If 
      
Loop While (objFSO.FileExists("" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\recovery_" & number & ".png" & ""))

WScript.Sleep(1000)

If (objFSO.FileExists("" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\fb0" & "")) Then
    objFSO.DeleteFile("" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\fb0" & "")
End If
 

makers_mark

Senior Member
Sep 21, 2013
192
476
Kings Mountain
Wasn't hard at all if you know what to look for...:D
I was missing the crop option and didn't know about this stride thing also. Was getting images like broken analog TV lol. Now all is good thanks to you. Here is my vbs code I am using for screenshots with my device in return:

Looks good! Don't know if you have an ulterior motive for making your own numbered files, but just so you know in the future, ffmpeg has a built in numbering feature. %03d.png as the filename would give you 001.png, 002.png... %02d.png would give you 01.png, 02.png... and so on. Here is a link, and sorry if you already knew that. Scroll down to 3.7.
 
Last edited:
  • Like
Reactions: SevenMaxs

nijel8

Senior Member
Dec 24, 2011
2,357
5,561
All over US
Looks good! Don't know if you have an ulterior motive for making your own numbered files, but just so you know in the future, ffmpeg has a built in numbering feature. %03d.png as the filename would give you 001.png, 002.png... %02d.png would give you 01.png, 02.png... and so on. Here is a link, and sorry if you already knew that. Scroll down to 3.7.

didn't know that either... thanks for the tip.

EDIT:Looks like I need my numbering code, I can't find a way to continue the naming sequence for multiple screenshots if file already exists or I am missing something...
 
Last edited:

makers_mark

Senior Member
Sep 21, 2013
192
476
Kings Mountain
didn't know that either... thanks for the tip.

EDIT:Looks like I need my numbering code, I can't find a way to continue the naming sequence for multiple screenshots if file already exists or I am missing something...

There isn't anyway that I know of inside of ffmpeg to do that globally, the way to do it is on your side (like you were doing). I didn't notice your number was saved.:good:
 
  • Like
Reactions: SevenMaxs

EnerJon

Senior Member
Jan 29, 2014
350
212
Thanks For The Tool... Its Working Fine...

Device: QMobile A900 (MT6589)
Screen Resolution: 720x1280
Stride: 16
Pixel Format: rgb565

1) Don't Know If Its A Bug :confused: But The Screenshot Taken With Option (1 - Get the top framebuffer.) Seems Cropped A Bit At Bottom...
Please Check Attached PNGs

2) Screenshot Taken With Option (2 - Get the bottom framebuffer.) Is Fine... :good:
 

Attachments

  • Bad.png
    Bad.png
    34.1 KB · Views: 182
  • Good.png
    Good.png
    34.8 KB · Views: 172
  • Like
Reactions: makers_mark

makers_mark

Senior Member
Sep 21, 2013
192
476
Kings Mountain
Thanks For The Tool... Its Working Fine...

Device: QMobile A900 (MT6589)
Screen Resolution: 720x1280
Stride: 16
Pixel Format: rgb565

1) Don't Know If Its A Bug :confused: But The Screenshot Taken With Option (1 - Get the top framebuffer.) Seems Cropped A Bit At Bottom...
Please Check Attached PNGs

2) Screenshot Taken With Option (2 - Get the bottom framebuffer.) Is Fine... :good:

Thanks for the feedback! What you are seeing is something with twrp, I think. I've noticed on mine, if I try to capture the splashscreen on twrp quickly at boot; it will do that same thing at the bottom on my screenshot too. If you look at it when it boots twrp draws like the whole top of the screen then quickly the very bottom as its calling for a fb swap. Even after my Nexus is sitting there for a minute, one framebuffer will look like that until the clock on twrp changes. Then it's fine.
Not real sure what causes it, but have you tried to do it after that? Does it do it everytime? If you open settings.cfg is this the first four numbers in it; 720 1280 16 736 ?
 
  • Like
Reactions: EnerJon

EnerJon

Senior Member
Jan 29, 2014
350
212
Thanks for the feedback! What you are seeing is something with twrp, I think. I've noticed on mine, if I try to capture the splashscreen on twrp quickly at boot; it will do that same thing at the bottom on my screenshot too. If you look at it when it boots twrp draws like the whole top of the screen then quickly the very bottom as its calling for a fb swap. Even after my Nexus is sitting there for a minute, one framebuffer will look like that until the clock on twrp changes. Then it's fine.
Not real sure what causes it, but have you tried to do it after that? Does it do it everytime? If you open settings.cfg is this the first four numbers in it; 720 1280 16 736 ?

No Its Not The SplashScreen... Its Main Screen Which Comes Right After SplashScreen...
Yes It Works Fine After Clock Changes...
Yes It Do It Everytime After First Bootup...
Yes The First Four Numbers Are Same...
720 1280 16 736 7536640 rgb565

Great Tool...!
 
Last edited:
  • Like
Reactions: makers_mark

makers_mark

Senior Member
Sep 21, 2013
192
476
Kings Mountain
No Its Not The SplashScreen... Its Main Screen Which Comes Right After SplashScreen...
Yes It Works Fine After Clock Changes...
Yes It Do It Everytime After First Bootup...
Yes The First Four Numbers Are Same...
720 1280 16 736 7536640 rgb565

Great Tool...!
Thanks for pointing that out. Added to the OP:

Notes:
If you change your recovery, you may have to clear the settings, it depends if there is a different pixel format. You can do so easily in the program, or you can just delete 'settings.cfg'

Sometimes your screenshot may seem disorganized or torn. This may happen when the very first screen is drawn, and also in between framebuffer swaps and writes. This is totally normal. This tool grabs your current framebuffer in its current state (in your devices memory). It can't automatically discern if the image is in fact what you see on your device in a given moment. If your screenshot is torn, you can:
  • Grab both framebuffers (option 3 in normal mode)
  • Quit hitting buttons to change the screen when you are pulling the framebuffer! lol
  • Wait for the framebuffer to swap with a clock change, or force it to change by going anywhere in the menu and then back to where you want to get your screenshot. A sub note on that: A button highlighting, and then a screen change will result in two swaps of the framebuffer and your next image will be on the same side of the framebuffer. If your screen was on the top and you hit a button (that highlights), then the next screen will also be on top. If there is no button highlight, hence just a draw of the next screen and a swap: The next screen will be on the opposite side. Same goes for any other change to your device screen, such as a clock digit changing. What was up now is down, and vice versa.
  • Aroma only uses the top framebuffer. It never calls for a swap, and the bottom framebuffer will stay whatever was last on it.
 
  • Like
Reactions: EnerJon

digyvijaykumar123

Senior Member
Nov 21, 2013
323
1,410
Koderma

Your recovery has to have ADB enabled! I wish I could tell you I know how to enable adb on all recoveries, but I can't.

I don't know. Your best bet is to ask in the forum thread you downloaded your recovery from.

Sent from my Nexus 7 using XDA Premium HD app

I am using same series device CANVAS 2+ and it worked on CWM recovery.
Thanks @makers_mark
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 69
    This is a tool to capture screenshots while in Recovery or the Aroma Installer.

    Your Recovery MUST have ADB enabled or no matter what you do you'll NEVER pull a Screenshot

    v1.5
    Feb 9, 2014
    -Total rewrite of structure and function
    -Added check for framebuffer in /dev/fb0
    -Added a manual mode where you don't have to have ADB connected as long as you have a file
    -Added loops for every pixel format supported as input for FFmpeg
    -Added folders for pngs to go into when they are rendered
    -Added the option to convert both framebuffers into two seperate images; or grab the top or botom images​

    One big problem people are having when trying to capture screenshots in recovery, on some devices, is the extra framebuffer info that is tacked on to the end of each pixel row. Through a lot of digging and not finding too much information on it, I've finally found a way to determine what dimensions to use for, I believe, all android devices.

    Fb2png is a great open source program, but unfortunately it only works with framebuffers that don't have a stride. FFmpeg is what I use here. FFmpeg is a great open source command line transcoder. It's pretty hefty and can do a vast amount of conversions (audio/video/codecs/images) all from the command line. They are two different beasts with, Fb2png made for the sole purpose of grabbing the framebuffer then converting it into a png file. While FFmpeg is more of a computer side program, and you tell it exactly what you want it to do.

    Dealing with the framebuffer we are dealing with raw data. There is 0 extra information in this file, no line size, title, header, no nothing except a continuous write of pixel data. That's great for guessing the exact file size, and that's about it. But to get it to a view-able image, you have to specify where each line starts/stops, and convert the pixel format to whatever you want to use, your file-type.

    I found that if you divide your width; the Nexus 5 for example is 1080; by 32, your stride will equal the value to add to that 1080 to go up and make it evenly divisible by 32. The next number up from 1080 that is evenly divisible by 32 is 1088, and those 8 extra pixels is your stride. Height is not as important, as far as what we are doing, simply because everything is read left to right, then advance down. Resolution being divisible by 32, or MOD 32 to graphics people, is becoming not as common on devices nowadays, AND those are the devices fb2png gives distorted screenshots with. Maybe @Phil3759 knows how to fix this for fb2png.

    I made this batch script that takes into account your stride, if you have one. If your width is 768 for example, you won't have one because 32 goes into 768 an even 24 times.

    You can also use manual mode and use any raw image you have saved.
    Please read the instructions below.

    Recovery Screenshot v1.5 batch script
    Code:
    @ECHO OFF
    IF NOT EXIST ffmpeg.exe CALL :NOFILES
    IF NOT EXIST adb.exe CALL :NOFILES
    CLS
    SETLOCAL
    SET pixfmt=""
    SET FINAME=frmbfr
    :TOP
    	TITLE Recovery Screenshot v1.5 For all devices.
    	MODE CON:COLS=60 LINES=48
    	COLOR 0B
    	ADB kill-server -d >nul 2>&1
    	SET "ffshowb=-hide_banner"
    	SET "ffdebug=-loglevel fatal"
    	IF "%~1"=="-d" (
    		REM @ECHO ON
    		SET "ffdebug=-loglevel debug"
    		SET "ffshowb=%"
    		MODE CON:COLS=140 LINES=250
    		COLOR 07
    		ECHO ______________________________________________________
    		ECHO DEBUG INFO
    		ECHO ______________________________________________________
    	)
    IF NOT EXIST "settings.cfg" GOTO CHECK 
    IF EXIST "settings.cfg" GOTO MAINMENU
    :CHECK
    	CALL :DRAWHEAD
    	ECHO[
    	ECHO You don't have a configuration set up...
    	ECHO[
    	ECHO Please choose 1 or 2
    	ECHO[
    	ECHO 1 - Make a configurations setting
    	ECHO[
    	ECHO 2 - Manual Mode
    	ECHO[
    	CHOICE /C:12
    	IF ERRORLEVEL 1 SET K=1
    	IF ERRORLEVEL 2 SET K=2
    	IF %K%==1 GOTO SETTINGS
    	IF %K%==2 CALL :MANUALMODE
    
    :MAINMENU
    	CALL :LOADCONFIG
    	ECHO[
    	ECHO Your Settings are....
    	ECHO Native Resolution %width%X%height% 
    	ECHO Stride=%stride%
    	ECHO Pixel Format=%pixfmt%
    	ECHO Save Folder for screenshots is ^"%DATE:/=-%\^"
    	CALL :DRAWHEAD
    	ECHO Please choose one of the following...
    	ECHO[
    	ECHO 1 - Get the top framebuffer.
    	ECHO[
    	ECHO 2 - Get the bottom framebuffer.
    	ECHO[
    	ECHO 3 - Get both framebuffers.(2 images)
    	ECHO[
    	ECHO 4 - Reset your settings.
    	ECHO[
    	ECHO 5 - Manual Mode!
    	ECHO[
    	ECHO 6 - Exit
    	ECHO[
    	CHOICE /C:123456
    		IF ERRORLEVEL 1 SET K=1
    		IF ERRORLEVEL 2 SET K=2
    		IF ERRORLEVEL 3 SET K=3
    		IF ERRORLEVEL 4 SET K=4
    		IF ERRORLEVEL 5 SET K=5
    		IF ERRORLEVEL 6 SET K=6
    		IF %K%==1 (CALL :GETFBO
    			CALL :UPPERGET)
    		IF %K%==2 (CALL :GETFBO
    			CALL :LOWERGET)
    		IF %K%==3 (CALL :GETFBO
    			CALL :UPPERGET)
    		IF %K%==4 GOTO SETTINGS
    		IF %K%==5 GOTO MANUALMODE
    		IF %K%==6 GOTO FINISH
    		CLS
    	GOTO MAINMENU
    
    :UPPERGET
    	CALL :SSNAMINGCONVENTION
    	SET stoy=" -s %widthwithstride%x%height% -i %FINAME% -vframes 1 -vf crop=%width%:%height%:0:0 -y %folderdate%\%TS%"
    	CALL :TRANSCODE %stoy%
    	ECHO[
    	ECHO SCREENSHOT SAVED AS %folderdate%\%TS%	
    	IF %K%==3 GOTO :LOWER
    	DEL frmbfr
    	ECHO Press any key to continue to menu...
    	PAUSE >NUL & CLS
    	GOTO :EOF
    
    :LOWERGET
    	CALL :SSNAMINGCONVENTION
    	:LOWER	
    	SET /a "cheight=2 * height"
    	SET stoy=" -s %widthwithstride%x%cheight% -i %FINAME% -vframes 1 -vf crop=%width%:%height%:0:%height% -y %folderdate%\%TSL%"
    	CALL :TRANSCODE %stoy%
    	ECHO SCREENSHOT SAVED AS %folderdate%\%TSL%
    	DEL frmbfr
    	ECHO Press any key to continue to menu...
    	PAUSE>NUL & CLS
    	GOTO MAINMENU
    
    :TRANSCODE
    	FFMPEG %ffdebug% %ffshowb% -f rawvideo -vcodec rawvideo -pix_fmt %pixfmt% %~1 || GOTO FFHELP "-loglevel debug -f rawvideo -vcodec rawvideo -pix_fmt %pixfmt% %stoy%
    	GOTO :EOF
    
    :GETLOTSOFPNGS
    	FOR /D %%A IN (%pixfmt%) DO CALL FFMPEG %ffshowb% %ffdebug% -f rawvideo -vcodec rawvideo -pix_fmt %%A -s %widthwithstride%x%height% -i %FINAME% -vframes 1 -vf crop=%width%:%height%:0:0 -y Pixel_formats\%%A%TS% || GOTO FFHELP LOTSOFPPNGS
    	GOTO :EOF
    
    :LOADCONFIG
    	FOR /F "tokens=1,2,3,4,5,6" %%A IN (settings.cfg) DO CALL :PROCESS %%A %%B %%C %%D %%E %%F || GOTO :SETTINGS
    	GOTO :EOF
    
    :PROCESS
    	SET width=%1
    	SET height=%2
    	SET stride=%3
    	SET widthwithstride=%4
    	SET fb0size=%5
    	SET pixfmt=%6
    	GOTO :EOF
    
    :SETTINGS
    	IF EXIST settings.cfg DEL settings.cfg
    	IF NOT EXIST Pixel_formats\ MKDIR Pixel_formats\
    	DEL Pixel_formats\*.png
    	CLS
    	CALL :DRAWHEAD
    	ECHO[
    	ECHO[
    	ECHO Settings
    	ECHO[
    	ECHO Enter your screen width...
    	ECHO[
    	SET /P width=Width?
    	ECHO[
    	ECHO Enter your screen height...
    	ECHO[
    	SET /P height=Height?
    	CALL :GETFBO
    	CALL :DOMATH
    	SET "pixfmt=rgb565,rgb565be,bgr24,rgb24,rgb32,argb,rgba,abgr,bgra,0rgb,rgb0,0bgr,bgr0,gbrp"
    	SET TS=%_%.png
    	ECHO[
    	ECHO[
    	ECHO Generating test images......
    	ECHO They will be in the folder 'Pixel_formats'
    	ECHO[
    	CALL :GETLOTSOFPNGS
    	ECHO[
    	ECHO[
    	ECHO Check the folder and make a note of the filename of the
    	ECHO correct screenshot.
    	ECHO[
    	ECHO Press any key to continue..
    	PAUSE >NUL
    	CLS
    	CALL :DRAWHEAD
    	ECHO[
    	ECHO Please select a menu number...
    	ECHO[
    	ECHO 1 - You see your image...
    	ECHO[	
    	ECHO 2 - Don't see your image..use more formats..?
    	ECHO[
    	ECHO 3 - Enter Manual Mode to try your own settings.
    	ECHO[
    	ECHO 4 - Exit
    	ECHO[
    	CHOICE /C:1234
    	IF ERRORLEVEL 1 SET K=1
    	IF ERRORLEVEL 2 SET K=2
    	IF ERRORLEVEL 3 SET K=3
    	IF ERRORLEVEL 4 SET K=4
    	IF %K%==1 GOTO INPUTPFMT
    	IF %K%==2 (DEL Pixel_formats\*.png
    		ECHO[
    		CALL :1TO2BYTESPP
    		ECHO GETTING 1 ^& 2 BYTE/pp formats..
    		CALL :GETLOTSOFPNGS
    		ECHO[
    		CALL :3BYTESPP
    		ECHO .Getting 3 Byte/pp formats..
    		CALL :GETLOTSOFPNGS
    		ECHO[
    		CALL :4BYTESPP
    		ECHO ..Getting 4 Byte/pp formats..
    		CALL :GETLOTSOFPNGS
    		ECHO[
    		CALL :5BYTESPP
    		ECHO ...Getting 5 Byte/pp formats..
    		CALL :GETLOTSOFPNGS
    		ECHO[
    		CALL :6TO8BYTESPP
    		ECHO ....Getting 6 ^& 8 Byte/pp formats..
    		CALL :GETLOTSOFPNGS
    		ECHO[)
    	IF %K%==3 CALL :MANUALMODE
    	IF %K%==4 GOTO FINISH
    	CLS
    	CALL :DRAWHEAD
    	ECHO[
    	ECHO Please select a menu number...
    	ECHO[
    	ECHO 1 - You found your screenshot.
    	ECHO[
    	ECHO 2 - You didn't find your screenshot.
    	ECHO[
    	ECHO 3 - Enter Manual Mode to try your own settings.
    	ECHO[
    	ECHO 4 - Exit
    	ECHO[
    	CHOICE /C:1234
    	IF ERRORLEVEL 1 SET K=1
    	IF ERRORLEVEL 2 SET K=2
    	IF ERRORLEVEL 3 SET K=3
    	IF ERRORLEVEL 4 SET K=4
    	IF %K%==1 GOTO INPUTPFMT
    	IF %K%==2 CALL :HELP
    	IF %K%==3 GOTO MANUALMODE
    	IF %K%==4 GOTO FINISH
    	GOTO :EOF
    
    :HELP
    	REN frmbfr Framebuffer.raw
    	REM MODE CON:COLS=80 LINES=68
    	ECHO[
    	ECHO[
    	ECHO[
    	ECHO[
    	ECHO If you don't have a valid/correct screenshot in your "Pixel_formats\ folder
    	ECHO something has happened.  I would really appreciate it if you would upload it
    	ECHO so I could try and find the problem. 
    	ECHO[
    	ECHO http://forum.xda-developers.com/showthread.php?t=2635736
    	ECHO[
    	ECHO There is absolutely no harm in doing this, because the only data stored in it
    	ECHO is pixel data, that is unless you had something private on your screen;
    	ECHO then you can keep your framebuffer!
    	ECHO[
    	ECHO I have named your framebuffer...'Framebuffer.raw' in 
    	ECHO %~dp0
    	ECHO Thank You for trying!
    	ECHO[
    	ECHO Press any key to exit...
    	PAUSE >NUL
    	GOTO FINISH
    
    :DRAWHEAD
    	ECHO[
    	ECHO _________________________________________________________-_-
    	ECHO[
    	ECHO                   Recovery Screenshot v1.5
    	ECHO[
    	ECHO ____________________________________________________________
    	ECHO[
    	ECHO             Thanks to Whiskey103 for the idea!!
    	ECHO                  Written by makers_mark
    	ECHO[
    	ECHO ____________________________________________________________
    	GOTO :EOF
    
    :INPUTPFMT
    	CLS
    	CALL :DRAWHEAD
    	ECHO[
    	ECHO Please enter the pixel format to use.
    	ECHO[
    	ECHO YOU MUST USE LOWERCASE LETTERS!
    	ECHO[
    	ECHO ____________________________________________________________
    	ECHO Example: If the filename of the image, that is correct, is 
    	ECHO          rgb565.png
    	ECHO          Then you would enter 'rgb565'
    	ECHO ____________________________________________________________
    	ECHO[
    	ECHO[	
    	SET /p pixfmt=Pixel format?
    	CALL :WRITETOFILE %width% %height% %stride% %widthwithstride% %fb0size% %pixfmt%
    	DEL frmbfr
    	CLS
    	GOTO MAINMENU
    		
    :SSNAMINGCONVENTION
    	SET folderdate=%DATE:/=-%
    	SET folderdate=%folderdate: =%
    	IF NOT EXIST "%folderdate%\" MKDIR "%folderdate%\"
    	SET TS=%TIME::=_%
    	SET TS=%TS:.=%
    	SET TS=%TS: =%
    	SET TSL=%TS%
    	SET TS=%TS%upper.png
    	SET TSL=%TSL%lower.png
    	GOTO :EOF
    
    :DOMATH
    	SET /a "stride=width %% 32"
    	IF %stride% NEQ 0 SET /a "stride=32 - stride"
    	SET /a "widthwithstride=stride + width"
    	FOR /F "usebackq" %%A IN ('frmbfr') DO set fb0size=%%~zA
    	GOTO :EOF
    
    :GETFBO
    	CLS
    	CALL :DRAWHEAD
    	ECHO[
    	ECHO[
    	ECHO Pulling Framebuffer from your device.....
    	ECHO[
    	ADB kill-server -d >NUL 2>&1
    	ADB pull /dev/graphics/fb0 frmbfr>NUL 2>&1 || ADB pull /dev/fb0 frmbfr>NUL 2>&1
    	IF ERRORLEVEL 1 (cls
    		ECHO ______________________________________________________
    		ECHO Adb is not properly connected.
    		ECHO Try "Safely Removing" your device from your computer
    		ECHO Then unplug your usb cable, and reinsert it.
    		ECHO ______________________________________________________
    		ECHO[
    		ECHO[
    		ECHO Press any key to try again.
    		ECHO[
    		ECHO[
    		PAUSE >nul
    		CLS
    		GOTO GETFBO)
    GOTO :EOF
    
    
    :WRITETOFILE
    	ECHO %~1 %~2 %~3 %~4 %~5 %~6 > settings.cfg
    	GOTO :EOF
    
    :FFHELP
    	MODE CON:COLS=108 LINES=200
    	COLOR 07
    	FFMPEG %~1
    	echo WIDTH=%width%
    	echo HEIGHT%height%
    	ECHO STRIDE=%stride%
    	ECHO Pixel Format is %pixfmt%
    	echo S to Y=%stoy%
    	echo Width with stride=%widthwithstride%
    	ECHO K=%K%
    	ECHO FINAME=%FINAME%
    	echo[
    	echo %1
    	echo %~1
    	echo[
    	ECHO There was an error in ffmpeg.
    	PAUSE >NUL 
    GOTO FINISH
    
    :MANUALMODE
    	IF NOT EXIST Manual_mode\ MKDIR Manual_mode\
    	CLS
    	ECHO[
    	ECHO _________________________________________________________-_-
    	ECHO                        MANUAL MODE!
    	ECHO[
    	CALL :DRAWHEAD
    	ECHO[
    	ECHO I DO NOT ACCOUNT FOR STRIDE IN THIS MODE!
    	ECHO[
    	ECHO YOUR WIDTH YOU INPUT WILL BE THE PIXEL THAT TELLS
    	ECHO FFMPEG TO GO TO THE NEXT LINE!
    	ECHO[
    	ECHO TIP: IF YOU ARE WORKING WITH A FRAMEBUFFER, DOUBLE YOUR 
    	ECHO HEIGHT, TO GET THE DOUBLE FRAMEBUFFER. 
    	ECHO[ 
    	SET /p width=Width?
    	ECHO[
    	SET /p height=Height?
    	ECHO[
    	SET "widthwithstride=width"
    	ECHO ENTER THE FILENAME OF THE RAW IMAGE YOU
    	ECHO WANT TO LOAD...
    	ECHO[
    	ECHO JUST PRESS ENTER TO USE ADB TO PULL FRAMEBUFFER
    	ECHO[
        :NONEXIST
    	SET /p FINAME=Filename? || SET FINAME=usefb
    	IF %FINAME%==usefb CALL :GETFBO
    	IF %FINAME%==usefb (SET FINAME=frmbfr
    		GOTO MANUALMODEIN)
    	IF EXIST %FINAME% GOTO MANUALMODEIN
    	IF NOT EXIST %FINAME% (
    		ECHO FILE, %FINAME% DOESN'T EXIST.
    		GOTO NONEXIST)
    
    :MANUALMODEIN
    	CLS
    	ECHO[
    	ECHO _________________________________________________________-_-
    	ECHO                        MANUAL MODE!
    	ECHO[
    	ECHO FILE= %FINAME%
    	IF %FINAME%==frmbfr ECHO       ^^^^^^^^^^^^THAT IS YOUR DEVICES FRAMEBUFFER!
    	ECHO[
    	ECHO WIDTH= %width%    HEIGHT= %height%
    	ECHO[
    	ECHO Please select the Pixel Formats to use.
    	ECHO I've grouped them in sets of Bytes Per Pixel
    	ECHO[
    	ECHO Please choose one of the following...
    	ECHO[
    	ECHO 1 - ALL FORMATS!
    	ECHO[
    	ECHO 2 - 2 Bpp
    	ECHO[
    	ECHO 3 - 3 Bpp
    	ECHO[
    	ECHO 4 - 4 Bpp
    	ECHO[
    	ECHO 5 - 5 Bpp
    	ECHO[
    	ECHO 6 - 6 ^& 8 Bpp
    	ECHO[
    	ECHO 7 - Start Manual mode over (new WxH and file)
    	ECHO[
    	ECHO 8 - Go to regular mode.
    	ECHO[
    	ECHO 9 - EXIT
    	CHOICE /C:123456789
    	IF ERRORLEVEL 1 SET K=1
    	IF ERRORLEVEL 2 SET K=2
    	IF ERRORLEVEL 3 SET K=3
    	IF ERRORLEVEL 4 SET K=4
    	IF ERRORLEVEL 5 SET K=5
    	IF ERRORLEVEL 6 SET K=6
    	IF ERRORLEVEL 7 SET K=7
    	IF ERRORLEVEL 8 SET K=8
    	IF ERRORLEVEL 9 SET K=9
    	IF %K%==1 (CALL :MMNAMINGCONVENTION
    		CALL :2BPP
    		CALL :3BPP
    		CALL :4BPP
    		CALL :5BPP
    		CALL :6BPP
    		ECHO[
    		ECHO DONE!
    		ECHO[
    		ECHO Press any key to continue..
    		PAUSE>NUL
    		GOTO MANUALMODEIN)
    	IF %K%==2 (CALL :MMNAMINGCONVENTION
    		CALL :2BPP
    		ECHO[
    		ECHO DONE!
    		ECHO[
    		ECHO Press any key to continue..
    		PAUSE >NUL
    		GOTO MANUALMODEIN)
    	IF %K%==3 (CALL :MMNAMINGCONVENTION
    		CALL :3BPP
    		ECHO[
    		ECHO DONE!
    		ECHO[
    		ECHO Press any key to continue..
    		PAUSE >NUL
    		GOTO MANUALMODEIN)
    	IF %K%==4 (CALL :MMNAMINGCONVENTION
    		CALL :4BPP
    		ECHO[
    		ECHO DONE!
    		ECHO[
    		ECHO Press any key to continue..
    		PAUSE >NUL	
    		GOTO MANUALMODEIN)
    	IF %K%==5 (CALL :MMNAMINGCONVENTION
    		CALL :5BPP
    		ECHO[
    		ECHO DONE!
    		ECHO[
    		ECHO Press any key to continue..
    		PAUSE >NUL	
    		GOTO MANUALMODEIN)
    	IF %K%==6 (CALL :MMNAMINGCONVENTION
    		CALL :6BPP
    		ECHO[
    		ECHO DONE!
    		ECHO[
    		ECHO Press any key to continue..
    		PAUSE >NUL	
    		GOTO MANUALMODEIN)
    	IF %K%==7 (DEL frmbfr >NUL
    		GOTO MANUALMODE)
    	IF %K%==8 (DEL frmbfr >NUL 2>&1
    		GOTO TOP)
    	IF %K%==9 (DEL frmbfr >NUL 2>&1
    		GOTO FINISH)
    	GOTO MANUALMODEIN
    :2BPP
    	ECHO[
    	ECHO CONVERTING 1 ^& 2 Byte/pp IMAGES!
    	ECHO[
    	CALL :MMNAMINGCONVENTION
    	CALL :1TO2BYTESPP
    	CALL :MAKEPNGSMM
    	ECHO IMAGES SAVED IN 'Manual_mode\' FOLDER
    	ECHO[
    	GOTO :EOF
    
    :3BPP
    	ECHO[
    	ECHO ..CONVERTING 3 BYTE/PP IMAGES!
    	ECHO[
    	CALL :3BYTESPP
    	CALL :MAKEPNGSMM
    	ECHO IMAGES SAVED IN 'Manual_mode\' FOLDER
    	ECHO[	
    	GOTO :EOF
    
    :4BPP
    	ECHO[
    	ECHO ...CONVERTING 4 BYTE/PP IMAGES!
    	ECHO[
    	CALL :4BYTESPP
    	CALL :MAKEPNGSMM
    	ECHO IMAGES SAVED IN 'Manual_mode\' FOLDER
    	ECHO[
    	GOTO :EOF
    :5BPP
    	ECHO[
    	ECHO ....CONVERTING 5 BYTE/PP IMAGES!
    	ECHO[
    	CALL :5BYTESPP
    	CALL :MAKEPNGSMM
    	ECHO IMAGES SAVED IN 'Manual_mode\' FOLDER
    	ECHO[
    	GOTO :EOF
    :6BPP
    	ECHO[
    	ECHO ....CONVERTING 6 ^& 8 BYTE/PP IMAGES!
    	ECHO[
    	CALL :6TO8BYTESPP
    	CALL :MAKEPNGSMM
    	ECHO IMAGES SAVED IN 'Manual_mode\' FOLDER
    	ECHO[
    	GOTO :EOF
    
    :MAKEPNGSMM
    	FOR /D %%A IN (%pixfmt%) DO CALL FFMPEG %ffshowb% %ffdebug% -f rawvideo -vcodec rawvideo -pix_fmt %%A -s %width%x%height% -i %FINAME% -vframes 1 -y Manual_mode\%%A_%width%X%height%_%TS% || GOTO FFHELP
    	GOTO :EOF
    :1TO2BYTESPP
    	SET "pixfmt=yuv410p,gray,monow,monob,pal8,bgr8,bgr4_byte,rgb8,rgb555be,rgb555le,bgr555be,bgr555le,yuv420p10be,yuv420p10le,yuv420p9be,yuv420p9le,yuv420p,yuv411p,yuv420p,nv12,nv21,rgb444le,rgb444be,bgr444le,bgr444be,yuvj411p,yuyv422,yuv422p,yuvj422p,uyvy422,gray16be,gray16le,yuv440p,yuvj440p,rgb565be,rgb565le,bgr565be,bgr565le,gray8a"
    	GOTO :EOF
    :3BYTESPP
    	SET "pixfmt=rgb24,bgr24,yuv444p,yuvj444p,yuva420p,yuv420p16le,yuv420p16be,yuv422p10be,yuv422p10le,yuv422p9be,yuv422p9le,yuva420p9be,yuva420p9le,gbrp,0rgb,rgb0,0bgr,bgr0,yuva422p,yuv420p12be,yuv420p12le,yuv420p14be,yuv420p14le,yuv422p12be,yuv422p12le"
    	GOTO :EOF
    :4BYTESPP
    	SET "pixfmt=argb,rgba,abgr,bgra,yuv422p16le,yuv422p16be,yuv444p9be,yuv444p9le,yuv444p10be,yuv444p10le,gbrp9be,gbrp9le,gbrp10be,gbrp10le,gbrp9be,gbrp9le,gbrp10be,gbrp10le,yuva422p9be,yuva422p9le,yuva420p10be,yuva420p10le,yuva422p10be,yuva422p10le,yuva444p,yuv422p14be,yuv422p14le,gbrap"
    	GOTO :EOF
    :5BYTESPP
    	SET "pixfmt=yuva444p9be,yuva444p9le,yuva444p10be,yuva444p10le,yuva420p16be,yuva420p16le,xyz12le,xyz12be,yuv444p12be,yuv444p12le,gbrp12be,gbrp12le"
    	GOTO :EOF
    :6TO8BYTESPP
    	SET "pixfmt=rgb48be,rgb48le,yuv444p16le,yuv444p16be,bgr48be,bgr48le,gbrp16be,gbrp16le,yuva422p16be,yuva422p16le,yuv444p14be,yuv444p14le,gbrp14be,gbrp14le,yuva444p16be,yuva444p16le,rgba64be,rgba64le,gbrap16be,gbrap16le"
    	GOTO :EOF
    
    :MMNAMINGCONVENTION
    	SET TS=%TIME::=_%
    	SET TS=%TS:.=%
    	SET TS=%TS: =%.png
    	GOTO :EOF
    
    :FINISH
    	ADB kill-server -d >nul 2>&1
    	ENDLOCAL
    	EXIT

    Instructions:
    If you have already downloaded a previous version, you do not have to download everything again. The bat file is the only difference between any of the versions. You can copy the script up above for v1.5 and edit the one you already have in Notepad, or any other text editor; Paste the new version in there and save it. And thats it.
    Download Recovery Screenshot v1.5
    Extract it to a new folder.
    You will have the programs FFmpeg & ADB.
    Two .dll files for ADB. And the batch script RUNrs.bat
    I assume you have your ADB drivers squared away!!

    Reboot into your recovery.
    Run RUNrs.bat and it will ask you if you want to set up a configuration or go into manual mode.
    If you have ADB good and ready to go, I would reccommend going ahead and setting up your configuration now.
    Enter you native resolution, with width being the short side! Don't adjust for stride either. Your native resolution should be entered.
    It will then pull the framebuffer, and convert it into several pngs with different pixel formats.
    Go to the folder "Pixel_formats" and look through them and make note of the correct one, specifically the filename of the correct one.
    If you see your image, then hit "1" to input the name of the pixel format (which is the name of the png that is right)
    If you don't see your screenshot in that folder hit "2" and it will generate a bunch more from various pixel formats.
    Look through those, it might take some time LOL, and see if you can skip over the cool looking ones until you see yours.
    Hit 1 and go input it.
    From there you are good to go. You'll see your configuration in the upper left corner of the main menu window, and it will be persistent when you close the program out. You have the option to grab both framebuffers with this version. You are probably wandering why there's two. Well android uses a double framebuffer. Have you ever noticed that sometimes when you got a screenshot before, it will be a previous screen on there? Android has one screen that is displayed, and another one adjacent to it (they are butted top to bottom) that is meant for drawing on (really quick I might add). The idea behind that (on a fast scale) is: When the device switches to a new frame, the device can render the next screen in a different buffer while the current screen stays displayed. And then pop up that screen when it is ready. If it didn't do that, and used just one framebuffer, then when you go to a different screen, the new screen would have to be processed and drawn over the old screen and just wouldn't look as good. When ANY little bit of information changes on you screen, yes even the minute number on the clock, it draws it quickly and swaps the two buffers. So now all of the sudden your main framebuffer is opposite what it was before. And the other one is the artboard.

    Manual mode does not take into account stride. It is just a tool to convert any raw image into pngs, and at the same time figure out what pixel format something, like a splash screen, might be. You don't have to have ADB enabled to use it. You can use a file of you own, just place it in the main folder, and after you supply the width and height, input the file name. If you just press enter instead, it will pull you framebuffer, and you will need ADB for that.

    In Manual mode you can select between different pixel formats grouped by Bytes per pixel (1&2 Byte/pp, 3Bpp, 4Bpp, 5Bpp, and 6&8 Byte/pp)
    Or you can run them all. If you run into errors with FFmpeg in manual mode, try not to seek too far down with your height in the resolution selection. If you overshoot the expected filesize looking for data, FFmpeg will not convert it.

    Notes:
    If you change your recovery, you may have to clear the settings, it depends if there is a different pixel format. You can do so easily in the program, or you can just delete 'settings.cfg'

    Sometimes your screenshot may seem disorganized or torn. This may happen when the very first screen is drawn, and also in between framebuffer swaps and writes. This is totally normal. This tool grabs your current framebuffer in its current state (in your devices memory). It can't automatically discern if the image is in fact what you see on your device in a given moment. If your screenshot is torn, you can:
    • Grab both framebuffers (option 3 in normal mode)
    • Quit hitting buttons to change the screen when you are pulling the framebuffer! lol
    • Wait for the framebuffer to swap with a clock change, or force it to change by going anywhere in the menu and then back to where you want to get your screenshot. A sub note on that: A button highlighting, and then a screen change will result in two swaps of the framebuffer and your next image will be on the same side of the framebuffer. If your screen was on the top and you hit a button (that highlights), then the next screen will also be on top. If there is no button highlight, hence just a draw of the next screen and a swap: The next screen will be on the opposite side. Same goes for any other change to your device screen, such as a clock digit changing. What was up now is down, and vice versa.
    • Aroma only uses the top framebuffer. It never calls for a swap, and the bottom framebuffer will stay whatever was last on it.

    I do need to thank @Whiskey103 for his work over here. And I promise this is the last time I'll mention you, lol :good:

    Changelog:
    v1.5
    Feb 9, 2014
    -Total rewrite of structure and function
    -Added check for framebuffer in /dev/fb0
    -Added a manual mode where you don't have to have ADB connected as long as you have a file
    -Added loops for every pixel format supported as input for FFmpeg
    -Added folders for pngs to go into when they are rendered
    -Added the option to convert both framebuffers into two seperate images; or grab the top or botom images

    v1.1
    Feb. 5, 2014
    - Fixed algorithm for calculating stride on devices that don't have one.
    5
    Thanks for this... helped me to figure out what was wrong with my ffmpeg options that couldn't take good screenshot.

    You're welcome. I'm glad you could decipher my babble. I'm going to rewrite it tomorrow to make it a little clearer.:confused:
    3
    You're welcome. I'm glad you could decipher my babble. I'm going to rewrite it tomorrow to make it a little clearer.:confused:

    Wasn't hard at all if you know what to look for...:D
    I was missing the crop option and didn't know about this stride thing also. Was getting images like broken analog TV lol. Now all is good thanks to you. Here is my vbs code I am using for screenshots with my device in return:

    Code:
    Dim number', file
    number = 0
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    
    
    Do
    
       If (objFSO.FileExists("" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\recovery_" & number & ".png" & "")) Then
           number = number +1
          ' Wscript.Echo number
       End If
       If (objFSO.FileExists("" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\recovery_" & number & ".png" & "")) Then
       Else
          Set objShell = WScript.CreateObject("WScript.Shell")
          Return =  objShell.Run ("adb pull /dev/graphics/fb0", 1, true)
          objShell.Run ("""" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\ffmpeg.exe" & """" & " -vcodec rawvideo -f rawvideo -pix_fmt rgb0 -s 1088x1920 -i " & """" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\fb0" & """" & " -vf crop=1080:1920:0:0 -y "  & """" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\recovery_" & "" & number & ".png""")
          objShell.Run ("adb kill-server")
        End If 
          
    Loop While (objFSO.FileExists("" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\recovery_" & number & ".png" & ""))
    
    WScript.Sleep(1000)
    
    If (objFSO.FileExists("" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\fb0" & "")) Then
        objFSO.DeleteFile("" & objFSO.GetParentFolderName(wscript.ScriptFullName) & "\fb0" & "")
    End If
    2

    Your recovery has to have ADB enabled! I wish I could tell you I know how to enable adb on all recoveries, but I can't.

    I don't know. Your best bet is to ask in the forum thread you downloaded your recovery from.

    Sent from my Nexus 7 using XDA Premium HD app

    I am using same series device CANVAS 2+ and it worked on CWM recovery.
    Thanks @makers_mark
    1
    This works brilliantly on my Xperia Z. Thanks so much! :D