AndrewFromMelbourne / raspi2png

Utility to take a snapshot of the Raspberry Pi screen and save it as a PNG file
MIT License
213 stars 78 forks source link

write to stdout #5

Closed ktsaou closed 4 years ago

ktsaou commented 10 years ago

Thank you very much for raspi2png!

I would like to make 2 suggestions:

  1. It would be useful to support writing to stdout. I normally snapshot the pi screen to send it to a web page. Now I do something like this using inetd:

    echo "HTTP/1.1 200 OK"
    echo "Content-type: image/png"
    echo
    raspi2png -p "/run/snapshot-$$.png" -h $h -w $w
    cat "/run/snapshot-$$.png"
    rm "/run/snapshot-$$.png"

    The extra effort to save and delete the image could be avoided if raspi2png could just write the png image to its stdout.

  2. raspi2png is somewhat slow. I don't know if this is because I need it to scale the image, or because the png compression is too complex for a pi.

    In any case, it would be perfect if you could speed it up (for example the OMX API may already provide hardware scaling, or it may provide hardware JPEG encoding - I guess it does both because raspistill is a lot faster, capable of capturing and saving many JPEG frames per second - of course from the camera, not the screen).

Anyway, thank you very much. Even the way it is now, raspi2png is very helpful.

AndrewFromMelbourne commented 10 years ago

Hi,

  1. It would be easy enough to support writing to stdout. I will commit something as soon as I can.
  2. I am not surprised that raspi2png is reasonably slow. There are plenty of bottle necks, my guess would be the disk I/O is the slowest part, I could be wrong. The scaling is done by the GPU, so that should be fast enough. Yes, using OMX (or MMAL which is used by raspistill) may speed things up significantly, but it is not something I want to take on right now. I think for most use cases the current speed is fine.

Thanks for the kind words!

ktsaou commented 10 years ago

OK. Perfect!

Just a note, I write to /run which is tmpfs. This is the way I use raspistill too. SD cards are awfully slow.

As I said. Everything is good even the way it is now.

Thanks.

ktsaou commented 9 years ago

Hi again.

In case it is useful to you, I found https://github.com/info-beamer/tools/tree/master/screenshot, that outputs JPEG and is fast enough (I measured more that 5 screenshots per second). It doesn't scale or rotate the image though. It also seems pretty simple code...

Thanks.

AndrewFromMelbourne commented 9 years ago

Sorry for the long delay. Thanks for that, so hopefully that is a solution for you. I actually wrote a program that I called raspi2jpg before I wrote raspi2png, but I never put the code up on github.