mercredi 5 février 2014

[TOOL][MOD][WIN][SHARE] Take Screenshots in Recovery & Aroma! topic




[SIZE="4']Note : I'm just sharing the work of the XDA Member.Here's a little introduction by him :[/SIZE]


Quote:










Originally Posted by makers_mark
(Post 50029759)

This is a tool to capture screenshots while in Recovery or the Aroma Installer.

One big problem people are having when trying to capture screenshots in recovery 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 program, but unfortunately it only works with framebuffers that don't have a stride. FFmpeg is what I use here. That is a major problem with fb2png but it seems like it would be an easy thing to fix. The only thing to get it working, besides some random pixel formats maybe, is taking care of this stride.

I found that if you divide your width, for the nexus 7 2013 it's 1200, by 32, your stride will equal the value to add to 1200 to go up and make it evenly divisible by 32, that is your stride. Look at a bunch of resolutions and the width; the short side, think portrait mode; is usually evenly divisible by 32. Not all the time though, like the case of the Nexus 7 2013, Nexus 5 with 1080, and many more devices nowadays, AND those are the devices fb2png gives distorted screenshots with. Maybe @Phil3759 knows how to fix this for fb2png.

By the way the Nexus 5's stride is 8
1080/32 = 33 with a remainder of 24. 32-24 = 8

Anyways 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.

Instructions:
Download the RS_all.rar file
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 for you screen width in pixels, and your height. Input them.
It will then pull your framebuffer and make a bunch of viewable pngs with different pixel formats.
Don't close the program or anything, but go look in the folder you unzipped everything, and go through the images until you find one that is exactly like you screen, don't settle for close. Look at the filename of the one, and input that into the next prompt for your pixel format.

If I get any feedback I will change the first set of pixel formats to more common ones only, then some rarer ones if the first set didn't work.
Feel free to run 'ffmpeg -pix_fmts' and put in any of the other input-able pixel formats when you are asked to select which one you want to use.
Your set from there, all of that will be saved into settings.cfg.

If you change your recovery, you may have to clear the settings. You can do so easily in the program, or you can just delete settings.cfg
Same thing if you try a different device.

I am severely limited in devices to test. But I'd like to find a universal way with all android devices to pull the screen resolution from the phone/tablet and..
- add a check for the framebuffer in /dev/fb0 instead of just /dev/graphics/fb0. For now, if you get errors and it won't pull the framebuffer. Just change the code in the batch, two different places, from 'adb pull /dev/graphics/fb0 frmbfr' to 'adb pull /dev/fb0 frmbfr'

- make folders for screenshots to go into, and also a temp folder that gets deleted, for the pixel format test images.

- add the double frame buffer, two images. I have already done it, but am a little baffled as some devices seem to have six; or at least room for six raw fb0 <single ones in fb0

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:

Here is the batch script.

 





Code:


@ECHO OFF
CLS
TITLE Recovery Screenshot v1.0 For all devices.
MODE CON:COLS=54 LINES=40
COLOR 0B
IF EXIST temp.tmp DEL temp.tmp
SET TS=0
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 SETTINGS

:START
FOR /F "tokens=1,2,3,4" %%A IN (settings.cfg) DO CALL :PROCESS %%A %%B %%C %%D

:GOTPARAMETERS
ECHO Your settings are:
ECHO[
ECHO Width=%width% Height=%height% Pixel format=%pixfmt%
ECHO[
ECHO ______________________________________________________
ECHO  This will pull a screenshot from your device and
ECHO    save it to the directory that you ran this bat
ECHO  file in. Connect USB ^& reboot into your recovery.
ECHO ______________________________________________________
ECHO        Thanks to Whiskey103 for the idea!!
ECHO              Written by makers_mark
ECHO ______________________________________________________
IF NOT EXIST ffmpeg.exe GOTO NOFILES
IF NOT EXIST adb.exe GOTO NOFILES
ADB kill-server -d >nul 2>&1
ECHO ______________________________________________________
ECHO Press 1,2,or 3
ECHO 1 - Save a screenshot
ECHO 2 - Delete previous settings and start over
ECHO 3 - Exit
ECHO ______________________________________________________
CHOICE /C:123 >nul
IF ERRORLEVEL 1 SET K=1
IF ERRORLEVEL 2 SET K=2
IF ERRORLEVEL 3 SET K=3
IF %K%==1 GOTO SKIPPEDthatPause
IF %K%==2 GOTO SETTINGS
IF %K%==3 GOTO FINISH

:SKIPPEDthatPause
ECHO[
ECHO Pulling framebuffer from /dev/graphics/fb0
adb pull /dev/graphics/fb0 frmbfr >nul
IF ERRORLEVEL 1 (cls
SET TS="NOGOOD"
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 START
)
SET TS=%DATE:/=%_%TIME::=_%
SET TS=%TS:.=%
SET TS=%TS: =%.png
FFMPEG %ffdebug% %ffshowb% -f rawvideo -vcodec rawvideo -pix_fmt %pixfmt% -s %widthwithstride%x%height% -i frmbfr -vf crop=%width%:%height%:0:0 -y %TS%
IF NOT EXIST %TS% GOTO ERRNE
DEL frmbfr >nul
ECHO ______________________________________________________
ECHO  Screenshot saved as %TS%
ECHO ______________________________________________________
ECHO Press 1 or 2
ECHO 1 - Save another screenshot
ECHO 2 - Exit
ECHO ______________________________________________________
CHOICE /C:12 >nul
IF ERRORLEVEL 1 SET K=1
IF ERRORLEVEL 2 SET K=2
IF %K%==1 GOTO SKIPPEDthatPause
IF %K%==2 GOTO FINISH

:NOFILES
CLS
ECHO The directory that you are running this script in is:
ECHO %~dp0
ECHO[
ECHO You must run this script in the same directory as
ECHO adb.exe and ffmpeg.exe. Press any key to exit
PAUSE >nul
GOTO FINISH

:ERRNE
CLS
MODE CON:COLS=108 LINES=200
COLOR 07
FFMPEG -loglevel debug -f rawvideo -vcodec rawvideo -pix_fmt %pixfmt% -s %widthwithstride%x%height% -i frmbfr -vf crop=%width%:%height%:0:0 -y %TS%
ECHO ____________________________________________________________________________________________________________
ECHO There was a problem converting the framebuffer to a png file.
ECHO[
ECHO To capture the screen of the cmd window, hold down the alt key and press PrtSc on your keyboard.  This
ECHO will save an image of the current window in memory on your clipboard.  Then open paint or photoshop or
ECHO whatever program you use and hit ctrl+N to open a new file, then ctrl+V to paste an image.  Save it and
ECHO please message me it or post in the XDA forum thread.
ECHO To see a list of all of the pix_fmts supported by ffmpeg, run ffmpeg -pix_fmts
ECHO[
ECHO Press 1 or 2
ECHO 1 - Show available pixel formats
ECHO 2 - Exit
CHOICE /C:12
IF ERRORLEVEL 1 SET K=1
IF ERRORLEVEL 2 SET K=2
IF %K%==1 (cls
MODE CON:COLS=52 LINES=200
ffmpeg -hide_banner -pix_fmts
pause
GOTO FINISH)
IF %K%==2 GOTO FINISH

:SETTINGS
IF EXIST settings.cfg DEL settings.cfg
IF EXIST temp.tmp DEL temp.tmp
CLS
ECHO Recovery Screenshot v1.0
ECHO ______________________________________________________
ECHO[
ECHO There is no current configuration saved
ECHO we'll make one real quick.  All I need is
ECHO your width, height, and you to select
ECHO from some images the correct screenshot.
ECHO Make sure you have adb working properly.
ECHO[
ECHO And also, your width, is the shortest
ECHO side of your phone/tablet. 
REM FOR /F "usebackq" %%A IN ('frmbfr') DO set fb0size=%%~zA
ECHO[
SET "pixfmt=rgb565,rgb565be,bgr24,rgb24,rgb32,argb,rgba,abgr,bgra,0rgb,rgb0,0bgr,bgr0,gbrp"
ECHO Enter your screen width...
SET /P width=Width?
ECHO[
ECHO Enter your screen height...
SET /P height=Height?

SET /a "stride=width %% 32"
SET /a "stride=32 - stride"
SET /a "widthwithstride=stride + width"
SET /a "framebufferpixels=widthwithstride * 2 * height"
SET /a "bytespp=fb0size / framebufferpixels"
ECHO[
ECHO Pulling framebuffer, and converting into several
ECHO png files for you.
ADB kill-server -d >NUL 2>&1
ADB pull /dev/graphics/fb0 frmbfr > nul
IF ERRORLEVEL 1 (cls
SET TS="NOGOOD"
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 SETTINGS
)
CLS
REM ECHO The width of your framebuffer is %widthwithstride%
SET line=
ECHO %widthwithstride% > temp.tmp
FOR /F "delims=" %%A IN (temp.tmp) DO SET line=%%A
ECHO %width% > temp.tmp
FOR /F "delims=" %%A IN (temp.tmp) DO SET line=%line% %%A
ECHO %height% > temp.tmp
FOR /F "delims=" %%A IN (temp.tmp) DO SET line=%line% %%A
REM echo %width% %height% %stride% %widthwithstride%
REM echo %framebufferpixels% %bytespp%
REM echo %fb0size%
SET TS=%_%.png
FOR /D %%A IN (%pixfmt%) DO call FFMPEG %ffshowb% %ffdebug% -f rawvideo -vcodec rawvideo -pix_fmt %%A -s %widthwithstride%x%height% -i frmbfr -vframes 1 -vf crop=%width%:%height%:0:0 -y %%A%TS%
ECHO Check in the folder you ran this program in and there
ECHO should be several images.  If any are a 'correct'
ECHO screenshot, make a note of what pixel format is in
ECHO the start of the filename. 
ECHO[
ECHO YOU MUST USE LOWERCASE LETTERS!
ECHO[
ECHO Example: file that is correct color is rgb565.png
ECHO then you would enter 'rgb565'
SET /p pixfmt=Pixel format?
REM IF %pixfmt%=none GOTO SORRY
ECHO %pixfmt% > temp.tmp
FOR /F "delims=" %%A IN (temp.tmp) DO SET line=%line% %%A
ECHO %line% > settings.cfg
DEL frmbfr
DEL temp.tmp
CLS
GOTO START

:FINISH
ADB kill-server -d
SET width=""
SET height=""
SET widthwithstride=""
SET framebufferpixels=""
SET bytespp=""
SET fb0size=""
SET TS=""
EXIT

:PROCESS
SET widthwithstride=%1
SET width=%2
SET height=%3
SET pixfmt=%4
GOTO GOTPARAMETERS

:SORRY
REM SLIM DOWN ORIGIANL PIXEL FORMATS, AND SOME RARER ONES HERE
GOTO FINISH

















Aucun commentaire:

Enregistrer un commentaire