使用下面的命令,我试图捕获10 and并将设备驱动程序发送给它们。现在,我希望将8位灰色原始帧(每帧640x480= 307200字节)发送到设备驱动程序。我不知道如何用ffmpeg或inputwithv4l2将输出设置为这种格式。
ffmpeg -f v4l2 -r 25 -s 640x480 -i /dev/video0 -f rawvideo "/dev/devicedriver"ffmpeg似乎不支持8位灰色输出。使用v4l2,我不知道如何设置它。它似乎没有对V4L2_PIX_FMT_GREY进行重新定位。
v4l2-ctl --set-fmt-video-out=width=640,height=480,pixelformat=V4L2_PIX_FMT_GREY我想出了一个结合python、opencv和ffmpeg的解决方案:
import cv
import sys
import os
import time
camera_index = 0
capture = cv.CaptureFromCAM(camera_index)
count = 0
def repeat():
global capture
global camera_index
global count
frame = cv.GetMat(cv.QueryFrame(capture))
framegray = cv.CreateMat(480, 640, cv.CV_8UC1)
cv.CvtColor(frame, framegray, cv.CV_BGR2GRAY)
sys.stdout.write(framegray.tostring())
c = cv.WaitKey(1)
if c == 27:
print count
sys.exit()
while True:
repeat()然后把它吹到
python capturewebcam.py | ffmpeg -f rawvideo -pix_fmt gray -s 640x480 -i - -an -f rawvideo -r 10 "/dev/null"但我认为,这真的必须是可能的,只有ffmpeg和v4l2,我不知道如何。我的头因阅读文件而感到头痛。
发布于 2013-08-11 00:28:28
首先,输出设备驱动程序支持检查像素格式:
v4l2-ctl --list-formats -d /dev/devicedriver要传递给v4l2-ctl命令行的像素格式是结果中显示的四in,例如:
Pixel Format : 'YUYV'在这种情况下,命令行是:
v4l2-ctl --set-fmt-video-out=width=640,height=480,pixelformat=YUYV如果您需要V4L2_PIX_FMT_GREY,那么该4‘t可能是“灰色”(我猜从视频dev2.h开始,无法检查)
如果没有列表格式命令的结果,驱动程序就不支持它,因此需要将源(输入/摄像机)格式转换为输出。
https://unix.stackexchange.com/questions/85849
复制相似问题