yashsingh1/xdaforums huggingface dataset:
[HTC One X] HQRaja:
Hello,

Great work on the script - it seems to be the only way that works for me to take screenshots of TWRP in recovery. However, there's a slight problem when using it on my Nexus 4 - the screenshot has a cyan tint applied all over it. I need to feature TWRP screenshots in a detailed review, and need them to be accurate. Can anyone offer a fix (or suggest something that might fix it)? It *likely* has to do with the type of encoding the Nexus 4 framebuffer uses, I'm guessing. Though not absolutely sure on that. Any help will be greatly appreciated.
[HTC One X] Whiskey103:
No solution as of yet, but you are right about the fb0, just we have no idea how to proper extract the shots due to the different settings used.

Tried a lot of ffmpeg values already but no luck.

RGB, BGR, xRGB, RGBX etc etc.
[HTC One X] HQRaja:
OK I found a way that works in command line:

adb pull /dev/graphics/fb0
ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgba -s 768x1280 -i fb0 -f image2 -vcodec mjpeg fb%d.jpg

(Found it here)

This seems to create accurate output, though it ends up creating three files; the first two being identical (and both accurate) while the third one being blank. Still, works just fine. Now if it could be incorporated into the script...

On another note, neither the script nor the above commands seem to work for me with the Nexus 10. The script says "Failed to read framebuffer." in the output, while using adb pull on /dev/graphics/fb0 says "failed to copy '/dev/graphics/fb0' to './fb0': No such device". I'm guessing the device uses a path other than /dev/graphics/fb0 for its framebuffer. Can anyone identify the correct path? The rest should work (in theory).
[HTC One X] Whiskey103:
The problem isn't pulling the fb0, the problem lays in deciphering the fb0 the proper way or creating it using the proper values.

Iam playing with that ffmpeg line for weeks but still don't get the correct screenshots.

That line is used in fb2png already it's just not working on all devices :(

Also it's not that easy as all OEMs seems to do it differently kernel wise/android versions etc.

I don't think there will ever be a universal way. To much variables out there.
[HTC One X] HQRaja:
Yup, pulling it is simple enough for most devices (though not for Nexus 10, it seems...can't manage it). The above command seems to decipher it just fine on the Nexus 4, the tint's gone.

And I agree - there will be no universal method for it. Though one idea would be to edit this script to perhaps check for the device, and use the method that we know to work for certain devices. For instance, now that we know rgba works fine for Nexus 4, use that if the device gets detected as Nexus 4, and the appropriate ones for the rest. For unknown devices, it can perhaps prompt the users to choose one of the known encodings themselves?
[HTC One X] wpkwolfseye:
Works like a charm on my NOTE 2. ;) Thank you so much.

Cheers

Wolfseye
[HTC One X] Sneakyghost:
Lol Whiskey and friends thanks for all this work... if i had only searched more it had saved me a hell of a lot of work.

I basically came up with the exact same ffmpeg solution.

Maybe for future reference: if you want to decipher what settings to use to decode your Fb0, Gimp's file open dialogue is a huge help as it has some sliders to play with values while it displays the changes in realtime. [MENTION=4174733]Behold_this[/MENTION] pointed that out to me while i was searching for the right settings to shoot screenies of the older twrp (using rgb565). Later finding out about what RGB8888 means to ffmpeg was a hitch then when TWRP updated to the new pxl format.

See my pains here: DarkViper TWRP Theme (qHD) using this as a little advertiser too, maybe someone wants to grab my theme and port it to your resolution... :laugh:
[HTC One X] Whiskey103:
Ah, thanks.... Will add your comments to the OP. So it won't be overlooked :)
[HTC One X] egren58:
Can someone make a video I coildnt get what I need from thw op all I need is the zip?.. ok but what xomands I type etc. Very confused

Sent from my SGH-T999 using Xparent Skyblue Tapatalk 2
[HTC One X] Whiskey103:
All is in the zip. You just have to run the bat file. It will run the adb commands for you.

You still need your device drivers ofcourse.

Seeing you are not using One X I have no idea what drivers you need for Samsung.

But if you are used to work with adb and fastboot it should work I guess.
[HTC One X] Phil3759:
Hi,

I added many fixes to original fb2png with the help of [MENTION=4464223]McKael[/MENTION] and mainly the support for ABGR8888 for the Nexus 4

These changes were merged into latest official sources you can get from google repo for fb2png or from my repo under the PhilZ Touch project with embedded fb2png source to compile as a static binary along recovery instead of as a shared as original

However, some devices like many HTC phones (One, One X, some google devices) still fail and return corrupted shots

I see your binary works for the One X while my recent commits don't

Any hope you share your modifications to the source so that we can merge them and enhance compatibility for other devices?
[HTC One X] Whiskey103:
Well, I just used the fb2png as provided in the project.

It worked for One X out of the box hence I never changed a single thing.

Hence no source other then the project source provided seeing I didn't edit it.

So you should look at the original code and compare with the different versions out there to spot the issue iam afraid.

Wish I could help, btw great job on your recovery!
[HTC One X] Phil3759:
Ah, thank you. Maybe some board versions or the newer libpng/zlib versions i used

I will try original code and see if it fixes

By the way, instead of playing with that line discussed above, we could add command line options support to force rendering in one of the supported modes. What do you think? It is easy to do and i could merge it if the issue is only related to the mode detection and not something else
[HTC One X] Whiskey103:
Well I discussed few ideas with Patrics83 such as adb device detection and use working binary/parameters based on device.

But that would be a massive job hence we kinda let it slide.

It could ofcourse be handy if the device detection is build in the binary and automatically uses the proper parameters for it.

As suggested above somewhere.

Thing is we also are not sure it's just the mode detection as there are multiple reports, mismatch colors, wrong alignments etc etc.

So i would be very greatfull ofcourse if you see some openings.

Feel free to "abuse" this thread for testing purposes to get feedback from various users/devices.

I tried a thread in android general with that purpose kinda but didn't get much response.

Perhaps with your help we can extend.

Also have been in contact with the author and he is also lookin into it.

Perhaps when we work all together we can make it happen ;)

XDA back to the basics... Yayyyyy :)
[HTC One X] Phil3759:
Bad news (or good): users report my version is ok on the One X. So, unless you have one of the non working phones, it will be hard for me to post debug versions here.

I just posted in all my threads to ask about fb2png working or not. That way i get a list of devices with issues and start to work on them

The non working phones do not error about unsupported mode but return a corrupted png. So, i would first add some debugging code to trace the detected mode for the affected device. After that, we know if it is an error in detection or if it is the processing of data that fails on some devices.

If it is only the mode detection, adding command line options is one easy way to fix it for good. If it is the processing, it would need a deeper look in code i fear
[HTC One X] EVOuser94:
I have a HTC EVO 4G LTE if you want me to test something to get this working count me in! I have recently found out that we now have a recovery that is based in RGBX_888 if that helps
[HTC One X] Phil3759:
Still looking at it got some debugging for the htc fireball. Will start there first
[HTC One X] Phil3759:
Hi,

I am back to you with some mixed news

First, I opened a git repo here:

https://github.com/PhilZ-cwm6/fb2png-debug

The last commit will dump the raw data that fb2png actually reads (file will be created in /sdcard/fbshot.raw)

This is before any processing, so should not fail unless fb2png fails to read the buffer

That way, we get a raw data to process offline quietely

This modified version (0.8) can be downloaded here:

http://d-h.st/users/philz_touch/?fld_id=17004#files

I also added a line to detect double buffer (not sure about it though) and some changes to the rgb565 to rgb888 matrix

However, all this is useless it seems as the input doesn't match a standard rgb565 for many htc devices and even last Samsung i9505

This is just a start, so that maybe someone with more knowledge on this graphics ciphering and device kernel sources can help
[HTC One X] EVOuser94:
Hey I just tried this on the EVOLTE and the image i'm getting now is definately getting closer!!!! THANK GOD!! and of course you Phil...and WHISKEY =P you guys are gods among men!
[HTC One X] Sloth:
Hi I just tried on the HTC One Sprint variant was a no go just throwing it out there not complaining

TWRP v2.5.0.0

Update I tried phil's version This modified version (0.8) can be downloaded here:

Same result

Update 2 the file from the OP worked on my Nexus 7 (grouper)
[HTC One X] Phil3759:
Would be great if you post the log you get onscreen whith the version that works for you

This is to see if it is the offset or my rgb changes to the matrix

Well, it means playing with the offset can fix it for some devices. Issue is that we need to deeply dig into kernel sources for each device and I have no time to start working on such a thing
[HTC One X] Sloth:
How do I do that? :D
[HTC One X] Phil3759:
file in the op is same as the one here

https://code.google.com/p/android-fb2png/downloads/list

However, you just need to run it from adb shell console (windows or linux)

adb push fb2png /sbin
adb shell
chmod 0775 /sbin/fb2png
/sbin/fb2png

this will give you the log in the adb shell window
[HTC One X] Sloth:
I can't get it to work I have always had driver issues with this Nexus 7

It was being recognized by my PC before I started running the commands but after running the first command it is not recognized anymore.

I have tried uninstalling the drivers/reboot PC/re-install drivers and nothing

Sorry I could not be of more help. :(
[HTC One X] Phil3759:
If you install my recovery for Nexus 7, it has fb2png embedded

You double tap outside a menu to open Aroma File Manager (you have to put it on your sdcard though, see tut in main thread from my signature)

You open terminal console inside Aroma while in recovery

In terminal, you just type fb2png

You will see the log

If it exceeds the screen, use:

fb2png /sdcard/pic.png >>/sdcard/fb2png_log.txt

And post the /sdcard/fb2png_log.txt here
[HTC One X] Sloth:
bpp : 16

size : 2048000

width : 800

height : 1280

ARGB offset : 0 11 5 0

ARGB length : 0 5 6 5

Framebuffer Pixel Format: 1

Is this what you need?
[HTC One X] Phil3759:
Yes, great

And you got a good pic with that or is it corrupted?
[HTC One X] Sloth:
It is the good one from here
[HTC One X] Phil3759:
Very nice. It shows that the rgb conversion matrix is good and mine is bad

I have a last request, if you do not mind:

Download the 0.9 version here: http://d-h.st/rrb

Put it into /data/local while booted in main system and chmod it to 0775 (using root explorer or terminal chmod 0775 /data/local/fb2png)

Reboot into recovery

Start Aroma file manager console and type

/data/local/fb2png

I am interested in the /sdcard/fbshot.raw file you will get + the log if it says something like "Using double buffer"

If you can upload the raw image somewhere, would be great

That way, I can compare to the rdb565 buffer I got from non working devices

I will try to work on line length based on device sources

Thanks in advance
[HTC One X] Sloth:
here is the log

It's not letting me move the fbshot.raw file from my device
[HTC One X] Phil3759:
Can't you copy it?
[HTC One X] Sloth:
I tried to copy it to my desktop on my PC

I used Es File Explorer to move it to a folder tried copying that folder to my desktop the folder was empty when I looked inside

I even tried to email it to my PC

None of which worked
[HTC One X] Phil3759:
Maybe your sdcard was not mounted when you used it in recovery. So, it created a /sdcard folder in root, which is a temporary ramdisk removed on reboot

Just make sure you mount sdcard before starting fb2png in recovery

Only the version 0.9 will dump that raw image too in /sdcard/fbshot.raw
[HTC One X] Sloth:
I'm still kinda new to adb pull/push maybe if you give me the path I could pull it

It's on my sdcard in a folder called fbshot
[HTC One X] Phil3759:
It should be /sdcard/fbshot.raw file, not in anyfolder

adb pull /sdcard/fbshot.raw
[HTC One X] Sloth:
Now I'm getting permission denied

I also tried adb shell

su

then the pull command

said device not found
[HTC One X] Phil3759:
You have a datamedia device

So, sdcard should be always mounted, not the issue

Maybe bad permissions, despite I have created them

try to chmod the file:

chmod 0775 /sdcard/fbshot.raw

Ensure you are in the correct place, either /data/media or /data/media/0
[HTC One X] Phil3759:
Cannot you see the fbshot.raw when booted in main system?

it could be under /data/media/fbshot.raw if you did not set your recovery to use /data/media/0
[HTC One X] Sloth:
it shows up here

/data/media/fbshot.raw

I ran the chmod 755 command and still get permission denied

---------- Post added at 05:40 AM ---------- Previous post was at 05:34 AM ----------

Sorry to say but it's 540am here time for me to go to bed sorry I couldn't help more
[HTC One X] Phil3759:
Strange, it never caused any issue on my system or others who tested it

You could run from adb shell

umount /data
e2fsck -fv /dev/block/platform/sdhci-tegra.3/by-name/UDA

To check your /data partition for errors
[HTC One X] Sloth:
C:\Users\Me\Desktop\ADB-Fastboot_Nexus>adb shell

root@android:/ # umount /data

umount /data

failed: Device or resource busy

1|root@android:/ #
[HTC One X] Phil3759:
Argh

Better you go sleep as it seems to be more complicated

Sorry, have no idea how to fix your issue
[HTC One X] Sloth:
No worries have a good day :D

Sent from my Liquid Smooth Nexus 7 :p
[HTC One X] Whiskey103:
[MENTION=4666971]Phil3759[/MENTION] nice work so far mate...real nice!
[HTC One X] shakatu:
Works great on my tablet for TWRP to show off my modified theme.

My tablet won't even mount in CWM, but that doesn't matter cuz I never use CWM :p but it could be nice to have a screenie...

Thanks for the work!
[HTC One X] stillthisguy:
Do you mind sharing the scripting used to name/tag with timestamps?
[HTC One X] EVOuser94:
Its in the code of the bat I do believe...
[HTC One X] stillthisguy:
I have already checked the bat file, it is not in there. I believe it is in the dump file.

Edit, yep, it was in the dump file. I found it.
[HTC One X] w3thax:
Doesn't work on HTC One. It gives only strange Screenshots like this one.
[HTC One X] qu4nd:
Same here on Galaxy Nexus...

My screenshots look just like the one above :(
[HTC One X] tessut:
Pls flash recovery 2 times
[HTC One X] qu4nd:
What exactly is this good for?
[HTC One X] Sloth:
Guys that make TWRP themes can showcase them
[HTC One X] qu4nd:
I have to flash TWRP 2 times to make the screenshots look correct? :confused:
[HTC One X] Sloth:
It does not work on all devices they are trying to make it work on all
[HTC One X] raimondomartire:
Some problem for me on Htc One.
[HTC One X] Whiskey103:
Thread closed due to ppl not reading :(

Edit: Please ppl READ READ and once done..yeah read again.

When done watch this:

[youtube]JmvCpR45LKA[/youtube]

Done? So now there is a slight possibility you did read the thread and noticed:

Its for ONE X...see ONE X..... so never supposed to work on HTC ONE.

However i just talked to Phil3759 and he is still trying to find out how to make it HTC One compatible.

In the mean time...yea we know its not working yet ;)
[HTC One X] w3thax:
Thank you. Just didn't see it. -.- Came from Google and didn't looked which forum we are here...

Hope it works on the One soon.

Ah and: great video.

Gesendet von meinem HTC One mit Tapatalk 4 Beta
[HTC One X] antutu:
working awsome in my GT P3100

I'm using Philz Recovery 5.0.6.1
[HTC One X] Whiskey103:
For the ppl that wanted a solution for making screenshots in recovery on HTC ONE M7

http://www.whiskey103.nl/x/screenshotutil/ScreenshotFFMPEG_M7.rar

thx to Sneakyghost for the ffmpeg values

extract en run the batfile

Its runs the following code:

@echo off
echo ********************************************
echo * *
echo * ADB-Screenshot Util *
echo * Boot into Recovery *
echo * Plug In USB Cable *
echo * Enjoy ;) *
echo * *
echo ********************************************
echo.
pause
echo.
adb kill-server -d >nul 2>&1
adb pull /dev/graphics/fb0 fb0
ffmpeg -vframes 1 -f rawvideo -pix_fmt rgba -s 1088x1920 -i fb0 screenshot.png
del fb0
echo.
echo ********************************************
echo * *
echo * Output saved as screenshot.png *
echo * *
echo ********************************************
echo.
pause
[HTC One X] CNexus:
Slight typo, it should be 1080x1920, not 1088x1920

Sent from my S3 on Sense 5 (you jelly?)
[HTC One X] Whiskey103:
yeah.. try it with 1080 ;)
[HTC One X] Phil3759:
Great news there

So, the framebuffer can be decrypted, unlike what many have pretended. Was sure it was not impossible, but just settings to figure out

If someone drops here the fb0 file from HTC One, I will look again at fb2png source to try to fix it
[HTC One X] Whiskey103:
Here you go ;)

http://www.whiskey103.nl/x/index1.php?dir=temp/&file=fb0
[HTC One X] EVOuser94:
Now if we could figure out the HTC Evo 4G LtE
[HTC One X] Sloth:
Whiskey103 and Phil3759 you are both awesome :D

The screenie is from my HTC One Sprint Variant

Is there a way for us users to edit the size(1080x1920) or is that something that has to be done on your side?
[HTC One X] Whiskey103:
What do you mean? The output file in a different size?

The script just pulls the fb0 buffer and ffmpeg deciphering it to a png in the devices default screenres. Oké the ffmpeg is slightly off since it's using 1088 but 1080 native corrupts the output.

If you want a difference size you have to resize it yourself with Photoshop, Gimp or whatever photo tool available.
[HTC One X] Sloth:
Yeah it comes out 1088x1920 and that's what I did was resize it

Again thanks for all your hard work :D
[HTC One X] CNexus:
Hmm..what I'm wondering is why 1088

It seems like a random choice/guess/thing

Or how Sneakyghost calculated that number...

Sent from my S3 on Sense 5 (you jelly?)
[HTC One X] Whiskey103:
Most likely endless trial and error till the values came up with a correct output.

No idea why the resolution is slightly off, but I don't bother that much.. It works ;)
[HTC One X] CNexus:
Of course, the short answer is "Because it works" :p

But just wondering...haha, must have been tedious, slowly incrementing the command by one pixel at a time
[HTC One X] Primokorn:
I'm still trying to use this tool but I always have this error:

I unzipped the file "screenshot.rar" on my desktop and ran as Administrator...
[HTC One X] Whiskey103:
What phone are you using?

What recovery do u have?

You can try to manually mount partitions in recovery first.
[HTC One X] Patrics83:
I bet it will work if he CD to 'desktop' and then execute the script.

Edit: it couldn't mount /data because it was already mounted. So the mounting code works

Sent from my HTC One X
[HTC One X] Primokorn:
I have a Galaxy Note II GT-N7100 with TWRP v2.6.0.1.

A friend who has the same phone and recovery (v2.6.0.0) has no problem so I don't understand what could be the reason.
[HTC One X] Whiskey103:
Explains it i guess ;)

Edit : didn't notice the same phone story.

Well extract rar, open folder... Double click bat file, can't imagine what can go wrong tbh.
[HTC One X] Primokorn:
I've done a new test. I did a full wipe then flashed a new rom (P.A.C.) but I still have the same error.

As mentioned a friend with the same phone/rom/kernel has no problem.

FYI my phone is recognized by my computer.
[HTC One X] Whiskey103:
Yea, well no idea.. I don't have that phone... It's not build for that phone either so what to expect huh.

I really can't help it sry.
[HTC One X] Primokorn:
Yes!!! :D

It works now! I don't know if it could be the reasons of my problem but here is what I did compared with my previous attempts:

1/ Plug the phone in usb to my PC when I was on my homescreen and not after running .bat file.

2/ Run your .bat file via a double clic and not "run as administrator"

3/ Reboot in TWRP recovery
[HTC One X] Whiskey103:
yes was talking to Patrics about that and if you have to do the "run as admin" it seems the batfile picks wrong path.

Once double click on the file it stays in the folderpath and finds the files.

Ow well, glad it works for you now ;)
[HTC One X] Android-Andi:
Any Idea?

(Works perfect on Galax Tab 2 7.0, CWM & PhilZ Touch)
[HTC One X] discours:
Hi,

with Xperia Ray (st18i) always "device not found"

however , I use ADB daily ????
[HTC One X] korbeny:
This is very useful. I tested on TWRP in my LG P500 and works very well. :good:

Also I did a few changes in the batch file: added a very simple menu, because for so many captures, it necesary run the bat file time and time again.

Here is my updated script:

@echo off
cls
echo.
echo ******************************************************
echo * *
echo * ADB-Screenshot from Recovery *
echo * *
echo * Original idea: Kyan He *
echo * code.google.com/p/android-fb2png *
echo * *
echo * Script: Whiskey103 *
echo * xdaforums.com/showthread.php?p=40260716 *
echo * *
echo * Script update: Korbeny *
echo * *
echo * ADB version: 1.0.31 (August 2013) *
echo * *
echo * Instructions: *
echo * - Boot into recovery *
echo * - Plug in USB cable *
echo * When ready press a key to continue *
echo * *
echo ******************************************************
echo.
pause
cls
adb devices
goto option
:option
cls
echo.
echo.
echo.
echo 1.- Make a screenshot
echo 2.- Exit
echo.
set /p choice=Type the number of your choice
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto screenshot
if '%choice%'=='2' goto exit
cls
echo.
echo.
echo.
echo "%choice%" is not a valid option. Please try again
echo.
echo.
pause
goto option
:screenshot
cls
adb shell mount /data
adb push fb2png /data/local/
adb push dump /data/local/
adb shell chmod 755 /data/local/fb2png
adb shell chmod 755 /data/local/dump
adb shell /data/local/dump
adb pull /data/local/ScreenShots
adb shell rm /data/local/fb2png
adb shell rm /data/local/dump
adb shell rm -r /data/local/ScreenShots
echo.
echo.
echo ******************************************************
echo * *
echo * The screenshot was taken successfully *
echo * *
echo ******************************************************
echo.
echo.
adb shell sync
adb shell umount /data
pause
goto option
:exit
cls
echo.
echo.
echo.
echo ******************************************************
echo * *
echo * The screenshots are stored in the ADB folder *
echo * named as Screenshot_date_time.png *
echo * *
echo ******************************************************
echo.
echo.
pause
exit

And the rar file: https://app.box.com/s/pjb8qnk0tbzg10ly1ngb
[HTC One X] ttersu:
Hi evry one,

Does anyone was able to use it with a S4 i9505 (with PhilZ Recovery)?
[HTC One X] Whiskey103:
That's nice, thank you very much.... Didn't see your edit until now.... Will add it to OP asap.
[HTC One X] android addicts:
finally this method work on my s3. Thank you so much.
[HTC One X] huchengtw:
Linux and Mac OS X porting

Hi all,

This is a great tool. But I am not using Windows box. So, I make a port of Windows version to Linux and Mac OS X. Hope you guys will love it.

You may find all files at github: https://github.com/john-hu/android-recovery-screenshot.

For more information, please find at http://john.hu/android-recovery-screenshot