You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
v4l2 MMAL_PARAMETER_VIDEO_ENCODE_INLINE_HEADER param not working #2780
flags 4132 (hex 0x1024) is MMAL_BUFFER_HEADER_FLAG_NAL_END | MMAL_BUFFER_HEADER_FLAG_CONFIG | MMAL_BUFFER_HEADER_FLAG_FRAME_END - MMAL_BUFFER_HEADER_FLAG_CONFIG denoting that it is the header bytes.
26 bytes is the expected length for the SPS/PPS headers on H264, and the driver works around the fact that the firmware always gives it a pts of 0 and gives it a sensible timestamp.
As root echo 0xFFFF > /sys/class/video4linux/video0/dev_debug and capture again, then dmesg | grep bytesused shows the same callbacks being made.
Set h264_i_frame_period to 2, and modify v4l2-ctl to log the length and first few bytes of each packet and I get
pi@raspberrypi:~/v4l-utils/utils/v4l2-ctl $ ./v4l2-ctl --stream-mmap=3 --stream-count=20 --stream-to=foo.h264
Start of packet len 26 00 00 00 01 27 64
<
Start of packet len 7958 00 00 00 01 25 88
K
Start of packet len 880 00 00 00 01 21 9A
<
Start of packet len 26 00 00 00 01 27 64
<
Start of packet len 7987 00 00 00 01 25 88
K
Start of packet len 3480 00 00 00 01 21 9A
<
Start of packet len 26 00 00 00 01 27 64
<
Start of packet len 11034 00 00 00 01 25 88
K
Start of packet len 1708 00 00 00 01 21 9A
<
Start of packet len 26 00 00 00 01 27 64
<
Start of packet len 12071 00 00 00 01 25 88
K
Start of packet len 1325 00 00 00 01 21 9A
<
Start of packet len 26 00 00 00 01 27 64
<
Start of packet len 12006 00 00 00 01 25 88
K
Start of packet len 1345 00 00 00 01 21 9A
<
Start of packet len 26 00 00 00 01 27 64
<
Start of packet len 12046 00 00 00 01 25 88
K
Start of packet len 1421 00 00 00 01 21 9A
<
Start of packet len 26 00 00 00 01 27 64
<
Start of packet len 12085 00 00 00 01 25 88
K
Stream to a file and use ```xxd`` (or similar hex editor) to look at the bitstream and I see the same as the above.
So from all that I'm farily happy that is working as expected. I'm running 4.14.86, but have also checked with 4.19.6. None of this has changed on 4.14 in a good few months anyway.
the issue seems that i am using v4l2 syscalls in a C program and no matter what i set V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to, the output remains the same.
but raspivid seems to be able to do generate a correct output stream.
we think that the option is not correctly passed down to the firmware when setting via v4l2
If you are trying to enable V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER from your app, check the value afterwards using v4l2-ctl --list-ctrls. For V4L2 capture devices the settings persist after stopping streaming.
One thought - you need to set V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER before calling STREAMON. (Looking at the code implementing this I'm not sure why that limitation is being enforced, but it's not something I really fancy fiddling with)
Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER
to control H264 inline headers.
Requires firmware fix to work correctly, otherwise format
has to be set to H264 before this parameter is set.
56ffb0f - a Linux 3.12 branch change in Dec 2013!
A lot of water has passed under the bridge so it would be reasonable to drop that requirement now, and the firmware will be returning an error should you change that setting whilst streaming.
TBH It would make more sense for me to investigate whether we can change inline headers mode whilst streaming.
Activity
zoff99 commentedon Dec 9, 2018
i am using the latest firmware (as of now 9.Dec.2018)
i have done all 3 just now:
using a RPI 3B+ hardware with a picam module v2.1
SPS/PPS are only generated at the first buffer and never again
6by9 commentedon Dec 10, 2018
More detail required as to what you've been done.
The resulting log shows
flags 4132 (hex 0x1024) is
MMAL_BUFFER_HEADER_FLAG_NAL_END | MMAL_BUFFER_HEADER_FLAG_CONFIG | MMAL_BUFFER_HEADER_FLAG_FRAME_END- MMAL_BUFFER_HEADER_FLAG_CONFIG denoting that it is the header bytes.26 bytes is the expected length for the SPS/PPS headers on H264, and the driver works around the fact that the firmware always gives it a pts of 0 and gives it a sensible timestamp.
As root
echo 0xFFFF > /sys/class/video4linux/video0/dev_debugand capture again, thendmesg | grep bytesusedshows the same callbacks being made.Set
h264_i_frame_periodto 2, and modify v4l2-ctl to log the length and first few bytes of each packet and I getStream to a file and use ```xxd`` (or similar hex editor) to look at the bitstream and I see the same as the above.
So from all that I'm farily happy that is working as expected. I'm running 4.14.86, but have also checked with 4.19.6. None of this has changed on 4.14 in a good few months anyway.
6by9 commentedon Dec 10, 2018
And it's absolutely nothing to do with #849. That appears to be a GStreamer bug in that particular version.
zoff99 commentedon Dec 10, 2018
the issue seems that i am using v4l2 syscalls in a C program and no matter what i set V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER to, the output remains the same.
but raspivid seems to be able to do generate a correct output stream.
we think that the option is not correctly passed down to the firmware when setting via v4l2
v4l2-ctl shoed the parameter set correctly.
zoff99 commentedon Dec 10, 2018
i will give more debug info when i am near the RPI3B+ again
6by9 commentedon Dec 10, 2018
All the above debug was done with v4l2-ctl which is itself a C program using the V4L2 API. The source is at https://git.linuxtv.org/v4l-utils.git/tree/utils/v4l2-ctl
If you are trying to enable V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER from your app, check the value afterwards using
v4l2-ctl --list-ctrls. For V4L2 capture devices the settings persist after stopping streaming.One thought - you need to set V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER before calling STREAMON. (Looking at the code implementing this I'm not sure why that limitation is being enforced, but it's not something I really fancy fiddling with)
zoff99 commentedon Dec 10, 2018
i checked the value afterwards with v4l2-ctl and it was set to "1" and i also tried with "0". did not make any change.
but let me test all the above on the PI so that i can give more info
zoff99 commentedon Dec 10, 2018
ohhh i set it after STREAMON. ok so will try that. thanks for the info.
6by9 commentedon Dec 10, 2018
Setting it after STREAMON should mean it applies for the next run, but not the current run.
zoff99 commentedon Dec 10, 2018
what does this mean in the source:
6by9 commentedon Dec 10, 2018
Tracking it back, the commit text was
56ffb0f - a Linux 3.12 branch change in Dec 2013!
A lot of water has passed under the bridge so it would be reasonable to drop that requirement now, and the firmware will be returning an error should you change that setting whilst streaming.
TBH It would make more sense for me to investigate whether we can change inline headers mode whilst streaming.
zoff99 commentedon Dec 10, 2018
that would help, since we did not get an error we didnt realize it
zoff99 commentedon Dec 10, 2018
we made a quick test now with a remote Pi3 and it seems to solve our issue.
i will confirm later tonight to make sure.
thanks for you help!
zoff99 commentedon Dec 10, 2018
ok i can confirm when setting it before STREAMON it works.
thanks for all the tips to get debug info.