Converting to/from RGB565 in Ubuntu using ffmpeg

I used ffmpeg to convert an image for my Android splash screen previously but couldn’t quite remember the right command.  The standard answer you’ll find on the internet is to use the rgb2565 tool included in the Android tools source.  Luckily there’s an easier way 🙂

Converting from RGB565 (to PNG)

ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s 320x240 -i image.raw -f image2 -vcodec png image.png

Converting to RGB565 (from PNG)

ffmpeg -vcodec png -i image.png -vcodec rawvideo -f rawvideo -pix_fmt rgb565 image.raw

Now I have custom Chumby boot screens! [Yeah wasn’t doing it for Android this time…]

3 thoughts on “Converting to/from RGB565 in Ubuntu using ffmpeg”

  1. Thank you for this! It was a big help. I used this for U-Boot splash images by using their tools/bin2header to encode the resulting 565 file.

  2. Thanks you!! You just helped me reverse engineer the image format of Hiptop II LCD screens!! I had what I was pretty sure might be an image buffer taken from ROM via JTAG. and I was looking for a way to display it. This worked the charm!!

  3. Thanks for the code, helps a lot.

    Facing a issue with using this
    ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s 640×480 -i image.raw -f image2 -vcodec png image.png

    image.raw has some modification done from x,y = 0,0, which accounts to 32×32 (1024 pixels) (like an overlayed image). But when converted back to a png file, it shows it being repeated on 4 additional times, which doesn’t make any sense, any suggestion?

Leave a Reply to Vikram Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.