[FFmpeg-user] Sync. Issue. Video Gradually Falls Behind

Thomas Seilund tps.ffmpeg at netmaster.dk
Tue Jan 26 17:51:41 EET 2021


Dear All

Video gradually falls behind!

I live stream from a Raspberry Pi with this command:


raspivid -vf -hf -t 0 -v -n -fps 25 -w  1280 -h 720 -b 2000000 --inline 
-o - | \

ffmpeg -fflags nobuffer \

-thread_queue_size 4096 -i - \

-thread_queue_size 4096 -f pulse -i 
alsa_input.usb-046d_HD_Pro_Webcam_C920_9D715A9F-02.analog-stereo \

-thread_queue_size 4096 -f pulse -i 
alsa_output.platform-bcm2835_audio.analog-stereo.monitor \

-c:v copy \

-c:a libmp3lame \

-map 0:v -map 1:a -map 2:a \

-f mpegts udp://192.168.0.101:7000


Output from the above command is:


....

   libavcodec     58. 35.100 / 58. 35.100
   libavformat    58. 20.100 / 58. 20.100
   libavdevice    58.  5.100 / 58.  5.100
   libavfilter     7. 40.101 /  7. 40.101
   libavresample   4.  0.  0 /  4.  0.  0
   libswscale      5.  3.100 /  5.  3.100
   libswresample   3.  3.100 /  3.  3.100
   libpostproc    55.  3.100 / 55.  3.100
Camera component done
Encoder component done
Starting component connection stage
Connecting camera video port to encoder input port
Enabling encoder output port
Starting video capture
Input #0, h264, from 'pipe:':
   Duration: N/A, bitrate: N/A
     Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720, 25 
fps, 25 tbr, 1200k tbn, 50 tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, pulse, from 
'alsa_input.usb-046d_HD_Pro_Webcam_C920_9D715A9F-02.analog-stereo':
   Duration: N/A, start: 1611673439.592751, bitrate: 1536 kb/s
     Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Guessed Channel Layout for Input Stream #2.0 : stereo
Input #2, pulse, from 
'alsa_output.platform-bcm2835_audio.analog-stereo.monitor':
   Duration: N/A, start: 1611673439.612473, bitrate: 1536 kb/s
     Stream #2:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
   Stream #0:0 -> #0:0 (copy)
   Stream #1:0 -> #0:1 (pcm_s16le (native) -> mp3 (libmp3lame))
   Stream #2:0 -> #0:2 (pcm_s16le (native) -> mp3 (libmp3lame))
Output #0, mpegts, to 'udp://192.168.0.101:7000':
   Metadata:
     encoder         : Lavf58.20.100
     Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720, 
q=2-31, 25 fps, 25 tbr, 90k tbn, 1200k tbc
     Stream #0:1: Audio: mp3 (libmp3lame), 48000 Hz, stereo, s16p
     Metadata:
       encoder         : Lavc58.35.100 libmp3lame
     Stream #0:2: Audio: mp3 (libmp3lame), 48000 Hz, stereo, s16p
     Metadata:
       encoder         : Lavc58.35.100 libmp3lame
[mpegts @ 0x17469d0] Timestamps are unset in a packet for stream 0. This 
is deprecated and will stop working in the future. Fix your code to set 
the timestamps properly


Output reaches "speed = 1x" is no time and after that there are no 
messages. So I assume encoding and sending over the network in no 
bottleneck! Correct?


I view the stream on host 192.168.0.101 with this command:


ffplay -fflags nobuffer -f mpegts -i udp://192.168.0.101:7000

Output from the above command is:


h264 @ 0x7fc11453b280] non-existing PPS 0 referenced    0B f=0/0
     Last message repeated 1 times
[h264 @ 0x7fc11453b280] decode_slice_header error
[h264 @ 0x7fc11453b280] no frame!
[h264 @ 0x7fc11453b280] non-existing PPS 0 referenced    0B f=0/0
     Last message repeated 1 times
[h264 @ 0x7fc11453b280] decode_slice_header error
[h264 @ 0x7fc11453b280] no frame!
[h264 @ 0x7fc11453b280] non-existing PPS 0 referenced    0B f=0/0
     Last message repeated 1 times
[h264 @ 0x7fc11453b280] decode_slice_header error
[h264 @ 0x7fc11453b280] no frame!
Input #0, mpegts, from 'udp://192.168.0.101:7000':sq=    0B f=0/0
   Duration: N/A, start: 2346.534522, bitrate: N/A
   Program 1
     Metadata:
       service_name    : Service01
       service_provider: FFmpeg
     Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), 
yuv420p(progressive), 1280x720, 25 fps, 25 tbr, 90k tbn, 180k tbc
     Stream #0:1[0x101]: Audio: mp3 ([3][0][0][0] / 0x0003), 48000 Hz, 
stereo, fltp, 128 kb/s
     Stream #0:2[0x102]: Audio: mp3 ([3][0][0][0] / 0x0003), 48000 Hz, 
stereo, fltp, 128 kb/s
Switch audio stream from #1 to #2  0KB vq=    0KB sq=    0B f=0/0
2374.89 A-V:  0.030 fd=   2 aq=    0KB vq=    0KB sq=    0B f=0/0

And the video I see is fine!


When I watch the video I note the following delays:

video is delayed 1 sec.

first audio is delayed 0.5 sec.

second audio is delayed 1 sec.


The problem is that as time passes the video falls more and more behind.

After streaming for about 40 min. I note the following delays:

video is delayed 2 sec.

first audio is delayed 0.5 sec.

second audio is delayed 1 sec.


What can I do to prevent the video from falling more and more behind?


Thanks


Thomas S



More information about the ffmpeg-user mailing list