With the following command i'm trying to capture 10fps and send them the device driver. Now i want 8 bit gray raw frames (640x480= 307200 bytes per frame) to be send to the device driver. I can't figure out how to set the output with ffmpeg or the intput with v4l2 to this format.
ffmpeg -f v4l2 -r 25 -s 640x480 -i /dev/video0 -f rawvideo "/dev/devicedriver"
ffmpeg doesn't seem to support 8-bit gray output. And with v4l2 i can't figure out how to set it. It seems it doesn't recoginize V4L2_PIX_FMT_GREY.
I came up with a solution combining python, opencv and 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()
and then pipe it to ffmpeg
python capturewebcam.py | ffmpeg -f rawvideo -pix_fmt gray -s 640x480 -i - -an -f rawvideo -r 10 "/dev/null"
But i think it really has to be possible with just ffmpeg and v4l2, and i can't figure out how. My head hurts from reading the documentation :p.