Closed tachang closed 3 years ago
Hi,
Thé frame spliting is messing up. Do you set h264 marker (0 0 0 1) writing frame to v4l2loopback device ?
Best Regards Michel
I am just writing the elementary h264 bytestream to the /dev/video3 v4l2loopback device. When I dump it into a file and run this:
ffmpeg -i video3.264 -c copy -bsf:v trace_headers -f null -
I get the following: https://gist.github.com/tachang/51fec92dfdd65228e65bd32502bdc894
My take on this is that there are no Access Unit Delimiter (AUD) units.
Basing this on https://doc-kurento.readthedocs.io/en/6.11.0/knowledge/h264.html#nal-units-nalu:
The NAL units can contain either actual data video (VCL units) or codec metadata (non-VCL units). Some of the most important types of NAL units are:
So my bytestream is missing the last one.
My guess is that v4l2loopback does not support bytestream. I am setting:
vid_format.fmt.pix.pixelformat = V4L2_PIX_FMT_H264;
which by this documentation: https://dri.freedesktop.org/docs/drm/media/uapi/v4l/pixfmt-compressed.html
Says
H264 Access Unit. The decoder expects one Access Unit per buffer. The encoder generates one Access Unit per buffer. If ioctl VIDIOC_ENUM_FMT reports V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM then the decoder has no requirements since it can parse all the information from the raw bytestream.
I am on kernel 3.10.14 which does not have any references to V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM
.
So my guess is I need to write out a AUD NALU to "frame" the bytestream?
Hi,
As I told you, I guess you are missing the start code prefix
, the code of v4l2rtspServer looks for a 4 byte or a 3 byte ones, to split frame SPS, PPS, IDR,....
A standard V4L2 device get in one read (SPS, PPS, IDR) then the code split that.
If you don't have any start code prefix
and one H264 frame per read, you can easily modify the code to process such data using directly the base V4L2DeviceSource instead of H264_V4L2DeviceSource.
Best Regards, Michel.
P.S. recent v4l2loopback support H264, you may have a look to https://github.com/mpromonet/v4l2tools that can compress H264 to a v4l2loopback device.
Wouldn't the code error out if the start code prefix of {0, 0, 0, 1}
wasn't present?
I see it here: https://github.com/mpromonet/v4l2rtspserver/blob/master/src/H264_V4l2DeviceSource.cpp#L134
I am using the most v4l2loopback that supports H264.
I'm not seeing the log message No marker found
which I would expect.
It seems like what is happening is that I am not seeing SPS or PPS units in time. I managed to somehow get it to work by letting it feed frames for a while but haven't been able to replicate again. Is there a "hook" into the server to begin streaming?
Hi,
SPS & PPS are decoded from the capture frame and updated, this fill the auxilary codec information that will be given to RTSP DESCRIBE.
If the parameter -c
is not given the SPS & PPS frames are added in front of each IDR frame.
Best Regards, Michel.
So I am copying an H264 byte stream via hardware encoding to /dev/video3 using v4l2loopback.
Starting v4l2rtpserver I am not able to connect with VLC. It says
Not sure what could be causing this.