Command for sending streaming media by FFMPEG (UDP, RTP, rtmp)

Source: Internet
Author: User

These two days I have studied the command for sending streaming media from FFMPEG. Here I will record it for memo.

1. udp1.1. send the H.264 bare stream to the multicast address.

Note: The multicast address ranges from 224.0.0.0 to 239.255.255.255.

The following command sends the H.264 raw stream "Chunwan. h264" to the address UDP: // 233.233.233.223: 264

[Plain]View plaincopy
  1. FFmpeg-Re-I Chunwan. h264-vcodec copy-F h264 UDP: // 233.233.233.223: 6666

Note 1:-Re must be added, indicating that data is sent at the frame rate. Otherwise, FFMPEG sends data at the highest efficiency.

NOTE 2:-vcodec copy must be added; otherwise, FFMPEG recodes the input H.264 bare stream.

1.2. UDP playing the H.264 bare stream [Plain]View plaincopy
  1. Ffplay-F h264 UDP: // 233.233.233.223: 6666

Note: Use-F to indicate that the data type is H.264.

You can add some parameters during playback, such as-max_delay. The following command sets-max_delay to 100 MS:

[Plain]View plaincopy
  1. Ffplay-max_delay 100000-F h264 UDP: // 233.233.233.223: 6666
1.3. Send the MPEG2 raw stream to the multicast address

The following command reads the data from the local camera, encoded as MPEG2, and sent to the UDP: // 233.233.233.223: 6666 address.

[Plain]View plaincopy
  1. FFmpeg-Re-I Chunwan. h264-vcodec mpeg2video-F mpeg2video UDP: // 233.233.233.223: 6666
1.4. Play the MPEG2 bare stream

Specify-vcodec as mpeg2video.

[Plain]View plaincopy
  1. Ffplay-vcodec mpeg2video UDP: // 233.233.233.223: 6666
2. rtp2.1. send the H.264 bare stream to the multicast address.

The following command sends the H.264 raw stream "Chunwan. h264" to the address RTP: // 233.233.233.223: 264

[Plain]View plaincopy
  1. FFmpeg-Re-I Chunwan. h264-vcodec copy-F RTP: // 233.233.233.223: 6666> test. SDP

Note 1:-Re must be added, indicating that data is sent at the frame rate. Otherwise, FFMPEG sends data at the highest efficiency.

NOTE 2:-vcodec copy must be added; otherwise, FFMPEG recodes the input H.264 bare stream.

NOTE 3: the rightmost "> test. SDP" is used to store the output information of FFMPEG to form an SDP file. This file is used to receive RTP. If "> test. SDP" is not added, FFMPEG directly outputs the SDP information to the console. Copy the information and save it as a. SDP text file suffix. It can also be used to receive the RTP stream. After "> test. SDP" is added, you can directly Save the SDP information as text.

2.2. Play the RTP that carries the H.264 bare stream. [Plain]View plaincopy
  1. Ffplay test. SDP
3. rtmp3.1. send the H.264 bare stream to the rtmp server (flashmedia server, red5, etc)

Run the command to send the "Chunwan. h264" of the H.264 bare stream to the rtmp URL where the host is localhost, the application is oflademo, and the path is livestream.

[Plain]View plaincopy
  1. FFmpeg-Re-I Chunwan. h264-vcodec copy-F FLV rtmp: // localhost/oflademo/livestream
3.2. Play rtmp [Plain]View plaincopy
  1. Ffplay "rtmp: // localhost/oflademo/livestream live = 1"

Note: It is best to enclose the rtmp URL of ffplay in double quotation marks and add the live = 1 parameter to the end to represent real-time streams. In fact, this parameter is passed to librtmp of FFMPEG.

For details about how to process rtmp, refer to the article: How to Use FFMPEG to process rtmp Streaming Media

 

4. Test latency

There is one way to test the latency, that is, one way to play the sender's video, and the other way to play the stream received by the streaming media. Two Stream play modes are available: FFMPEG and ffplay.

Playing Through ffplay is a well-known method, for example:

[Plain]View plaincopy
  1. Ffplay-F dshow-I video = "integrated camera"

You can play back the camera with the local name "integrated camera.

In addition, you can use FFMPEG to play back the video by specifying the "-f sdl" parameter. For example:

[Plain]View plaincopy
  1. FFmpeg-Re-I Chunwan. h264-pix_fmt yuv420p-F SDL XXXX. YUV-vcodec copy-F FLV rtmp: // localhost/oflademo/livestream

You can send video streams to the rtmp server while playing videos through SDL.

NOTE 1: The XXXX. YUV specified after SDL is not output.

NOTE 2: FFMPEG can specify multiple outputs. This command specifies two outputs.

The method of the playback receiver has been mentioned previously and will not be detailed here.

 

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.