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.
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.
相关文章推荐
- how to use adb and gdbserver with VirtualBox - KVM (qemu)
- How to use a SQL Server database with your PHP web site
- [Yii Framework] How to run cron job (or use command) in the server with yii framework
- How To Use Proxy Server To Access Internet at Shell Prompt With http_proxy Variable. [reprint]
- How to use the Install from Media feature to promote Windows Server 2003-based domain controllers
- How to use Access Log Sampler to Generate Traffic with JMeter
- Visual C++ Debugging: How to use 'ASSERT' and deal with assertions failures?
- Learn How to Use Neo4J with Node.js
- Correct Smartphone Video Orientation and How To Rotate iOS and Android Videos with ffmpeg
- How to use ServerCore<1>
- How to Send an Email Using UTL_SMTP with Authenticated Mail Server
- How to use HttpSendRequestEx with password-protected URLs
- IntegrationWithDjango - modwsgi - How to use Django with mod_wsgi. - Python WSGI adapter module for Apache. - Google Project Hosting
- how to configure libvirt to use virtio with KVM guests
- How to use GitHub with Android Studio
- How to use re-write module of Apache web server 2.2.3 on FC6 with new or refurbi
- How to create aligned partitions in Linux for use with NetApp LUNs, VMDKs, VHDs and other virtual di
- How to find out why your account keeps getting locked with Windows Server, TMG and Webspy
- (转)How to use MySQL with 3D Studio Max
- How to Export Mailboxes with Exchange Server 2010 SP1(带状态查看,清除请求,归档备份)