maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   convert "cat /dev/fb0 > file.raw" to bmp or png...or... (https://talk.maemo.org/showthread.php?t=82559)

schasch 2012-02-24 11:58

convert "cat /dev/fb0 > file.raw" to bmp or png...or...
 
can someone give me a hint to convert a N900

"cat /dev/fb0 > screenshot.fb" to a screenshot.bmp? or png?

rewrite works: cat screenshot.fb > /dev/fb0

BUT:
ffmpeg does not work:
ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s 800x480 -i fb-n900.raw -f image2 -vcodec png screenshot.png

fb2png does work on gta2 openmoko, but bot for n900...
I guess the problem is the 32 bit color?


thanks for help
schasch

Hurrian 2012-02-24 12:40

Re: convert "cat /dev/fb0 > file.raw" to bmp or png...or...
 
Quote:

Originally Posted by schasch (Post 1169167)
can someone give me a hint to convert a N900

"cat /dev/fb0 > screenshot.fb" to a screenshot.bmp? or png?

rewrite works: cat screenshot.fb > /dev/fb0

BUT:
ffmpeg does not work:
ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s 800x480 -i fb-n900.raw -f image2 -vcodec png screenshot.png

fb2png does work on gta2 openmoko, but bot for n900...
I guess the problem is the 32 bit color?


thanks for help
schasch

The color is 24, not 32 bits.

schasch 2012-02-24 12:49

Re: convert "cat /dev/fb0 > file.raw" to bmp or png...or...
 
thanks Hurrian
24bit...

any idea how to convert?

schasch 2012-02-24 12:56

Re: convert "cat /dev/fb0 > file.raw" to bmp or png...or...
 
http://www.cnx-software.com/2010/07/...er-screenshot/

gimp does not work too??

>Then open the screenshot as a raw file (Select File Type: Raw Image Data) in Gimp2, enter the width and height as well of the color arrangement, RGB, RGBA etc…

schasch 2012-02-29 05:12

Re: convert "cat /dev/fb0 > file.raw" to bmp or png...or...
 
3 Attachment(s)
Hello, noone can give me a hint?

Nokia-N900-51-1:~# cat /dev/fb0 > /home/user/MyDocs/fb-n900-20120228.raw
Nokia-N900-51-1:~# cat /home/user/MyDocs/fb-n900-20120228.raw > /dev/fb0
...is wroking and brings the schot on the screen....

But how is the raw build inside?

FFMPEG:
-------------
user@ubuntu /screenshot-fb$ ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s 800x480 -i fb-n900-20120228.raw -f image2 -vcodec png screenshot.png
FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1.3, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --extra-version=4:0.5.1-1ubuntu1.3 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 1 / 52.20. 1
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libavfilter 0. 4. 0 / 0. 4. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Dec 21 2011 18:37:21, gcc: 4.4.3
Input #0, rawvideo, from 'fb-n900-20120228.raw':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0.0: Video: rawvideo, rgb565, 800x480, 25 tbr, 25 tbn, 25 tbc
Output #0, image2, to 'screenshot.png':
Stream #0.0: Video: png, rgb24, 800x480, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop encoding
av_interleaved_write_frame(): I/O error occurred
Usually that means that input file is truncated and/or corrupted.


...but like I wrote, rewrite in fb0 works, so not truncated/corrupted..


fb-n900-20120228.raw (=Screenshot from /dev/fb0)
screenshot.png (Screenshot-Result after ffmpeg the raw)
vnc.png (=Screenshot with VNC)

no ideas?

regards
schasch

jlancaster 2012-03-20 19:30

Re: convert "cat /dev/fb0 > file.raw" to bmp or png...or...
 
Try:
ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb32 -s 800x480 -i fb-n900.raw -f image2 -vcodec png screenshot.png

It worked for me.

alfmar 2016-09-27 21:56

Re: convert "cat /dev/fb0 > file.raw" to bmp or png...or...
 
N900 framebuffer memory map it's a bit weird.

cat /dev/fb0 outputs 1966080 bytes, that is 480 scanlines * 4096 bytes.

Only the first 1600 bytes (800 pixels, 16 bits each) are relevant; the following bytes overflow on next scanlines (that is: only 800*480*2=768000 bytes are the actual display image; the remaining 1198080 bytes are wasted duplicates).

Also, the /dev/fb0 format is 5-6-5 (5 bits red, 6 bits green, 5 bits blue), but is packed as 5-5-6 in big-endian (that is: first byte is bbbbbrrr, second byte is rrgggggg: green is in the 6 less significant bits of the 16-bit pixel value, blue is in the 5 high significant bits of the 16-bit pixel).

The following Ruby program fills the screen by only writing on /dev/fb0 (note: any video-related event causing Xorg refresh will redraw screen areas).
Code:

#!/usr/bin/env ruby

def rgb565 r, g, b
  r >>= 3    # shift to skip unused bits
  g >>= 2
  b >>= 3
  [ (r<<6) | g | (b<<11) ].pack('n')  # build & pack to 16 bits
end

samples = [ rgb565(255,0,0), rgb565(0,255,0), rgb565(0,0,255),
            rgb565(50,0,0), rgb565(0,50,0), rgb565(0,0,50),
            rgb565(0,255,255), rgb565(255,255,0) ]

File.open("/dev/fb0", "w") do |fp|    # open framebuffer for write
  480.times do |sl|                  # for every scanline:
    fp.seek sl*4096                  # update framebuffer pointer
    samples.each do |color|          # eight color samples:
      100.times { fp.write color }    # 100 pixels wide column
    end
  end
end



All times are GMT. The time now is 04:45.

vBulletin® Version 3.8.8