Video encoding with the x264 encoder can be tuned for fast encoding and low latency streaming. Documentation is available with x264 --fullhelp, on the libx264 wiki and here.

Example for encoding and streaming a file with ffmpeg to an RTMP endpoint:

ffmpeg -re -i input.mp4 -c:v libx264 -c:a aac -tune zerolatency -f flv rtmp://<destination>/stream-key

The effect of zerolatency tuning are these flags being applied:

  • --bframes 0 disable bilinear frames, as they can reference future frames and introduce latency
  • --force-cfr requires constant frame rate
  • --no-mbtree Deactivate the use of macroblock tree ratecontrol – Allows faster encoding with a little bit less quality
  • --sync-lookahead 0 Disables buffer for lookahead algorithms
  • --rc-lookahead 0 Disables lookahead for MB and VBV algorithms
  • --sliced-threads Applies some parallelism without an increase in latency