系統:Ubuntu 10.10
啟動: ./start.sh
錯誤內容:
[email protected]:~/mjpg-streamer/mjpg-streamer-experimental# ./start.sh
MJPG Streamer Version: svn rev: 3:160
i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 640 x 480
i: Frames Per Second.: -1
i: Format............: JPEG
Unable to set format: 1196444237 res: 640x480
Init v4L2 failed !! exit fatal
i: init_VideoIn failed
錯誤原因:
市面上大部分攝像頭都是支持YUV的,而不是JPEG的。mjpg-stream支持JPEG和YUV兩種格式。
[www.linuxidc.com@linuxidc mjpg-streamer]$ cd mjpg-streamer-experimental/plugins/input_uvc/
[www.linuxidc.com@linuxidc input_uvc]$ vim input_uvc.c
int input_init(input_parameter *param, int id)
{
char *dev = "/dev/video0", *s;
int width = 640, height = 480, fps = -1, format = V4L2_PIX_FMT_MJPEG, i;
/* initialize the mutes variable */
if(pthread_mutex_init(&cams[id].controls_mutex, NULL) != 0) {
IPRINT("could not initialize mutex variable\n");
exit(EXIT_FAILURE);
}
......................
format = V4L2_PIX_FMT_YUYV
以上就設置了默認的圖像格式,重新把模塊編譯,之後就成功了!