[FFmpeg-user] FFplay network stream with low latency

Elliott Balsley elliottbalsley at gmail.com
Sun Aug 5 04:50:35 EEST 2018


> Are you sure about the framerate?
> If it really is 30fps and FFmpeg reports it as 25fps, then you
> need a filter chain to speed playback up, "-r" only works with
> ffmpeg, see the documentation for setpts:
> 
I’m pretty sure.  The stream comes from a raspberry pi like this:
raspivid -n -ih -t 0 -w 1280 -h 720 -b 1000000 -fps 30 -o - | nc -lkv4 8080
If I lower the framerate to 5, then latency improves to about 3 seconds, but ffplay still detects it as 25.  See full output below from the latest build (with some duplicate error lines removed).  I’m piping ffmpeg to ffplay so I can use the -r option.

According to mplayer, it says "FPS not specified in the header or invalid, use the -fps option”. If I use “-fps 60” then it plays with no latency, but if I use “-fps 30” it has bad latency like ffmpeg.  I don’t understand why. nc 192.168.1.3 8080 | mplayer -fps 60 -demuxer h264es -

Also, this stream plays with no latency in this app: https://github.com/ShawnBaker/iOS_RPiCameraViewer <https://github.com/ShawnBaker/iOS_RPiCameraViewer>


> You can also test -analyzeduration.
Thanks, I tried setting that to zero but it doesn’t help.


$ nc 192.168.3.172 8080 | /usr/local/bin/ffmpeg -r 5 -i pipe:0 -analyzeduration 0 -probesize 32 -f h264 -an -c:v copy pipe:1 | /usr/local/bin/ffplay -i pipe:0
ffplay version N-91560-g476fd6ba3a Copyright (c) 2003-2018 the FFmpeg developers
  built with gcc 7.3.0 (MacPorts gcc7 7.3.0_1)
ffmpeg version N-91560-g476fd6ba3a  configuration: --enable-libopenjpeg --enable-libass --enable-libbluray --enable-libfreetype --enable-libx264 --enable-libx265 --enable-nonfree --enable-libfdk-aac --enable-gpl
 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.0 (MacPorts gcc7 7.3.0_1)
  configuration: --enable-libopenjpeg --enable-libass --enable-libbluray --enable-libfreetype --enable-libx264 --enable-libx265 --enable-nonfree --enable-libfdk-aac --enable-gpl
  libavutil      56. 18.102 / 56. 18.102
  libavcodec     58. 22.100 / 58. 22.100
  libavformat    58. 17.101 / 58. 17.101
  libavdevice    58.  4.101 / 58.  4.101
  libavfilter     7. 26.100 /  7. 26.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
  libavutil      56. 18.102 / 56. 18.102
  libavcodec     58. 22.100 / 58. 22.100
  libavformat    58. 17.101 / 58. 17.101
  libavdevice    58.  4.101 / 58.  4.101
  libavfilter     7. 26.100 /  7. 26.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
[h264 @ 0x7fb52580ea00] non-existing PPS 0 referenced
    Last message repeated 1 times
[h264 @ 0x7fb52580ea00] decode_slice_header error
[h264 @ 0x7fb52580ea00] no frame!
[h264 @ 0x7fb52580ea00] non-existing PPS 0 referenced
    Last message repeated 1 times
[h264 @ 0x7fb52580ea00] decode_slice_header error
[h264 @ 0x7fb52580ea00] no frame!
Input #0, h264, from 'pipe:0':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Output #0, h264, to 'pipe:1':
  Metadata:
    encoder         : Lavf58.17.101
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720, q=2-31, 25 fps, 25 tbr, 5 tbn, 5 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Input #0, h264, from 'pipe:0':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720, 25 fps, 25 tbr, 1200k tbn, 50 tbc
    nan M-V:    nan fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0    451.5kbits/s speed=1.81x    
av_interleaved_write_frame(): Broken pipe
Error writing trailer of pipe:1: Broken pipeime=00:01:11.80 bitrate= 450.5kbits/s speed= 1.8x    
frame=  335 fps=8.4 q=-1.0 Lsize=    3949kB time=00:01:11.80 bitrate= 450.5kbits/s speed=1.79x    
video:3964kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!



More information about the ffmpeg-user mailing list