Re-stream using FFmpeg with Wowza Streaming Engine

Want To Try Us Out?

Our trial plan is free, with no obligation or credit card required. Start your free trial and you'll be streaming in minutes!

Start your trial!

With re-streaming in Wowza Streaming Engine™ media server software, you can broadcast an encoded video file as though it were a live stream. To re-stream using FFmpeg, use the -re option when encoding the video file for Wowza Streaming Engine™ media server software. The -re option instructs the encoder to read the source at its native frame rate. This slows the stream down to simulate live streaming and mitigates buffering and memory buildup that can disrupt playback.

Note: FFmpeg is updated frequently. Download the current version and read current documentation at ffmpeg.org.

Contents


Re-stream sample.mp4
Re-stream using passthrough
Re-stream RTSP with password authentication
Re-stream RTP with SDP
Re-stream UDP-based MPEG-TS
Re-stream TCP-based MPEG-TS
Re-stream UDP-based RTSP
Re-stream TCP-based RTSP
Re-stream RTMP
Re-stream to MP4
More resources

Re-stream sample.mp4


This example re-streams the sample.mp4 video that's included with your Wowza Streaming Engine installation.

Notes:

  • The sample.mp4 file is about 10 minutes long. FFmpeg stops when streaming ends, so you may have to restart FFmpeg during configuration and testing. To loop your command to generate a constant test stream, preface the FFmpeg command with

FOR /L %% IN (0) DO

  • To host FFmpeg on a computer other than the computer on which Wowza Streaming Engine is installed, change udp://127.0.0.1:10000 in the example to the IP address of the server running Wowza Streaming Engine and any destination UDP port. Be sure that the specified UDP port is open on any routers or firewalls between the server hosting FFmpeg and the server running Wowza Streaming Engine.

     
  1. In a Terminal window, enter one of the following commands.
  • For a low-bitrate, low-complexity, low-quality stream that can be played on most devices and systems:

ffmpeg -re -i "%WMSAPP_HOME%/content/sample.mp4" -pix_fmt yuv420p -vsync 1 -threads 0 -vcodec libx264 -r 30 -g 60 -sc_threshold 0 -b:v 512k -bufsize 640k -maxrate 640k -preset veryfast -profile:v baseline -tune film -acodec aac -b:a 128k -ac 2 -ar 48000 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -bsf:v h264_mp4toannexb -f mpegts udp://127.0.0.1:10000?pkt_size=1316
  • For a higher-quality stream:
ffmpeg -re -i "%WMSAPP_HOME%/content/sample.mp4" -pix_fmt yuv420p -vsync 1 -threads 0 -vcodec libx264 -r 30 -g 60 -sc_threshold 0 -b:v 640k -bufsize 768k -maxrate 800k -preset veryfast -profile:v baseline -tune film -acodec aac -b:a 128k -ac 2 -ar 48000 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -bsf:v h264_mp4toannexb -f mpegts udp://127.0.0.1:10000?pkt_size=1316
  1. Follow the instructions in Publish and play a live stream (MPEG-TS based encoder) in Wowza Streaming Engine to set up a live application to re-stream the FFmpeg stream. When configuring the application and adding a stream file on the Stream Files page, use udp://127.0.0.1:10000 as the Stream URI.

Re-stream using passthrough


Content can also be re-streamed by passing the existing encode though FFmpeg without re-encoding. For passthrough re-streaming, use the -codec option and set it to copy. This example re-streams sample.mp4 as a passthrough instead of the full encode shown in the previous example.

ffmpeg -re -i "%WMSAPP_HOME%/content/sample.mp4" -codec copy -bsf:v h264_mp4toannexb -f mpegts udp://127.0.0.1:10000?pkt_size=1316

Re-stream RTSP with password authentication


This example re-streams sample.mp4 with user authentication, level 3.0 logging verbosity, a 24-fps frame rate, 2-second keyframe frequency, 310 kbps bitrate, and 44.1 kHz stereo audio.

ffmpeg -re -i "%WMSAPP_HOME%/content/sample.mp4" -pix_fmt yuv420p -vsync 1 -threads 0 -vcodec libx264 -r 30 -g 60 -sc_threshold 0 -b:v 640k -bufsize 768k -maxrate 800k -preset veryfast -profile:v baseline -tune film -acodec aac -b:a 128k -ac 2 -ar 48000 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -f rtsp rtsp://username:password@[wowza-address]:1935/myApplication/myStream

Re-stream RTP with SDP


This example captures local hardware devices, uses a 15-fps frame rate, 8-bit color, and generates an SDP file that contains metadata about the streaming session.

ffmpeg -f dshow -s 640x480 -r 15 -i video="Logitech HD Pro Webcam C920" -f dshow -i audio="Microphone (HD Pro Webcam C920)" -pix_fmt yuv420p -vsync 1 -threads 0 -vcodec libx264 -r 15 -g 30 -sc_threshold 0 -b:v 640k -bufsize 768k -maxrate 800k -preset veryfast -profile:v baseline -tune film -an -f rtp rtp://127.0.0.1:10000 -acodec aac -b:a 128k -ac 2 -ar 48000 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -vn -f rtp rtp://127.0.0.1:10002 > 10000.sdp

Re-stream UDP-based MPEG-TS


  1. In a Terminal window, enter:
ffmpeg -re -i inputfile.mp4 -codec copy -bsf:v h264_mp4toannexb -f mpegts udp://[<em>wowza-address</em>]:1234?pkt_size=1316

  1. Follow the instructions at Publish and play a live stream (MPEG-TS based encoder) in Wowza Streaming Engine to create a live application to broadcast the FFmpeg stream.

Re-stream TCP-based MPEG-TS


  1. In a Terminal window, enter:
ffmpeg -re -i inputfile.mp4 -codec copy -bsf:v h264_mp4toannexb -f mpegts tcp://[<em>wowza-address</em>]:1234?listen

  1. Follow the instructions at Publish and play a live stream (MPEG-TS over TCP/IP) in Wowza Streaming Engine to create a live application to broadcast the FFmpeg stream.

Re-stream UDP-based RTSP


  1. In a Terminal window, enter:
ffmpeg -re -i inputfile.mp4 -codec copy -f rtsp rtsp://username:password@[wowza-address]:1935/myApplication/myStream



 
  1. Follow the instructions at Set up live streaming using an RTSP/RTP-based encoder in Wowza Streaming Engine to connect your RTSP encoder to Wowza Streaming Engine and create a live application to broadcast the FFmpeg stream.

Re-stream TCP-based RTSP


  1. In a Terminal window, enter:
ffmpeg -re -i inputfile.mp4 -codec copy -rtsp_transport tcp -f rtsp rtsp://username:password@[wowza-address]:1935/myApplication/myStream

  1. Follow the instructions at Set up live streaming using an RTSP/RTP-based encoder in Wowza Streaming Engine to connect your RTSP encoder to Wowza Streaming Engine and create a live application to broadcast the FFmpeg stream.

Re-stream RTMP


  1. In a Terminal window, enter one of the following commands.
     
    • Use the following command with the latest versions of FFmpeg (version 4.3.1 or later):
       
      ffmpeg -re -i inputfile.mp4 -codec copy -f flv "rtmp://[wowza-address]:1935/myApplication/myStream flashver=FMLE/3.0\20(compatible;\20FMSc/1.0) pubUser=username pubPasswd=password"

    • For earlier versions of FFmpeg, use the following command:
       
      ffmpeg -re -i inputfile.mp4 -codec copy -f flv rtmp://username:password@[wowza-address]:1935/myApplication/myStream
 
  1. Follow the instructions at Set up live streaming using an RTMP-based encoder in Wowza Streaming Engine to connect your RTMP encoder to Wowza Streaming Engine and create a live application to broadcast the FFmpeg stream.

Re-stream to MP4


  • In a Terminal window, enter:
ffmpeg -re -i inputfile.mp4 -codec copy -f mp4 output.mp4

More resources