Answers.Body: <p>Gyan is right :</p>
  
  <p>I just need to add +global header flag and only the "dump_extra" bit stream filter</p>
  
  <p>My patch become useless, ffmpeg can add SPS/PPS itself inside the stream.</p>
  
  <p>My old cmdline is - missing inline SPS/PPS for infinite streaming - :</p>
  
  <p>ffmpeg -f v4l2 -i /dev/video0 -vf hqdn3d=0:0:50:50 -c:v h264_omx -profile:v baseline -b:v 1500000 -f rawvideo tcp://127.0.0.1:8003</p>
  
  <p>I just need to add "-flags:v +global_header -bsf:v dump_extra" the cmdline become :</p>
  
  <p>ffmpeg -f v4l2 -i /dev/video0 -vf hqdn3d=0:0:50:50 -c:v h264_omx -profile:v baseline -b:v 1500000 -flags:v +global_header -bsf:v dump_extra -f rawvideo tcp://127.0.0.1:8003</p>
  
  <p>(live result here : <a href="https://www.vigibot.com/" rel="nofollow noreferrer">https://www.vigibot.com/</a> click on the "Astro" public robot)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-12T09:47:40.893Z
Answers.LastActivityDate: 2019-12-12T09:47:40.893Z
Answers.UserDisplayName: Serveurperso
Body: <p>I managed to enable inline header on the OMX H.264 hardware encoder. inline header(SPS/PPS) are mandatory to play an already launched stream.</p>
  
  <p><a href="https://github.com/Serveurperso/FFmpeg/commit/6e410823e63103342e8fc3407ff6698808d4d1ef" rel="nofollow noreferrer">https://github.com/Serveurperso/FFmpeg/commit/6e410823e63103342e8fc3407ff6698808d4d1ef</a></p>
  
  <p>Yes but there is a problem : the latency grow over the time. There is a strange time calculation problem inside the muxer? I get a lot of traces "application provided invalid, non monotonically increasing dts to muxer in stream X/0" and the ffmpeg process always freeze at 3335/0 (with no trace).</p>
  
  <p>Without inline header : no latency (about 0.2s on raspberry pi 4 / 720x576 25FPS) No "... increasing dts to muxer" error. disadvantage: I can't resume the already launched stream.</p>
  
  <p>With software x264 encoder : no latency (about 0.2s on raspberry pi 4 / 720x576 25FPS) No "... increasing dts to muxer" error. disadvantage: It consume a lot of CPU power...</p>
  
  <p>How to fix the timestamp(?) calculation inside ffmpeg muxer code to take into account the addition of SPS / PPS NALUs ?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-12-11T07:58:12.633Z
Comments.Text: Without the patch, try inserting bitstream filters extract_extradata and dump_extradata for the video stream.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-12-12T09:40:25.180Z
Comments.Text: MY WORKING CMDLINE IS (I just need to add global header flag and the dump_extra bit stream filter !!!! My patch is useless:) : ffmpeg -f v4l2 -i /dev/video0 -vf hqdn3d=0:0:50:50 -c:v h264_omx -profile:v baseline -b:v 1500000 -flags:v +global_header -bsf:v dump_extra -f rawvideo tcp://127.0.0.1:8003
Comments.UserDisplayName: Serveurperso
Tags: <ffmpeg><h.264>
Title: FFmpeg raspberry pi OMX hardware encoder with inline_headers enabled = Increasing latency over the time
UserDisplayName: Serveurperso
ThreadText: # FFmpeg raspberry pi OMX hardware encoder with inline_headers enabled = Increasing latency over the time
  
  (Asked by: username_0 on 2019-12-10)
  
  I managed to enable inline header on the OMX H.264 hardware encoder. inline header(SPS/PPS) are mandatory to play an already launched stream.
  
  <https://github.com/username_0/FFmpeg/commit/6e410823e63103342e8fc3407ff6698808d4d1ef>
  
  Yes but there is a problem : the latency grow over the time. There is a strange time calculation problem inside the muxer? I get a lot of traces "application provided invalid, non monotonically increasing dts to muxer in stream X/0" and the ffmpeg process always freeze at 3335/0 (with no trace).
  
  Without inline header : no latency (about 0.2s on raspberry pi 4 / 720x576 25FPS) No "... increasing dts to muxer" error. disadvantage: I can't resume the already launched stream.
  
  With software x264 encoder : no latency (about 0.2s on raspberry pi 4 / 720x576 25FPS) No "... increasing dts to muxer" error. disadvantage: It consume a lot of CPU power...
  
  How to fix the timestamp(?) calculation inside ffmpeg muxer code to take into account the addition of SPS / PPS NALUs ?
  
  **Tags:** ffmpeg, h.264
  
  > **Comments:**
  > **username_1**: Without the patch, try inserting bitstream filters extract_extradata and dump_extradata for the video stream.  
  > **username_0**: MY WORKING CMDLINE IS (I just need to add global header flag and the dump_extra bit stream filter !!!! My patch is useless:) : ffmpeg -f v4l2 -i /dev/video0 -vf hqdn3d=0:0:50:50 -c:v h264_omx -profile:v baseline -b:v 1500000 -flags:v +global_header -bsf:v dump_extra -f rawvideo tcp://127.0.0.1:8003  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-12-12. Score: 0
  
  username_1 is right :
  
  I just need to add +global header flag and only the "dump\_extra" bit stream filter
  
  My patch become useless, ffmpeg can add SPS/PPS itself inside the stream.
  
  My old cmdline is - missing inline SPS/PPS for infinite streaming - :
  
  ffmpeg -f v4l2 -i /dev/video0 -vf hqdn3d=0:0:50:50 -c:v h264\_omx -profile:v baseline -b:v 1500000 -f rawvideo tcp://127.0.0.1:8003
  
  I just need to add "-flags:v +global\_header -bsf:v dump\_extra" the cmdline become :
  
  ffmpeg -f v4l2 -i /dev/video0 -vf hqdn3d=0:0:50:50 -c:v h264\_omx -profile:v baseline -b:v 1500000 -flags:v +global\_header -bsf:v dump\_extra -f rawvideo tcp://127.0.0.1:8003
  
  (live result here : <https://www.vigibot.com/> click on the "Astro" public robot)
  
  
  ---
  
  