Changes between Version 85 and Version 86 of StreamingGuide


Ignore:
Timestamp:
Dec 5, 2024, 1:55:28 PM (17 months ago)
Author:
iconoclasthero
Comment:

streaming with zmq

Legend:

Unmodified
Added
Removed
Modified
  • StreamingGuide

    v85 v86  
    146146Note that rtp by default uses UDP, which, for large streams, can cause packet loss.  See the "point to point" section in this document for hints if this ever happens to you.
    147147
     148== Streaming a ZMQ audio stream from FFmpeg ==
     149
     150FFmpeg can stream using the [https://en.wikipedia.org/wiki/ZeroMQ] if compiled with the `--enable-libzmq` flag at build time. The streaming should also be done utilizing the -re option, for real-time streaming (i.e. it slows it down to simulate a live streaming [http://ffmpeg.org/ffmpeg.html source].  ZMQ is primarily TCP as in this example but other streaming options are possible.
     151
     152For example the following command will generate a signal, and will stream it to the port 5555 on localhost:
     153{{{
     154ffmpeg -re -hide_banner -f s16le -ar 48000 -ac 2 -i - -f mpegts -acodec libopus -b:a 128k zmq:tcp://127.0.0.1:${streamPort}
     155}}}
     156
     157To play the stream with ffplay, run the command:
     158{{{
     159ffplay -autoexit -nodisp zmq:tcp://${serverAddress}:${streamPort}
     160}}}
     161
     162A secure stream can be accessed with the above ffplay command from a remote client by connecting to the server via an ssh tunnel:
     163{{{
     164autossh -fvN -M0 -L${streamPort}:localhost:${streamPort} ${serverAddress} -p${sshPort}"
     165}}}
     166Where {{{streamPort}}} is the port for the stream (also the ssh tunnel port); {{{serverAddress}}} and {{{sshPort}}} are the server url/ip address and port, respectively.  (Adding {{{-R${returnPort}:localhost:22}}} allows access from the server back to the client if desirable.  {{{ssh}}} can be used in place of autossh for a simpler connection if less reliable connection; a VPN tunnel would also suffice.)
     167
    148168== Codecs ==
    149169