[FFmpeg-user] UDP multicast - private data streams and mpegts alternatives

Rohan Fletcher rohfle at gmail.com
Thu Apr 15 14:30:01 EEST 2021


Hello,

I have been trying to use udp multicast to send high speed low latency
video to multiple computers simultaneously. To do this, I have been using
mpegts as a container like follows:

ffmpeg -f lavfi -i testsrc2=s=1920x1080:d=30 -c:v dirac -f mpegts udp://
239.0.0.1:1234
ffmpeg -f lavfi -i testsrc2=s=1920x1080:d=30 -c:v dnxhd -profile:v dnxhr_hq
-pix_fmt yuv422p -f mpegts udp://239.0.0.1:1234
ffmpeg -f lavfi -i testsrc2=s=1920x1080:d=30 -c:v cfhd -pix_fmt yuv422p -f
mpegts udp://239.0.0.1:1234
ffmpeg -f lavfi -i testsrc2=s=1920x1080:d=30 -c:v hap -pix_fmt yuv422p -f
mpegts udp://239.0.0.1:1234
ffmpeg -f lavfi -i testsrc2=s=1920x1080:d=30 -c:v huffyuv -pix_fmt yuv422p
-f mpegts udp://239.0.0.1:1234

Only dirac works out of the box - the others give messages similar to:
$ ffmpeg -f lavfi -i testsrc2=s=1920x1080:d=30 -c:v dnxhd -profile:v
dnxhr_hq -pix_fmt yuv422p -f mpegts udp://239.0.0.1:1234
ffmpeg version 4.3.1-4ubuntu1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10 (Ubuntu 10.2.0-9ubuntu2)
  configuration: --prefix=/usr --extra-version=4ubuntu1
--toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu
--incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl
--disable-stripping --enable-avresample --disable-filter=resample
--enable-gnutls --enable-ladspa --enable-libaom --enable-libass
--enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio
--enable-libcodec2 --enable-libdav1d --enable-libflite
--enable-libfontconfig --enable-libfreetype --enable-libfribidi
--enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame
--enable-libmysofa --enable-libopenjpeg --enable-libopenmpt
--enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg
--enable-librubberband --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh
--enable-libtheora --enable-libtwolame --enable-libvidstab
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp
--enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq
--enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl
--enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx
--enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc
--enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, lavfi, from 'testsrc2=s=1920x1080:d=30':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080
[SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> dnxhd (native))
Press [q] to stop, [?] for help
Output #0, mpegts, to 'udp://239.0.0.1:1234':
  Metadata:
    encoder         : Lavf58.45.100
    Stream #0:0: Video: dnxhd (DNXHR HQ) (AVdh / 0x68645641), yuv422p,
1920x1080 [SAR 1:1 DAR 16:9], q=2-1024, 200 kb/s, 25 fps, 90k tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.91.100 dnxhd
[mpegts @ 0x5588eb03ebc0] Stream 0, codec dnxhd, is muxed as a private data
stream and may not be recognized upon reading.

This is probably because dnxhd(?), cfhd, hap, and huffyuv do not have SMPTE
registered identifiers. Using ffplay, I can't seem to figure out how to map
that private data stream back to being a video codec. Is there a way to
view video in private data streams with ffplay?

Alternatively, I have been looking into other container formats to use for
udp multicast and the above codecs. Matroska works but only if ffplay is
running as the receiver before the sender starts sending. eg

ffplay udp://239.0.0.1:1234 &  # then
ffmpeg -f lavfi -i testsrc2=s=1920x1080:d=30 -c:v cfhd -pix_fmt yuv422p -f
matroska udp://239.0.0.1:1234

If the receiver is started after ffmpeg, I get the following message:
ffplay version 4.3.1-4ubuntu1 Copyright (c) 2003-2020 the FFmpeg developers
  built with gcc 10 (Ubuntu 10.2.0-9ubuntu2)
  configuration: --prefix=/usr --extra-version=4ubuntu1
--toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu
--incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl
--disable-stripping --enable-avresample --disable-filter=resample
--enable-gnutls --enable-ladspa --enable-libaom --enable-libass
--enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio
--enable-libcodec2 --enable-libdav1d --enable-libflite
--enable-libfontconfig --enable-libfreetype --enable-libfribidi
--enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame
--enable-libmysofa --enable-libopenjpeg --enable-libopenmpt
--enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg
--enable-librubberband --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh
--enable-libtheora --enable-libtwolame --enable-libvidstab
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp
--enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq
--enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl
--enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx
--enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc
--enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
udp://239.0.0.1:1234: Invalid data found when processing input

Are there some options that I need to specify in ffmpeg to avoid this when
muxing with Matroska? Like repeating headers, limiting packet sizes etc.
Otherwise are there other recommendations of alternative container formats
to use when multicast udp streaming?


Regards
Rohan


More information about the ffmpeg-user mailing list