Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't change video manually #33

Open
hankTaro opened this issue May 24, 2023 · 1 comment
Open

Can't change video manually #33

hankTaro opened this issue May 24, 2023 · 1 comment

Comments

@hankTaro
Copy link

I wrote the test.c as below

#include <fcntl.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <unistd.h>

static char fb_path[128] = "/dev/fb1";
static int fd;

void signal_exit_handler(int sig)
{
    close(fd);
    exit(0);
}

int main()
{
    signal(SIGINT, signal_exit_handler);
    fd = open(fb_path, O_RDWR);
    unsigned char rgb[3] = {10, 60, 128};
    while (1) {
        for (int i = 0; i < 480; i++) {
            for (int j = 0; j < 640; j++) {
                write(fd, rgb, sizeof(rgb));
            }
        }
        for (int i = 0; i < 3; i++) {
            rgb[i]++;
        }
    }
    return 0;
}

after compile I enter this command

./test # terminal 1
vlc v4l2:///dev/video2 # terminal 2

but video is still the original black and white gradient picture

@jserv jserv changed the title can't change video by running following program Can't change video manually May 24, 2023
@AGenchev
Copy link

AGenchev commented Sep 27, 2023

It works for me, thanks !

But it eats all CPU time because you write byte-by-byte onto the framebuffer.
I modified it to have own framebuffer and dump it onto the fd at once. Also limited it to 30FPS to limit the cpu usage.
I suggest you to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants