[FFmpeg-user] FFMpeg Streaming via UDP

Bogdan Mariesan bogdan.mariesan at buddyguard.io
Wed May 4 15:28:16 CEST 2016


Hi everyone,

I am trying to achieve a *P2P *connection via *UDP *and for that I'm
following the wiki guide.

On my server I am using:

*ffmpeg -f dshow -video_size 640x360 -rtbufsize 702000k -framerate 30 -i
video="Integrated Camera":audio="Microphone (5- Logitech USB Headset H340)"
-r 30 -threads 4 -vcodec libx264 -pix_fmt yuv420p -tune zerolatency -preset
ultrafast -f mpegts udp:/10.166.141.198:23202 <http://10.166.141.198:23202>*

Where *10.166.141.198 *is the IP of an Android device and *23202 *is the
UDP port opened by the NAT after doing UDP hole punching.

Based on the example in the guide (
https://trac.ffmpeg.org/wiki/StreamingGuide) I assume on the client I have
to connect to the client in a similar manner. I might be wrong here since
the guide uses the same IP address for both client and server.

So on the client I am connection the URL *udp://5.2.55.19:51810?localport=50341
<http://5.2.55.19:51810?localport=50341>*.
Where *5.2.55.19 *is the IP of the serverm *51810 *is the public port and
*50341* is the private port obtained after doing UDP hole punching.
On the client side the stream seems to work but on my mobile device the app
i have built using IJKPlayer (https://github.com/Bilibili/ijkplayer)
doesn't display my stream. So is it due to the way I am listening for the
UDP stream?


Client side log:

ffmpeg version N-79630-g9ac154d Copyright (c) 2000-2016 the FFmpeg
developers
  built with gcc 5.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads
--enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r
--enable-gnutls --enable-iconv --enable-libass --enable-libbluray
--enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme
--enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenjpeg --enable-libopus --enable-librtmp
--enable-libschroedinger --enable-libsnappy --enable-libsoxr
--enable-libspeex --enable-libtheora --enable-libtwolame
--enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis
--enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264
--enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg
--enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 22.101 / 55. 22.101
  libavcodec     57. 38.100 / 57. 38.100
  libavformat    57. 34.103 / 57. 34.103
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 44.100 /  6. 44.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Guessed Channel Layout for  Input Stream #0.1 : stereo
Input #0, dshow, from 'video=Integrated Camera:audio=Microphone (5-
Logitech USB Headset H340)':
  Duration: N/A, start: 1386931.560000, bitrate: N/A
    Stream #0:0: Video: rawvideo, bgr24, 640x360, 30 fps, 31 tbr, 10000k tbn
    Stream #0:1: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
[libx264 @ 0000000008a4be20] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0000000008a4be20] profile Constrained Baseline, level 3.0
[mpegts @ 00000000086fd880] Using AVStream.codec to pass codec parameters
to muxers is deprecated, use AVStream.codecpar instead.
    Last message repeated 1 times
Output #0, mpegts, to 'udp://109.166.141.198:61623?localport=53366':
  Metadata:
    encoder         : Lavf57.34.103
    Stream #0:0: Video: h264, yuv420p, 640x360, q=2-31, 30 fps, 90k tbn
    Metadata:
      encoder         : Lavc57.38.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: mp2, 44100 Hz, stereo, s16, 384 kb/s
    Metadata:
      encoder         : Lavc57.38.100 mp2
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (pcm_s16le (native) -> mp2 (native))
Press [q] to stop, [?] for help
Past duration 0.659996 too large
Past duration 0.699989 too large
Past duration 0.739998 too large
Past duration 0.779991 too large
Past duration 0.619987 too large
Past duration 0.659996 too large
Past duration 0.699989 too large
frame=   23 fps=0.0 q=22.0 size=     122kB time=00:00:01.13 bitrate=
878.5kbits/s speed=2.26x
Past duration 0.739998 too large
Past duration 0.779991 too large
Past duration 0.619987 too large
Past duration 0.629997 too large
Past duration 0.669991 too large
Past duration 0.679985 too large
Past duration 0.689995 too large
frame=   37 fps= 37 q=22.0 size=     201kB time=00:00:01.60
bitrate=1031.2kbits/s speed= 1.6x
Past duration 0.699989 too large
Past duration 0.739998 too large
Past duration 0.749992 too large
frame=   53 fps= 35 q=22.0 size=     275kB time=00:00:02.13
bitrate=1054.7kbits/s speed=1.42x

Kind regards,

*Bogdan Emil Mariesan*
Senior Software Engineer

*BuddyGuard UG* (haftungsbeschränkt)
Dircksenstr. 40
10178 Berlin

m:         +40 743 901 331
w.           www.buddyguard.io


More information about the ffmpeg-user mailing list