[FFmpeg-user] Local latency with FFplay
Bouke
bouke at editb.nl
Thu Apr 22 10:43:11 EEST 2021
Trying to view a stream while recording. (That 'sorta kinda' works with a tee and udp streaming, but has a horrible delay.)
eg:
I start FFplay:
ffplay udp://127.0.0.1:1230 -x 320 -y 240 -left 100 -top 100 -alwaysontop
Then:
ffmpeg -f decklink -i UltraStudio Mini Recorder -raw_format auto -format_code Hi50 -channels 2 -timecode_format none -video_input sdi -audio_input embedded -audio_depth 16 -vcodec libx264 -preset ultrafast -pix_fmt yuv422p -tune zerolatency -an -s 320x180 -aspect 16:9 -map 0:v -f flv udp://127.0.0.1:1230
This results in a latency of 6 seconds (Ok, no local file, but with it and a tee it’s the same)
So, back to the drawing board and trying something simple, piping directly from FFmpeg to FFplay.
ffmpeg -i yadda - | ffplay -
this takes 2 up to 6 seconds before the FFplay window is shown (Depending on the phase of the moon divided by the temperature or something, I am clueless why there is a difference), and the video is still horrible delayed (app by the same time as it took FFplay to start / show the video). If I add a -ss 2 to FFplay, there is just a couple frames delay, but the startup time of FFplay is doubled.
Funny enough, without -ss 2 the video could be 6 seconds late, with -ss 2 it's very close. (good enough for rock 'n roll, except for the 12 seconds start time...)
Any pointers?
Ideal would be to keep FFplay open, and start / stop FFmpeg for recording, or just viewing the incoming signal.
thx,
Bouke
bouke at Boukes-iMac ~ % /usr/local/bin/ffmpeg -f decklink -i "UltraStudio Mini Recorder" -format_code Hi50 -raw_format auto -s 320x180 -aspect 16:9 -map 0:v -an -vcodec libx264 -preset ultrafast -f flv - | /usr/local/bin/ffplay -
ffplay version git-2021-03-31-b3e9a84 Copyright (c) 2003-2021 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.29)
configuration: --enable-videotoolbox --enable-nonfree --enable-gpl --enable-lv2 --enable-openssl --enable-libsvtav1 --enable-libx264 --enable-libx265 --enable-libvpx --enable-libxvid --enable-libvidstab --enable-libaom --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libtheora --enable-libfdk-aac --enable-libwebp --enable-libsrt --disable-debug --disable-doc --disable-shared --enable-pthreads --enable-static --enable-small --enable-version3 --enable-decklink --extra-cflags='-I/Users/bouke/ffmpeg-build-script/workspace/include -I/Users/bouke/ffmpeg-build-script/include' --extra-ldexeflags= --extra-ldflags='-L/Users/bouke/ffmpeg-build-script/workspace/lib -L/Users/bouke/ffmpeg-build-script/include' --extra-libs='-ldl -lpthread -lm -lz' --pkgconfigdir=/Users/bouke/ffmpeg-build-script/workspace/lib/pkgconfig --pkg-config-flags=--static --prefix=/Users/bouke/ffmpeg-build-script/workspace
ffmpeg version git-2021-03-31-b3e9a84 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.29)
configuration: --enable-videotoolbox --enable-nonfree --enable-gpl --enable-lv2 --enable-openssl --enable-libsvtav1 --enable-libx264 --enable-libx265 --enable-libvpx --enable-libxvid --enable-libvidstab --enable-libaom --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libtheora --enable-libfdk-aac --enable-libwebp --enable-libsrt --disable-debug --disable-doc --disable-shared --enable-pthreads --enable-static --enable-small --enable-version3 --enable-decklink --extra-cflags='-I/Users/bouke/ffmpeg-build-script/workspace/include -I/Users/bouke/ffmpeg-build-script/include' --extra-ldexeflags= --extra-ldflags='-L/Users/bouke/ffmpeg-build-script/workspace/lib -L/Users/bouke/ffmpeg-build-script/include' --extra-libs='-ldl -lpthread -lm -lz' --pkgconfigdir=/Users/bouke/ffmpeg-build-script/workspace/lib/pkgconfig --pkg-config-flags=--static --prefix=/Users/bouke/ffmpeg-build-script/workspace
libavutil 56. 63.101 / 56. 63.101
libavutil 56. 63.101 / 56. 63.101
libavcodec 58.117.101 / 58.117.101
libavformat 58. 65.101 / 58. 65.101
libavcodec 58.117.101 / 58.117.101
libavdevice 58. 11.103 / 58. 11.103
libavformat 58. 65.101 / 58. 65.101
libavfilter 7. 96.100 / 7. 96.100
libavdevice 58. 11.103 / 58. 11.103
libswscale 5. 8.100 / 5. 8.100
libavfilter 7. 96.100 / 7. 96.100
libswresample 3. 8.100 / 3. 8.100
libswscale 5. 8.100 / 5. 8.100
libpostproc 55. 8.100 / 55. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
[decklink @ 0x7f87ec80f000] Autodetected the input mode
[decklink @ 0x7f87ec80f000] Found Decklink mode 1920 x 1080 with rate 25.00(i)
Guessed Channel Layout for Input Stream #0.0 : stereo 0B f=0/0
Input #0, decklink, from 'UltraStudio Mini Recorder':
Duration: N/A, start: 0.000000, bitrate: 830976 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream #0:1: Video: rawvideo (UYVY / 0x59565955), uyvy422(top first), 1920x1080, 829440 kb/s, 25 tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #0:1 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x7f87ec81f800] using SAR=1/1
[libx264 @ 0x7f87ec81f800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7f87ec81f800] profile High 4:2:2, level 1.2, 4:2:2, 8-bit
[libx264 @ 0x7f87ec81f800] 264 - core 161 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, flv, to 'pipe:':
Metadata:
encoder : Lavf58.65.101
Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv422p(tv, top coded first (swapped)), 320x180 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 1k tbn
Metadata:
encoder : Lavc58.117.101 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Input #0, flv, from 'pipe:':aq= 0KB vq= 0KB sq= 0B f=0/0 51.9kbits/s speed=0.953x
Metadata:
encoder : Lavf58.65.101
Duration: 00:00:00.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264, yuv422p(progressive), 320x180 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc
6.74 M-V: 0.001 fd= 0 aq= 0KB vq= 3KB sq= 0B f=0/0 44.7kbits/s speed=0.98x
av_interleaved_write_frame(): Broken pipe
[flv @ 0x7f87ec81e600] Failed to update header with correct duration.
[flv @ 0x7f87ec81e600] Failed to update header with correct filesize.
Error writing trailer of pipe:: Broken pipe
frame= 306 fps= 25 q=17.0 Lsize= 64kB time=00:00:11.92 bitrate= 44.1kbits/s speed=0.98x
video:58kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 10.367472%
[libx264 @ 0x7f87ec81f800] frame I:2 Avg QP:17.50 size: 14524
[libx264 @ 0x7f87ec81f800] frame P:304 Avg QP:17.37 size: 99
[libx264 @ 0x7f87ec81f800] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x7f87ec81f800] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 7.4% 0.0% 0.0% 0.0% 0.0% skip:92.6%
[libx264 @ 0x7f87ec81f800] coded y,uvDC,uvAC intra: 97.3% 98.1% 87.4% inter: 2.1% 1.3% 0.4%
[libx264 @ 0x7f87ec81f800] i16 v,h,dc,p: 44% 18% 22% 16%
[libx264 @ 0x7f87ec81f800] i8c dc,h,v,p: 29% 8% 40% 22%
[libx264 @ 0x7f87ec81f800] kb/s:38.68
Conversion failed!
More information about the ffmpeg-user
mailing list