0

I'm trying to capture h264 with ffmpeg and send it to my virtual device. I can capture YUYV and send it with this command:

ffmpeg -f video4linux2 -s 1920x1080 -i /dev/video0 -vcodec copy -f v4l2 /dev/video3

Then I tried this to capture h264 instead of YUYV:

ffmpeg -f video4linux2 -input_format h264 -s 1920x1080 -i /dev/video0 -vcodec copy -f v4l2 /dev/video3

Then ffmpeg returns the error statement:

V4l2 output device supports only a single raw video stream

Does anybody know the correct command or what's wrong?

Tveitan
  • 288
  • 5
  • 14
  • Does the input video has more than one stream? i.e. audio and video – Maxito May 02 '15 at 07:37
  • Okay, so more than one stream means that it captures audio as well. Thank you for that clarification. I do not know if it is capturing audio and video. It's an Logitech C920 and it has an microphone. So I would presume that it moste likely is capturing sound at the same time as the video. Do you know how I would turn it into a single raw video stream? – Tveitan May 02 '15 at 12:09

1 Answers1

0

Like the error message states it needs a single, raw video stream and not a H.264 raw stream:

if (s1->nb_streams != 1 ||
       s1->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
       s1->streams[0]->codec->codec_id   != AV_CODEC_ID_RAWVIDEO) {
       av_log(s1, AV_LOG_ERROR,
               "V4L2 output device supports only a single raw video stream\n");
       return AVERROR(EINVAL);
}

FFmpeg/v4l2enc.c on GitHub

You are using -input_format h264 with -vcodec copy. You must change it to -vcodec rawvideo or omit it entirely for the v4l2 output format. You might also need to set the correct pixel format.

aergistal
  • 29,947
  • 5
  • 70
  • 92
  • Okay, but how would I proceed to convert the H.264 raw stream to a single raw video stream? Is that something that I would need to change on the camera settings with "v4l2-ctl" or is it just a matter of using an ffmpeg command? – Tveitan May 02 '15 at 12:02
  • Updated the answer. You cannot use `-vcodec copy` if your input is `h264`. – aergistal May 02 '15 at 20:25
  • 1
    Linking your related GStreamer/v4l2sink solution for the reader's benefit: http://stackoverflow.com/questions/29991677/how-to-catch-stdout-stream-in-ffmpeg-then-pipe-it-to-v4l2loopback/30000709#30000709 – aergistal May 02 '15 at 21:16
  • As I said in the other post. I can't get it working for now. It may be because of an outdated v4l2loopback driver. I'll post here as soon as I get something working! :) – Tveitan May 04 '15 at 19:02
  • try ffmpeg -i http://... -pix_fmt yuv420p -c:v rawvideo -f video4linux2 /dev/video1 – Peter Fleix Dec 12 '20 at 08:45