[FFmpeg-user] Low latency H.264 streaming with ffmpeg

rameshperumal reachtorameshmail at gmail.com
Tue Mar 27 06:59:57 EEST 2018


Greger Burman wrote
> Observation:
> x264 codec + mpegts format compared to mjpeg codec + mjpeg format adds
> about 300 ms (10 frames) latency.

Hi,

I just started to transcode the 1-minute input video(mjpeg) from the USB
camera with the below command.

time ~/bin/ffmpeg -benchmark -threads 4 -t 00:01:00.000000 -f video4linux2
-input_format mjpeg -framerate 30 -i /dev/video0 -an -c:v libx264 -preset
ultrafast -tune zerolatency -thread_type 1 -r:v 30 -f null - 

Output:
ffmpeg version 3.3 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.2.0 (Ubuntu 6.2.0-5ubuntu12) 20161005
  configuration: --prefix=/usr --pkg-config-flags=--static
--extra-cflags=-I/usr/include --extra-ldflags=-L/usr/lib --bindir=/root/bin
--enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype
--enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264
--enable-libx265 --enable-nonfree --enable-vaapi --enable-libopus
--enable-libvpx --enable-hwaccel=h263_vaapi --enable-hwaccel=h264_vaapi
--enable-hwaccel=mpeg2_vaapi --enable-hwaccel=mpeg4_vaapi
--enable-hwaccel=vc1_vaapi --enable-hwaccel=vp8_vaapi
--enable-hwaccel=vp9_vaapi --enable-hwaccel=wmv3_vaapi
--enable-decoder='vp8,vp9'
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 5864.558330, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown),
640x480, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
No pixel format specified, yuvj422p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x555b636ea220] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x555b636ea220] profile High 4:2:2, level 3.0, 4:2:2 8-bit
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf57.71.100
    Stream #0:0: Video: h264 (libx264), yuvj422p(pc), 640x480, q=-1--1, 30
fps, 30 tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.89.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 1800 fps= 30 q=-1.0 Lsize=N/A time=00:01:00.00 bitrate=N/A speed=  
1x
video:8981kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: unknown
bench: utime=5.746s
bench: maxrss=57952kB
[libx264 @ 0x555b636ea220] frame I:8     Avg QP:19.12  size: 62426
[libx264 @ 0x555b636ea220] frame P:1792  Avg QP:22.09  size:  4853
[libx264 @ 0x555b636ea220] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x555b636ea220] mb P  I16..4:  1.5%  0.0%  0.0%  P16..4: 58.3% 
0.0%  0.0%  0.0%  0.0%    skip:40.2%
[libx264 @ 0x555b636ea220] coded y,uvDC,uvAC intra: 29.4% 66.3% 13.1% inter:
14.5% 42.2% 8.9%
[libx264 @ 0x555b636ea220] i16 v,h,dc,p: 32% 38% 18% 12%
[libx264 @ 0x555b636ea220] i8c dc,h,v,p: 36% 23% 31% 10%
[libx264 @ 0x555b636ea220] kb/s:1226.19

real    1m1.359s
user    0m5.772s
sys     0m0.115s


May I know the values (bench: utime=5.746s or user    0m5.772s or  sys    
0m0.115s) I need to consider to measure the end-to-end transcoding latency?
I am interested in measuring the combined encode and decode latency per
video frame. Please suggest me.



--
Sent from: http://www.ffmpeg-archive.org/


More information about the ffmpeg-user mailing list