-
1 RTMP push flow
-
1.1 obs
- 1.1.1 OBS acquisition camera
-
1.2 ffmpeg
- 1.2.1 FFMPEG read file push
-
-
2 RTSP stream
-
2.1 ffmpeg
- 2.1.1 FFMPEG read file push stream
-
-
3 RTMP flow
- 3.1 VLC
-
3.2 ffmpeg
- 3.2.1 FFMPEG pull streams to save files
- 3.3 ffplay
- 3.4 MPV
- 3.5 RTMP playback page provided by SRS (based on Adobe Flash technology)
- 4
http-flv
andhttps-flv
Pull flow -
5 HLS (m3u8 + ts) flow
- 5.1 Safari Browser
- 5.2 VLC, FFMPEG, FFPLAY
- 6
http-ts
Pull flow - 7 RTSP stream
- 8 Test file download
<! — more –>
(Additional client usage and other streaming protocol formats will be added later.)
Example stream address:
agreement | address | Protocol default port |
---|---|---|
The RTMP push flow | RTMP: / / 127.0.0.1:1935 / live/test110 | 1935 |
Push RTSP stream | rtsp://localhost:5544/live/test110 | 554 |
RTMP pull flow | RTMP: / / 127.0.0.1:1935 / live/test110 | 1935 |
HTTP – FLV flow | http://127.0.0.1:8080/live/test110.flv | 80 |
HTTPS – FLV flow | https://127.0.0.1:4433/live/test110.flv | 443 |
HTTP – ts stream | http://127.0.0.1:8082/live/test110.ts | 80 |
RTSP pull flow | rtsp://localhost:5544/live/test110 | 554 |
HLS(M3U8 + TS) live pull stream | http://127.0.0.1:8081/hls/test110/playlist.m3u8 | 80 |
HLS(M3U8 + TS) recording and playback | http://127.0.0.1:8081/hls/test110/record.m3u8 | 80 |
Note that if you use the default port, the address can be omitted in the port, such as http://127.0.0.1:8080/live/test110.flv into http://127.0.0.1/live/test110.flv
1 RTMP push flow
1.1 obs
Download the binary installation package of the corresponding operating system from the official website (https://obsproject.com/) and install it.
In this paper, OBS version 25.0.8 of MacOS is used as a demonstration, and other systems and OBS versions are similar.
1.1.1 OBS acquisition camera
- To open OBS, click the Settings button in the lower right corner
- In the pop-up window, click the Push Stream button on the left
-
Push flow details page appears on the right:
- Leave the service drop – down box alone, keep custom…
- The serverFill in the input box
RTMP: / / 127.0.0.1:1935 / live
-
Enter TEST110 in the streaming key input field
- Tips, the streaming key default is not plaintext display input characters, if afraid of output, you can click the display button on the right
- Click the OK button in the lower right corner to complete the setting
- Back to the main screen, click the button in the lower right corner to start the push stream
- The status bar at the bottom shows
Live, FPS, KB /s
, respectively represent the push stream length, frame rate and bit rate, indicating the push stream is successful
In addition to capturing camera as input stream, OBS also provides functions such as capturing desktop, audio and video files. It also provides many parameters that can be configured in a graphical interface.
1.2 ffmpeg
1.2.1 FFMPEG read file push
(See how to install FFMPEG at the end of this article)
In this case, the audio in FLV or MP4 files is in AAC format, and the video is in H264 or H265 format, which is supported by the streaming media server itself, so FFMPEG does not need to re-encode the audio and video:
$ffmpeg - re - stream_loop - 1 - I demo. FLV - c: a copy - c: v copy - f FLV RTMP: / / 127.0.0.1:1935 / live/test110
Explain some of the parameters:
-re
It means push according to the bitrate of the tenor video stream of the file. If not added, it means that the transmission speed is not controlled and it is sent to the server at one time, which is not in line with the characteristics of live broadcasting-stream_loop -1
Denotes the number of times that the file continues to loop from the header after the end of the file,- 1
It’s an infinite loop-i
Represent input file-c:a copy
Indicates that the audio encoding format is unchanged-c:v copy
Indicates that the video encoding format is unchanged-f flv
Pushing RTMP streams requires the format specified asflv
- Finally, the RTMP push stream address
If it’s an mp4 file, change demo.flv to an mp4 file name, such as demo.mp4
The above is a more common situation.
In another case, if the audio and video encoding format in the file is not supported by the streaming server, then FFMPEG needs to be re-encoded:
$ffmpeg - re - I demo. FLV - c: a aac - c: v h264 -f FLV RTMP: / / 127.0.0.1:1935 / live/test110
Where, -C: A AAC means audio is encoded in AAC, and -C: V H264 means video is encoded in H264.
2 RTSP stream
2.2 ffmpeg
2.2.1 FFMPEG read file push
ffmpeg -re -stream_loop -1 -i demo.flv -acodec copy -vcodec copy -f rtsp rtsp://localhost:5544/live/test110
In addition, RTSP also supports RTP over TCP to push streams. The corresponding FFMPEG command is as follows:
ffmpeg -re -stream_loop -1 -i demo.flv -acodec copy -vcodec copy -rtsp_transport tcp -f rtsp rtsp://localhost:5544/live/test110
See 1.2.1 for the meaning of the parameter
3 RTMP flow
The original is not easy, please indicate the article reprinted from open source media server lal, Github:https://github.com/q191201771/lal official documentation: https://pengrl.com/lal
3.1 VLC
On the website (https://www.videolan.org/vlc/) to download the corresponding binary of the operating system installation package, and install.
In this article, VLC 3.0.8 for MacOS is used as a demonstration, and other systems and OBS versions are similar.
- Open the VLC
- Click File in the menu bar at the bottom, then Open Network…
- In the pop-up windowURLFill in the input box
RTMP: / / 127.0.0.1:1935 / live/test110
- Click the OK button in the lower right corner to complete the setting
- Start playing live streams
3.2 ffmpeg
3.2.1 FFMPEG pull streams to save files
How to install FFMPEG see article at end
$ffmpeg -i RTMP: / / 127.0.0.1:1935 / live/test110 - c copy test110. FLV
3.3 ffplay
FFPlay is a player that comes with the FFmpeg project
$ffplay RTMP: / / 127.0.0.1:1935 / live/test110
3.4 MPV
Download the binary installation package, install, and then input the streaming address to play, basically and VLC, refer to 2.1 VLC
3.5 RTMP playback page provided by SRS (based on Adobe Flash technology)
Open the RTMP playback page provided by SRS:
http://ossrs.net/players/srs_player.html?app=live&stream=livestream&server=r.ossrs.net&port=1935&autostart=true&vhost=r. ossrs.net
Enter the RTMP pull stream address in the URL input box and click the Play Video button
4 http-flv
andhttps-flv
Pull flow
HTTP-FLV pull streams, for VLC, FFMPEG, FFPlay, MPV, are the same as pull RTMP streams, The flow from the RTMP URL: / / 127.0.0.1:1935 / live/test110 to http://127.0.0.1:8080/live/test110.flv.
HTTPS-FLV pulls the stream in the same way as HTTP-FLV.
5 HLS(m3u8+ts)
Pull flow
5.1 Safari Browser
Open safari, in address line input HLS flow at http://127.0.0.1:8081/hls/test110/playlist.m3u8.
5.2 VLC, FFMPEG, FFPLAY
HLS(M3U8 + TS) pull streams, for VLC, FFMPEG, FFPlay, are the same as pull RTMP streams, The flow from the RTMP URL: / / 127.0.0.1:1935 / live/test110 to http://127.0.0.1:8081/hls/test110/playlist.m3u8.
6 http-ts
Pull flow
HTTP-TS pull streams, for VLC, FFMPEG, FFPlay, MPV, are the same as pull RTMP streams, The flow from the RTMP URL: / / 127.0.0.1:1935 / live/test110 to http://127.0.0.1:8082/live/test110.ts.
7 RTSP stream
$ffplay rtsp://localhost:5544/live/test110
$ffmpeg -i rtsp://localhost:5544/live/test110 -vcodec copy -acodec copy -f flv /tmp/test110.flv
$ffmpeg -rtsp_transport tcp -i rtsp://localhost:5544/live/test110 -vcodec copy -acodec copy -f flv /tmp/test110.flv
8 Test file
Test file download address:
https://github.com/q191201771…
Test file conversion generation command:
$ffmpeg - I wontcry. Mp4-acodec aac-vcodec h264-r 15-g 30-keyint_min 30-bf 0-f FLV wontcry. FLV # -r 15 FPS FLV, $ffmpeg - I wontcry. Mp4-ac-vcodec h264-r 15-g 30-keyint_min 30-bf 0-f FLV wontcry. Represents 1 second encoding 15 frames # -G 30 GOP size, that is, I frame interval, 1 I frame per 30 frames, # -keyint_min 30 minimum GOP size # -bf 0 does not use B frame encoding # -acodec AAC output file audio encoding uses AAC # -vcodec H264 output file video encoding uses H264 # -i Mp4 input file # -f FLV wontcryflv. FLV output FLV file $ffmpeg -i wontcry.flv -acodec copy-vcodec copy-t 30-f FLV $ffmpeg -i wontcry30s. Flv-acodec aac-vcodec hevc-r 15-g 30-keyint_min 30-bf 0. $ffmpeg -i wontcry30s -preset ultrafast -x265-params "bframes=0" -f FLV hevc. FLV # Transcode to 265 without B frame
Ffmpeg installation
- Linux install ffmpeg
- MacOS builds Jinshanyun KSVC FFMPEG and supports HEVC H265 on top of RTMP FLV
- MacOS compiles FFPlay, the player in FFMPEG
- The FFmpeg compiled in MacOS Catalina 10.15.1 environment does not run and crashes on startup
The original is not easy, please indicate the article reprinted from open source media server lal, Github:https://github.com/q191201771/lal official documentation: https://pengrl.com/lal
yoko, 20210206