Alexandre34
Posts: 21
Joined: Sun Jan 31, 2016 6:18 am

omxplayer framebuffer

Tue Mar 29, 2016 7:55 am

Hello.
I need for a projet to make a screen snapshot of the HDMI output. So I use the framebuffer ( /dev/fb0 ) and make a picture from the pixel.
Unfortunatly, it seems that video played with omxplayer doesn't use framebuffer, because if I see the video on the screen, I don't see her in the picture.
Does somebody knows how to make a snapshoot of a screen including the omxplayer output ?

Bellow is the code I use to initialize the framebuffer:

Code: Select all

    /// initialise framebuffer
    int fbfd = 0;
    struct fb_var_screeninfo orig_vinfo;
    long int screensize = 0;


    // Open the file for reading and writing
    fbfd = open("/dev/fb0", O_RDWR);
    if (!fbfd)
    {
        printf("Error: cannot open framebuffer device.\n");
        return(1);
    }
    printf("The framebuffer device was opened successfully.\n");

    // Get variable screen information
    if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo))
    {
        printf("Error reading variable information.\n");
    }
    printf("Original %dx%d, %dbpp\n", vinfo.xres, vinfo.yres,
           vinfo.bits_per_pixel );

    // Store for reset (copy vinfo to vinfo_orig)
    memcpy(&orig_vinfo, &vinfo, sizeof(struct fb_var_screeninfo));

    // Get fixed screen information
    if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo))
    {
        printf("Error reading fixed information.\n");
    }

    // map fb to user mem
    screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
    fbp = (char*)mmap(0,
                      screensize,
                      PROT_READ | PROT_WRITE,
                      MAP_SHARED,
                      fbfd,
                      0);

    if ((int)fbp == -1)
    {
        printf("Failed to mmap.\n");
    }

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: omxplayer framebuffer

Tue Mar 29, 2016 8:05 am

Have a look at https://github.com/AndrewFromMelbourne/raspi2png
I think it does what you are looking for

Alexandre34
Posts: 21
Joined: Sun Jan 31, 2016 6:18 am

Re: omxplayer framebuffer

Thu Mar 31, 2016 11:06 am

Yes, exactly what I need..
Thank you.

Return to “Media centres”