[FFmpeg-user] Poor NDI performance
Jon
jon.tech.uk at gmail.com
Thu Jul 19 02:13:22 EEST 2018
On Wednesday, 18 July 2018, Micael Silva <micaelsilva at gmail.com> wrote:
> On Wed, Jul 18, 2018 at 8:13 AM, Jon <jon.tech.uk at gmail.com> wrote:
>
> > On Tue, 17 Jul 2018 at 23:15, Carl Eugen Hoyos <ceffmpeg at gmail.com>
> wrote:
> > >
> > > 2018-07-17 20:16 GMT+02:00, Jon <jon.tech.uk at gmail.com>:
> > > > After successfully compiling ffmpeg on Debian 9 64bit, following the
> > > > instructions at https://trac.ffmpeg.org/wiki/CompilationGuide and
> > > > adding the relevant includes for NDI using the Newtek SDK
> > > > (InstallNDISDK_v3_Linux.sh from https://www.newtek.com/ndi/sdk/) and
> > > > compiler flag (--enable-libndi_newtek), the resulting builds of
> ffmpeg
> > > > / ffplay do now playback NDI network streams but playback performance
> > > > is poor compared to playing back through OBS using the NDI plug-in
> > > > from https://github.com/Palakis/obs-ndi on the same machine. OBS has
> > > > smooth playback whereas ffmpeg is jittery.
> > > >
> > > > ./ffplay -fs -f libndi_newtek -i "NDI test (test-laptop-pgm)"
> > >
> > > Complete, uncut console output missing.
> > > Do you see the same jitter if you reencode with ffmpeg?
> > >
> > > Carl Eugen
> >
> > Thanks for your prompt reply Carl.
> >
> > Output from ffplay which produces glitchy playback:
> >
> > $ ./ffplay -fs -f libndi_newtek -i "COMPUTER (jonny-ndi-pgm)"
> > ffplay version N-91482-g8aa6d9a Copyright (c) 2003-2018 the FFmpeg
> > developers
> > built with gcc 7 (Debian 7.3.0-25)
> > configuration: --prefix=/home/blitz/ffmpeg_build
> > --pkg-config-flags=--static
> > --extra-cflags=-I/home/blitz/ffmpeg_build/include
> > --extra-ldflags=-L/home/blitz/ffmpeg_build/lib --extra-libs='-lpthread
> > -lm' --bindir=/home/blitz/bin --enable-gpl --enable-libaom
> > --enable-libass --enable-libfdk-aac --enable-libfreetype
> > --enable-libmp3lame --enable-libopus --enable-libvorbis
> > --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
> > --enable-libndi_newtek
> > libavutil 56. 18.102 / 56. 18.102
> > libavcodec 58. 21.105 / 58. 21.105
> > 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
> > Input #0, libndi_newtek, from 'COMPUTER (jonny-ndi-pgm)':0B f=0/0
> > Duration: N/A, start: 3258.294488, bitrate: 443779 kb/s
> > Stream #0:0: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
> > Stream #0:1: Video: rawvideo (UYVY / 0x59565955),
> > uyvy422(progressive), 1280x720 [SAR 1:1 DAR 16:9], 442368 kb/s, 30
> > fps, 30 tbr, 10000k tbn
> > 3275.05 A-V: -0.001 fd= 1 aq= 114KB vq=16200KB sq= 0B f=0/0
> >
> > Then as suggested I capture and reecode to mp4:
> >
> > $ ./ffmpeg -f libndi_newtek -i 'COMPUTER (jonny-ndi-pgm)' -pix_fmt
> > yuv420p -preset veryfast -threads 0 -s 1280x720 -r:v 30000/1001
> > test.mp4
> > ffmpeg version N-91482-g8aa6d9a Copyright (c) 2000-2018 the FFmpeg
> > developers
> > built with gcc 7 (Debian 7.3.0-25)
> > configuration: --prefix=/home/blitz/ffmpeg_build
> > --pkg-config-flags=--static
> > --extra-cflags=-I/home/blitz/ffmpeg_build/include
> > --extra-ldflags=-L/home/blitz/ffmpeg_build/lib --extra-libs='-lpthread
> > -lm' --bindir=/home/blitz/bin --enable-gpl --enable-libaom
> > --enable-libass --enable-libfdk-aac --enable-libfreetype
> > --enable-libmp3lame --enable-libopus --enable-libvorbis
> > --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
> > --enable-libndi_newtek
> > libavutil 56. 18.102 / 56. 18.102
> > libavcodec 58. 21.105 / 58. 21.105
> > 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
> > Guessed Channel Layout for Input Stream #0.0 : stereo
> > Input #0, libndi_newtek, from 'COMPUTER (jonny-ndi-pgm)':
> > Duration: N/A, start: 4328.386098, bitrate: 443779 kb/s
> > Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
> > Stream #0:1: Video: rawvideo (UYVY / 0x59565955),
> > uyvy422(progressive), 1280x720 [SAR 1:1 DAR 16:9], 442368 kb/s, 30
> > fps, 30 tbr, 10000k tbn
> > Stream mapping:
> > Stream #0:1 -> #0:0 (rawvideo (native) -> h264 (libx264))
> > Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
> > Press [q] to stop, [?] for help
> > [libx264 @ 0x563d67569840] using SAR=1/1
> > [libx264 @ 0x563d67569840] using cpu capabilities: MMX2 SSE2Fast SSSE3
> > SSE4.2 AVX FMA3 BMI2 AVX2
> > [libx264 @ 0x563d67569840] profile High, level 3.1
> > [libx264 @ 0x563d67569840] 264 - core 155 - H.264/MPEG-4 AVC codec -
> > Copyleft 2003-2018 - http://www.videolan.org/x264.html - options:
> > cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1
> > psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0
> > 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0
> > threads=6 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1
> > interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2
> > b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250
> > keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=crf
> > mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40
> > aq=1:1.00
> > Output #0, mp4, to 'test.mp4':
> > Metadata:
> > encoder : Lavf58.17.101
> > Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p,
> > 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc
> > Metadata:
> > encoder : Lavc58.21.105 libx264
> > Side data:
> > cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
> > Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
> > stereo, fltp, 128 kb/s
> > Metadata:
> > encoder : Lavc58.21.105 aac
> > frame= 862 fps= 32 q=-1.0 Lsize= 1892kB time=00:00:28.66 bitrate=
> > 540.8kbits/s dup=59 drop=0 speed=1.07x
> > video:1425kB audio:436kB subtitle:0kB other streams:0kB global
> > headers:0kB muxing overhead: 1.677788%
> > [libx264 @ 0x563d67569840] frame I:4 Avg QP:15.09 size: 35316
> > [libx264 @ 0x563d67569840] frame P:217 Avg QP:20.03 size: 3285
> > [libx264 @ 0x563d67569840] frame B:641 Avg QP:22.11 size: 942
> > [libx264 @ 0x563d67569840] consecutive B-frames: 0.8% 0.0% 0.3% 98.8%
> > [libx264 @ 0x563d67569840] mb I I16..4: 56.1% 22.7% 21.2%
> > [libx264 @ 0x563d67569840] mb P I16..4: 2.5% 7.9% 0.4% P16..4:
> > 5.0% 2.1% 0.8% 0.0% 0.0% skip:81.3%
> > [libx264 @ 0x563d67569840] mb B I16..4: 0.3% 1.4% 0.0% B16..8:
> > 3.7% 1.0% 0.1% direct: 1.3% skip:92.2% L0:49.8% L1:40.5% BI: 9.6%
> > [libx264 @ 0x563d67569840] 8x8 transform intra:70.2% inter:51.8%
> > [libx264 @ 0x563d67569840] coded y,uvDC,uvAC intra: 42.5% 37.4% 5.7%
> > inter: 0.7% 1.6% 0.0%
> > [libx264 @ 0x563d67569840] i16 v,h,dc,p: 50% 33% 7% 10%
> > [libx264 @ 0x563d67569840] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 37% 18%
> > 3% 3% 3% 5% 3% 5%
> > [libx264 @ 0x563d67569840] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 25% 11%
> > 5% 8% 8% 8% 6% 6%
> > [libx264 @ 0x563d67569840] i8c dc,h,v,p: 48% 29% 18% 4%
> > [libx264 @ 0x563d67569840] Weighted P-Frames: Y:0.0% UV:0.0%
> > [libx264 @ 0x563d67569840] kb/s:405.56
> > [aac @ 0x563d6756c2c0] Qavg: 192.838
> >
> > The resulting playback is perfect:
> >
> > $ ./ffplay test.mp4
> > ffplay version 3.4.3-1 Copyright (c) 2003-2018 the FFmpeg developers
> > built with gcc 7 (Debian 7.3.0-24)
> > configuration: --prefix=/usr --extra-version=1 --toolchain=hardened
> > --libdir=/usr/lib/x86_64-linux-gnu
> > --incdir=/usr/include/x86_64-linux-gnu --enable-gpl
> > --disable-stripping --enable-avresample --enable-avisynth
> > --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray
> > --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite
> > --enable-libfontconfig --enable-libfreetype --enable-libfribidi
> > --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa
> > --enable-libopenjpeg --enable-libopenmpt --enable-libopus
> > --enable-libpulse --enable-librubberband --enable-librsvg
> > --enable-libshine --enable-libsnappy --enable-libsoxr
> > --enable-libspeex --enable-libssh --enable-libtheora
> > --enable-libtwolame --enable-libvorbis --enable-libvpx
> > --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2
> > --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx
> > --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394
> > --enable-libdrm --enable-libiec61883 --enable-chromaprint
> > --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
> > libavutil 55. 78.100 / 55. 78.100
> > libavcodec 57.107.100 / 57.107.100
> > libavformat 57. 83.100 / 57. 83.100
> > libavdevice 57. 10.100 / 57. 10.100
> > libavfilter 6.107.100 / 6.107.100
> > libavresample 3. 7. 0 / 3. 7. 0
> > libswscale 4. 8.100 / 4. 8.100
> > libswresample 2. 9.100 / 2. 9.100
> > libpostproc 54. 7.100 / 54. 7.100
> > Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':q= 0B f=0/0
> > Metadata:
> > major_brand : isom
> > minor_version : 512
> > compatible_brands: isomiso2avc1mp41
> > encoder : Lavf58.17.101
> > Duration: 00:00:28.76, start: 0.000000, bitrate: 538 kb/s
> > Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
> > 1280x720 [SAR 1:1 DAR 16:9], 405 kb/s, 29.97 fps, 29.97 tbr, 30k tbn,
> > 59.94 tbc (default)
> > Metadata:
> > handler_name : VideoHandler
> > Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
> > stereo, fltp, 128 kb/s (default)
> > Metadata:
> > handler_name : SoundHandler
> > 31.65 A-V: -0.014 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
> >
> > So what can I do to view the incoming NDI stream smoothly (as with the
> > first ffplay command) as that is my main reason for doing this?
> >
> > Please let me know if I can provide any further details.
>
>
> NDI playback is very jitttery for me to on ffplay, although encodes fine
> with ffmpeg. I've never had too much time to debug this but i suspect there
> is something with clock sync or timestamping. NDI likes to guess if the
> content is interlaced or progressive and it can cause problems on realtime
> playback for ffplay
This nifty trick produces perfectly smooth playback:
./ffmpeg -f libndi_newtek -i 'COMPUTER (jonny-ndi-pgm)' -f matroska - |
./ffplay -fs -
Even on an old, slow, low resource computer.
But if there is a better workaround or a fix then please notify me.
More information about the ffmpeg-user
mailing list