Windows Nasty Media nginx-rmtp-module server build and Java program call Fmpeg to turn rtsp to rtmp live stream

Source: Internet
Author: User
Tags nginx server

First step: first introduce the relevant technology used

Note: The Jwplayer plug-in used in the project does not support the RTSP protocol, so use the following techniques to turn the art

    1. FFmpeg is an open-source computer program that can be used to record, convert digital audio, video, and turn it into a stream. Here I only use its video format conversion function, the RTSP protocol to the stream into rtmp
    2. RTSP protocol ( live stream Transfer Protocol ):

The company uses Hoi Hong's surveillance address for (Rtsp://admin:[email Protected]/h264/ch1/main/av_stream)

3. RTMP protocol ( Real-time message Transfer Protocol ):

RTMP is a network protocol designed for real-time data communication, which is used primarily for audio and video and data communication between the Flash/air platform and the streaming/interactive server that supports the RTMP protocol. The software that supports this protocol includes the Adobe Media server/ultrant media server/red5/nginx ( The nginx I use here) and so on.

4.Jwplayer is an open source Flash video, audio, and image player for use on Web pages.

It supports playback of Adobe Flash player and HTML5 browser which can handle any format (FLV files, H. MP4 features, VP8, WEBM, support mp3,aac,jpg,png and GIF). It also supports a variety of streaming and playlist formats (including RMTP protocol, HTTP Live and more) and a variety of playback options.

5.nginx-rmtp-module is the streaming media plugin for Nginx server:

Nginx itself is an excellent HTTP server, FFmpeg is a very good audio and video solution. These two things through an nginx module Nginx-rtmp-module, Together, you can build a relatively well-functioning streaming media server. This streaming media server can support RTMP and HLS (Live Http stream).

Nginx with FFmpeg to do streaming media server principle is:

Nginx provides rtmp service via RTMP module, FFmpeg pushes an rtmp stream to Nginx, and then the client accesses Nginx to watch the real-time video stream. ( Here I use Jwplayer to access this rtmp address )

The second step: the configuration and application of related software

    1. nginx-1.5.8 version currently in use

(Now you need to use the Nginx-rtmp.exe program, online can search for the software has integrated rtmp module version of Windows)

2. Open the Conf folder to locate the nginx.conf file, configure rtmp

(Add rtmp{....} )

3. Run the cmd command to start the Nginx.exe service

(Start Nginx.exe: Start the Nginx service and see if there are any nginx.exe in the process)

4. Open Web input: localhost or 127.0.0.1 Native IP

(Show the interface instructions to start successfully)

The third step: the configuration and application of related software after the Nginx service is started, you can execute the ffmpeg command to turn the RTSP protocol into rtmp:

Ffmpeg-i "Rtsp://admin:[email Protected]/h264/ch1/main/av_stream"-F flv-r 25-s 640x480-an "rtmp://192.168.3.138:1935 /myapp/test2 "

    1. Run cmd: Execute ffmpeg command statement

FFmpeg: Actually is Ffmpeg.exe, when you run the statement, the. exe does not

-I: Behind the camera protocol that I need

-F FLV: Back to the RTMP server I'm going to go to Nginx

-S: Video resolution: (Distribution Rate) is the sharpness of the screen can be adjusted, if the test recommendations on the local 640*480 is good, change the video stream of the analytic CPU will consume a lot

(rtmp service address: RTMP://192.168.3.138:1935/MYAPP/TEST2)

192.168.3.138:nginx Machine IP for startup

1935: Port number (previously configured in nginx.conf)

MyApp: Is the name behind the application

Test2: You can get up, remember when you visit rtmp to be consistent

Enter Execution FFmpeg statement

(Below is the result of my execution, proves that my execution is successful, through the FFmpeg to the RTSP protocol camera's video stream has been running to the Nginx rtmp video streaming server)

Fourth Step: Configure Jwplayer: file name jwplayer6.8.4616[(2014-06-28) (Perfect to Watermark

(Online download resources, here mainly used to jwplayer.js and jwplayer.flash.swf two, index.html there are some parameters introduced, the corresponding introduction of other documents can be Baidu Jwplayer use method)

Note: Jwplayer does not seem to support playback in a local HTML page, to play in a server environment

The project only configures what it needs:

attached: Execute the FFMPEG statement in Java as follows

public static Boolean Convertprotocol (String ffmpeg,string rtsp, string rtmp,string s) {//ffmpeg-i "Rtsp://admin:[email p Rotected]/h264/ch1/main/av_stream "//-f flv-r 25-s 640x480-an" Rtmp://192.168.3.138:1935/myapp/test2 "List<String > commend = new arraylist<string> (), Commend.add (FFmpeg), Commend.add ("-i"), Commend.add ("\" "+rtsp+" \ ""); Commend.add ("-f"); Commend.add ("flv"); Commend.add ("-R"); Commend.add ("+"); Commend.add ("-S"); Commend.add (s); Commend.add ("-an"); Commend.add (rtmp); try {processbuilder builder = new Processbuilder ();//Create System process Builder.command ( commend); Builder.start ();//START process} catch (Exception e) {e.printstacktrace ();} return true;}

Note: The above-mentioned software can be found on the Internet, if not found or have any problems can I number: CCBABC

Reprint Please specify the source thank you

Windows Nasty Media nginx-rmtp-module server build and Java program call Fmpeg to turn rtsp to rtmp live stream

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.