Wowza Community

Frequently requested FFMPEG command examples for Wowza

Example commands and information for using FFmpeg as a live video/audio encoder with Wowza Media Server.

Updated for FFmpeg Build git-a85b4a5 64-bit Static (2012-07-30)

Note: Wowza Media Systems provides these instructions on as “AS-IS” basis. FFmpeg is not a Wowza Media Systems product. If you have problems getting FFmpeg to work properly it is best to contact FFmpeg support through their forums or wiki.

The information collected here is a brief overview of common FFmpeg solutions. It is intended for an intermediate-level streaming technician who has previous experience with FFmpeg. Feel free to post solutions and hints, but please refer to the FFmpeg documentation for configuration information.

Table of Contents

  • [anchorurl=content.php?35#tutorials]Required Wowza Application Tutorials[/anchorurl]

  • [anchorurl=content.php?35#install]Installation Instructions[/anchorurl]

  • [anchorurl=content.php?35#usage]Usage[/anchorurl]

  • [anchorurl=content.php?35#inputs]Inputs[/anchorurl]

  • [anchorurl=content.php?35#outputs]Outputs[/anchorurl]

  • [anchorurl=content.php?35#inputs]Examples[/anchorurl]

  • [anchorurl=content.php?35#misc]Miscellaneous Hints[/anchorurl]


    Required Wowza Application Tutorials

    Note: In order stream to Wowza using FFmpeg you must create a Wowza live application corresponding to your chosen FFmpeg output protocol. RTMP is recommended.

    1. RTMP

    2. RTSP

    3. RTP with SDP

    4. MPEG-TS

    Installation Instructions

    Windows Installation:

    1. Download the latest static build from http://ffmpeg.zeranoe.com/builds/

    2. Unzip and copy the contents of the included folder to C:\Program Files (x86)\ffmpeg\

    3. Add “C:\Program Files (x86)\ffmpeg\bin” to your System “PATH” environment variable:

    a. Go to: Start Button -> All Programs -> Accessories. Right-click on “Command Prompt”. Left-click “Run as Administrator”.

    b. In the CMD window enter: setx /M PATH C:\Program Files (x86)\ffmpeg\bin;"%PATH%"

    c. Close this CMD window.

    Linux Installation:

    Official Ubuntu Linux guide for compiling from source.

    On Linux you will have to compile from source to add support for certain codecs. The Ubuntu instructions linked here include the AAC codec libfaac instead of libvo_aacenc. In the following examples replace “libvo_aacenc” with “libfaac”.

    Usage

    A basic ffmpeg command is of the following form:

    ffmpeg [INPUT OPTIONS] -i [INPUT] [OUTPUT OPTIONS] [OUTPUT]

    Parameters placed before the input apply to the input. For example, if the source is a file, prefix with the “-re” option to limit reading the input (and hence writing the output) to the encoded bitrate.

    ffmpeg -re -i [INPUT] [OUTPUT OPTIONS] [OUTPUT]

    FFmpeg supports some protocols that can be push-published directly to a Wowza application and are available for viewing automatically: RTMP, RTSP. The OUTPUT URL looks like this:

    Other protocols such as MPEG-TS, or RTP with SDP, must be “started” manually using the StreamManager, automatically using StartupStreams.xml, or programmatically with the StreamClass API. OUTPUT URL format:

    Inputs

    1. Some VOD file path examples:

    “%WMSAPP_HOME%/content/sample.mp4”

    /usr/local/WowzaMediaServer/content/bigbuckbunny_1500.mp4

    myRecording.mp3

    streamcapture.ts

    myStream.flv

    1. RTSP/RTP camera:

    rtsp://192.168.1.22/mycamera

    1. MPEG-TS stream:

    udp://localhost:1234

    1. Native RTP stream SDP file:

    unicast.sdp

    1. RTMP source:

    rtmp://[Streaming-Server-IP]:1935/vod/mp4:sample.mp4

    1. Hardware device:

    -f dshow -i video=“Integrated Webcam”

    1. Linux X11 Desktop:

    -f x11grab -s wxga -r 25 -i :0.0 -sameq

    Outputs

    Note: Refer to the corresponding tutorial for your chosen live output stream type.

    1. RTMP:

    -f flv rtmp://127.0.0.1/live/myStream

    1. RTSP:

    -f rtsp -muxdelay 0.1 rtsp://127.0.0.1:1935/live/myStream

    1. RTSP (with publish password):

    -f rtsp -muxdelay 0.1 rtsp://username:secretword@127.0.0.1:1935/live/myStream

    1. RTP with SDP:

    -f rtp rtp://127.0.0.1:10000 > “%WMSAPP_HOME%/content/10000.sdp”

    -This will write an .sdp file to the Wowza content directory which can be started in Stream Manager.

    1. MPEG-TS (requires .stream file and Stream Manager):

    -vbsf h264_mp4toannexb -f mpegts udp://127.0.0.1:10000?pkt_size=1316

    Examples

    1. Output RTMP without transcoding:
    ffmpeg -re -i "%WMSAPP_HOME%/content/sample.mp4" -c:v copy -c:a copy -f flv rtmp://127.0.0.1/live/myStream
    
    1. RTSP low bandwidth baseline stream:

    -H.264/AAC, Baseline profile, level 1.2, 12FPS, keyframe at least every 96 frames (8 seconds), 110kbps video, 212x120 resolution, 40kbps audio, 22.05khz, mono

    ffmpeg -re -i sample.mp4 -c:v libx264 -profile:v baseline -level:v 1.2 -r 12 -g 96 -vb 110000 -s 212x120 -c:a libvo_aacenc -ab 40000 -ar 22050 -ac 1 -f rtsp -muxdelay 0.1 rtsp://127.0.0.1/live/myStream
    
    1. RTSP with publish password:

    -H.264/AAC, Baseline profile, level 3.0, 24FPS, 2sec keyframe exactly, 350kbps stream, 44.1khz, stereo

    ffmpeg -re -i sample.mp4 -c:v libx264 -profile:v baseline -level 3.0 -r 24 -g 48 -keyint_min 48 -sc_threshold 0 -vb 310k -c:a libvo_aacenc -ab 40k -ar 44100 -ac 2 -f rtsp -muxdelay 0.1 rtsp://username:secretword@127.0.0.1:1935/live/myStream
    
    1. MPEG-TS:

    -H.264/AAC, Main profile, level 3.1, 24FPS, 4sec max keyframe interval, 404kbps constant bitrate video, 96kbps audio, 48khz, stereo

    ffmpeg -re -i sample.mp4 -c:v libx264 -profile:v main -level 3.1 -r 24 -g 96 -maxrate 404000 -minrate 404000 -bufsize 125k -c:a libvo_aacenc -ab 96000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -f mpegts udp://127.0.0.1:10000?pkt_size=1316
    
    
    1. RTP with SDP:

    -Capture local hardware devices, generate SDP file in current directory. Set 15FPS source framerate, 12bit color.

    ffmpeg -y -f dshow -s 640x480 -r:v 15 -i video="Integrated Webcam":audio="Microphone (Realtek High Defini" -c:v libx264 -pix_fmt yuv420p -vb 450 -an -map 0:0 -f rtp rtp://127.0.0.1:10000 -flags +global_header -c:a libvo_aacenc -vn -map 0:1 -f rtp rtp://127.0.0.1:10002 > 10000.sdp
    

    Miscellaneous FFMPEG Hints

    1. Show VOD or Live stream encoding parameters for troubleshooting:

    ffprobe -show_streams [media]

    1. List available hardware device names such as webcams and microphones, for use as FFmpeg inputs:

    ffmpeg -list_devices true -f dshow -i dummy

    1. When testing short videos you may want loop your command to generate a constant test stream:

    Windows: FOR /L %% IN (0) DO YourCommand

    1. Convert .ts file (or any FFmpeg compatible input) to .mp4 container for use with Wowza VOD playback:

    ffmpeg -i input.ts -c:v copy -c:a copy output.mp4

    1. Check VOD files for keyframe alignment (Linux):

    ffprobe -output_format csv -show_frames [media] |grep I

    -For each file in your multibitrate rendition ensure the PTS and/or DTS timestamps are identical for each corresponding I-frame.

    1. Generate keyframe aligned multi-bitrate VOD rendition (Linux):

    Use this media source for testing.

    ffmpeg -y -i bigbuckbunny_1500.mp4 -c:a libfaac -ac 2 -ab 64k -c:v libx264 -preset:v veryfast -threads 0 -r 24 -g 48 -keyint_min 48 -sc_threshold 0 -x264opts no-mbtree:bframes=1 -pass 1 -b:v 286k -s 384x216 bigbuck-350k.mp4
    ffmpeg -y -i bigbuckbunny_1500.mp4 -c:a libfaac -ac 2 -ab 64k -c:v libx264 -preset:v fast -threads 0 -r 24 -g 48 -keyint_min 48 -sc_threshold 0 -x264opts no-mbtree:bframes=1 -pass 2 -b:v 286k -s 384x216 bigbuck-350k.mp4
    ffmpeg -y -i bigbuckbunny_1500.mp4 -c:a libfaac -ac 2 -ab 64k -c:v libx264 -preset:v fast -threads 0 -r 24 -g 48 -keyint_min 48 -sc_threshold 0 -x264opts no-mbtree:bframes=1 -pass 2 -b:v 836k -s 640x360 bigbuck-900k.mp4
    
    

    Version .08

Hi

I am making app using flash and wowza server in which need to publish stream using camera (as3 )from client side and need to connect with ffmpeg so

can convert the multi streams at a time .

My question is how to set the path rtmp to ffmpeg during publish time so can convert the streams during publish time on server .My ffmpeg on wamp sever under bin.

Thanks

Vishal

connect with ffmpeg so can convert the multi streams at a time

How does FFmpeg fit in? What is the goal?

Can you diagram that?

Webcam > Wowza > FFmpeg > client ?

Webcam > FFmpeg > Wowza > client ?

Richard