当前位置:网站首页>RTSP streaming using easydarwin+ffmpeg
RTSP streaming using easydarwin+ffmpeg
2022-06-13 04:58:00 【Sunset class】
One 、 background
Studying recently ffmpeg Basic operation ,ffmpeg Very powerful , Can run Audio And video in multiple formats 、 transformation 、 Stream function , Contains libavcodec—— This is a decoder library for audio and video in multiple projects , as well as libavformat—— An audio and video format conversion library
You can use ffmpeg Splice media files , transformation , Recording , Screenshot , Push the flow and so on , This time, we use ffmpeg Push the local video file to the streaming media server, and then html The operation of streaming and playing , The required configuration and preparation are as follows .
| name | remarks |
| Ffmpeg | Streaming tools |
| EasyDarwin | Streaming services |
| Centos7 | The server |
Two 、 install EasyDarwin
EasyDarwin Is a high-performance open source RTSP Streaming media server , be based on go Language development , Maintenance and optimization RTSP Push mode forwarding 、RTSP Pull mode forwarding 、 videotape 、 retrieval 、 The playback 、 Keyframe cache 、 Second on screen 、RESTful Interface 、WEB Background management 、 Distributed load balancing !
Media services in easydarwin Download and install the version that conforms to the server from the official website of
wget https://github.com/EasyDarwin/EasyDarwin/releases/download/v8.1.0/EasyDarwin-linux-8.1.0-1901141151.tar.gz
tar -zvxf EasyDarwin-linux-8.1.0-1901141151.tar.gz
cd EasyDarwin-linux-8.1.0-1901141151/

After entering the installation directory, there is a easydarwin.ini file You need to configure the service account and port .
[http]
port=3000
default_username=admin
default_password=admin
[rtsp]
port=2379
; rtsp Timeout time , Include RTSP Establish connection and send and receive data .
timeout=28800
; Whether to enable gop cache. If enabled , The server caches the last I Frame and subsequent non I frame , To increase playback speed . But it may cause memory pressure in the case of high concurrency .
gop_cache_enable=1
; Whether the user name and password can be verified when streaming to the server or playing from the server . [ Be careful ] Because the server does not store plaintext passwords , So when pushing or playing , The client should enter the password md5 After the value of .
; password should be the hex of md5(original password)
authorization_enable=0
; Whether to enable pushed colleagues to store locally , After enabling, video query and playback can be performed .
save_stream_to_local=0
;easydarwin Use ffmpeg Tools to store . It means ffmpeg The path of the executable program
ffmpeg_path=/Users/ze/Downloads/ffmpeg-20180719-9cb3d8f-macos64-shared/bin/ffmpeg
; Local store the root directory to be saved . If it doesn't exist , The program will try to create the directory .
m3u8_dir_path=/Users/ze/Downloads/EasyDarwinGoM3u8
; Slice file duration . When storing locally , This time period will be used as the standard to generate ts file ( The time + One I Frame spacing ), Unit second .
; If you need live broadcast , Let this value be smaller , But this will produce a lot ts file ; If you don't need live broadcast , As long as it is stored , It can be set larger .
ts_duration_second=6
;key It is the user-defined path for pulling flow ,value by ffmpeg Transcoding format , For example, it can be set to -c:v copy -c:a copy, Express copy The source format ;default Said the use of ffmpeg Built in output format , Will transcode .
/stream_265=default
about rtsp Streaming testing and use only need to pay attention to http Port number and account of the service part ,rtsp Partial port configuration . When configuring , Note that the server port is open .
Run directly under the installation directory .start.sh The script can start EasyDarwin service , because EasyDarwin Yes, it is golang To write , Therefore, the server configuration is required golang Installation environment .

Open after startup open in browser The server ip: port

You can't see any information before streaming .
3、 ... and 、Ffmpeg Push stream operation
Get into FFmpeg Releases · BtbN/FFmpeg-Builds · GitHub Download the corresponding version on the official website , After decompressing bin The contents are as follows .

Uploading … Re upload cancel

| describe | Study | |
| ffmpeg | FFmpeg Is the leading multimedia framework , can decode 、 code 、 transcoding 、 complex use 、 Explain Reuse 、 flow 、 Filter and Play Almost everything created by humans and machines | About FFmpeg |
| ffplay | FFplay It's a use FFmpeg Kuhe SDL Library of very simple and portable media players . It is mainly used for a variety of FFmpeg API Test platform of . | ffplay Documentation |
| ffprobe | ffprobe Media information can be collected from media streams , And print out a format that developers can read , Also can put the ffprobe Understand as a streaming media analysis tool ; Use ffprobe You can view the containers contained in the streaming media , And the format and type of streaming media contained in the container | ffprobe brief introduction - Simple books |
The functions of the three packages are different , It's powerful . For details, please refer to the official website

// Push local media files
ffmpeg.exe -re -stream_loop -1 -i 1out.mp4 -vcodec h264 -f rtsp rtsp://49.232.162.xxx:2379/test
// Video recording and streaming
ffmpeg -f gdigrab -i desktop -r 15 -vf scale=640:360 -rtsp_transport tcp -vcodec h264 -f rtsp rtsp://localhost/capture
// Recording screen
ffmpeg -f gdigrab -i desktop -f mp4 out.mp4Use this command to set the local 1out.mp4 Push video to the streaming server , Note that the format used this time is rtsp, Of course you can specify other formats , Note that the push address port is the specified open port of the media service .
When the streaming is successful, it will be in EasyDarwin The corresponding streaming record can be seen at the service address of .

Four 、 Pull flow operation
After successfully pushing the flow, you can pull the flow , Copy the playback address in the streaming list , After copying, you can use VLC The tool plays

When the playback is normal, in EasyDarwin The corresponding pull records can be seen in the pull list of the service

This completes the function of pushing the local stream to the remote streaming service and playing the stream .
边栏推荐
- Hidden implementation and decoupling, knowing Pimpl mode
- RuoYi-Cloud启动教程(手把手图文)
- UNO
- Embedded hardware - read schematic
- rainbow
- Clause 31: avoid default capture mode
- 2021tami/ image processing: exploiting deep generative priority for versatile image restoration and manipulation
- 2022 oxidation process operation certificate examination question bank and simulation examination
- QT using layout manager is invalid or abnormal
- The processing flow of thread pool depends on the core parameters
猜你喜欢

Embedded hardware - read schematic

PostgreSQL Guide: Insider exploration (Chapter 7 heap tuples and index only scanning) - Notes

Win8.1和Win10各自的優勢

Section 8 - Practical commissioning techniques

Solution to sudden font change in word document editing

LeetCode第297场周赛(20220612)

Simple-SR:Best-Buddy GANs for Highly Detailed Image Super-Resolution论文浅析

利用Javeswingjdbc基於mvc設計系統

Draw a hammer

Logical point
随机推荐
CMB's written test -- data analysis
C language learning log 10.11
Embedded hardware: electronic components (1) resistance capacitance inductance
QT using layout manager is invalid or abnormal
Mind mapping series - Database
Section 2 - branch and loop statements
Clause 32: moving objects into closures using initialization capture objects
Solution to sudden font change in word document editing
Mysql8.0.13 installation tutorial (with pictures)
Cesium:cesiumlab makes image slices and loads slices
Analysis of scoped attribute principle and depth action selector
Explain the role of key attribute in V-for
Tita performance treasure: remote one-on-one discussion
Explain the differences and usage scenarios between created and mounted
Analysis on the usage, response and global delivery of provide/inject
Clause 28: understanding reference folding
Article 49: understanding the behavior of new handler
Conception d'un système basé sur MVC avec javaswing JDBC
QT interface rendering style
MySQL8.0.13安装教程(有图)