Opened 7 years ago

Last modified 7 years ago

#6249 new enhancement

v4l2 output encoder does not support h264 (only raw)

Reported by: rogerbrent Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: v4l2
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Using tools such as v4l2loopback it's useful to create a virtual v4l2 device and write h264 video to it. Unfortunately this isn't supported by ffmpeg, this gives an error:

ffmpeg -i X -c:v h264 -f v4l2 /dev/video0

Note this is possible with other software like v4l2compress_h264.

Change History (4)

comment:1 by Carl Eugen Hoyos, 7 years ago

Keywords: v4l2 added

Would you like to tell us about the error?

Please test current FFmpeg git head and provide your command line together with the complete, uncut console output to make this a valid ticket.

comment:2 by rogerbrent, 7 years ago

pi@raspberrypi:~$ ./ffmpeg -f v4l2 -i /dev/video0 -c:v h264 -f v4l2 /dev/video1
ffmpeg version git-2017-03-12-ff17c76 Copyright (c) 2000-2017 the FFmpeg developers

built with gcc 4.9.2 (Raspbian 4.9.2-10)
configuration: --enable-gpl --enable-nonfree --enable-mmal --enable-omx --enable-omx-rpi
libavutil 55. 48.100 / 55. 48.100
libavcodec 57. 83.100 / 57. 83.100
libavformat 57. 66.104 / 57. 66.104
libavdevice 57. 3.100 / 57. 3.100
libavfilter 6. 76.100 / 6. 76.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100

Input #0, video4linux2,v4l2, from '/dev/video0':

Duration: N/A, start: 208455.331127, bitrate: 24576 kb/s

Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 24576 kb/s, 5 fps, 5 tbr, 1000k tbn, 1000k tbc

Stream mapping:

Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_omx))

Press [q] to stop, ? for help
[h264_omx @ 0x1ee6310] Using OMX.broadcom.video_encode
[v4l2 @ 0x1ee4f20] V4L2 output device supports only a single raw video stream
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 -- �?ھ m?
Conversion failed!

in reply to:  2 comment:3 by Carl Eugen Hoyos, 7 years ago

Replying to rogerbrent:

pi@raspberrypi:~$ ./ffmpeg -f v4l2 -i /dev/video0 -c:v h264 -f v4l2 /dev/video1

What is this command line supposed to do?
You send h264 frames to the v4l2 device - what is it supposed to do with them?
Does your v4l2 device contain a h264 decoder?

Error initializing output stream 0:0 -- �?ھ m?

This awkward error (reading uninitialized memory) is hopefully fixed.

comment:4 by rogerbrent, 7 years ago

video1 Is a loopback (virtual) device and another program will read back the h264 stream and process it.

Note: See TracTickets for help on using tickets.