您的位置:首页 > 其它

how to use ffmpeg with media wowza server (mpeg-ts)

2015-05-13 13:41 971 查看
Step-by-step instructions for using FFmpeg as a live video/audio encoder with Wowza Media Server®.

Note: Updated for FFmpeg version N-52458-gaa96439 (04-30-2013)

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, contact FFmpeg.

To get started, download and install FFmpeg for your platform on the same computer that's running Wowza Media Server. I used the most recent daily build of FFmpeg from http://ffmpeg.zeranoe.com/builds//.
FFmpeg Setup

Note: The examples below demonstrate re-streaming using the Wowza Media Server sample video file [install-dir]/content/sample.mp4 on Windows operating systems.

1.In the root the C: drive, create the following directory structure:

Code:

C:/usr/local/share/ffmpegCopy all of the files from the presets folder in the FFmpeg package to this new directory.

2.Open a command prompt and change directory to the FFmpeg bin folder.

3.Enter the following FFmpeg command to re-stream the file sample.mp4 from the [install-dir]/content folder of the Wowza Media Server installation:

Code:

ffmpeg -re -i "%WMSAPP_HOME%/content/sample.mp4" -vcodec libx264 -vb 150000 -g 60 -vprofile baseline -level 2.1 -acodec aac -ab 64000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts udp://127.0.0.1:10000?pkt_size=1316

Next, follow the instructions in the following tutorial:

How to publish and play a live stream (MPEG-TS based encoder)

See Also:

FFmpeg website

FFmpeg documentation

Notes

•The sample.mp4 file is about 10 minutes long. FFmpeg will stop when it hits the end of this file, so you may have to restart FFmpeg several times during configuration and testing.

•The above FFmpeg command lines will produce a low bitrate, low complexity, low quality stream that should be playable on most playback devices and systems. The following is a higher quality version that provides a glimpse of what VideoLAN (VLC) can do:

Code:

ffmpeg -re -i "%WMSAPP_HOME%/content/sample.mp4" -vcodec libx264 -vb 500000 -g 60 -vprofile main -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts udp://127.0.0.1:10000?pkt_size=1316

•FFmpeg can also be used to transcode an RTSP, native RTP, or MPEG-TS stream. Just change the first argument of each of the command lines (the path to the sample.mp4 file) to the desired source to be transcoded and remove the -re command line option. Here are
a few examples:

RTSP/RTP camera

Code:

ffmpeg -i "rtsp://192.168.1.22/mycamera" -vcodec libx264 -vb 150000 -g 60 -vprofile baseline -level 2.1 -acodec aac -ab 64000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts udp://127.0.0.1:10000?pkt_size=1316MPEG-TS stream

Code:

ffmpeg -i "udp://localhost:1234" -vcodec libx264 -vb 150000 -g 60 -vprofile baseline -level 2.1 -acodec aac -ab 64000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts udp://127.0.0.1:10000?pkt_size=1316Native RTP stream

Code:

ffmpeg -i "unicast.sdp" -vcodec libx264 -vb 150000 -g 60 -vprofile baseline -level 2.1 -acodec aac -ab 64000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts udp://127.0.0.1:10000?pkt_size=1316

•If you want to host FFmpeg on a different computer as the server hosting Wowza Media Server, you can modify any of the above command lines by changing udp://127.0.0.1:10000 to the IP address of the server running Wowza Media Server and any destination UDP
port. Be sure that the specified UDP port is open on any routers or firewalls between the server running VLC and the server running the Wowza media server.

•FFmpeg can publish streams using other outgoing protocols such as RTMP and RTSP/RTP (QuickTime ANNOUNCE). To send a stream using RTMP, change the destination portion of the FFmpeg URL:

From:

Code:

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

Code:

-f flv rtmp://127.0.0.1/live/myStreamThe format of the RTMP URL portion is:

Code:

rtmp://[wowza-ip-address]/[application]/[streamName]To send a stream using RTSP/RTP, change the destination portion of the FFmpeg URL:

From:

Code:

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

Code:

-f rtsp rtsp://127.0.0.1:1935/live/myStream.sdpThe format of the RTSP URL portion is:

Code:

rtsp://[wowza-ip-address]:1935/[application]/[streamName]

•Microsoft Silverlight players prefer a 2-second key frame frequency. If you set the -r (fps) flag to half of the -g (GOP) setting, the stream will have a 2-second key frame frequency. In the above examples where -g is 48, you would set -r 24.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: