I. Configure live broadcast service
Here to Tencent cloud live services for example Tencent cloud registration process is not described, registered individual, enterprise accounts can be
1.1 After registering an account, open “Cloud Live” service in Tencent Cloud
1.2 Then purchase the traffic package
As an experiment, it is enough to buy a 100GB data packet first
2. Set the traffic address
The address format of the push stream is RTMP ://livepush.[domain]/[videoname] the [] part indicates the domain name and videoname that can be customized
General live streaming cloud services allow you to bind your own domain name to point to the stream address provided by the service provider. In Tencent cloud live, you can set the stream address through “domain name management”
2.1 Binding custom domain names
You need to add two domain names
A livepush.xxx is used to push the stream
A livePlay. XXX is used for playback
After just adding, the picture is as follows
The address in the red box is the real streaming address (or broadcast address) assigned by the live streaming cloud to you.
The red exclamation mark indicates that you have not resolved the domain name to the stream address (or play address) generated for you by Tencent.
Now you need to go to your domain name service provider where to add two domain name resolution
2.2 Go to the DOMAIN name service provider to add two CNames for domain name resolution
My domain name is in Ali Cloud, I added two CNAME resolution under the corresponding domain name, the target address is the real push basin name given in the red box in the previous step
2.3 Viewing the effect after the resolution takes effect
Domain name resolution takes a certain time to take effect, ranging from half an hour to one minute
After it takes effect, you can enter the “Domain name Management” page of Tencent Live and check the status of your bound domain name
If the icon in the CNAME column in the red box below is programmed with a green check box, the binding is effective
Next you need to generate a stream address, because each stream needs a corresponding stream address
2.4 Generating a Traffic Push Address
The Address Generator page is displayed
Generate the final push stream address
Note that AppName and StreamName specified in “Push stream Address” in the previous step must be the same as those specified when “push stream address” is generated, otherwise it is not considered as the same video stream
Ok, now we have the stream address and the play address. For the sake of consistency, let’s assume a pair of set addresses for the stream: rtmp://livepush.walkye.com/live/demo3?txSecret=a8039dcb6e1f4e9f735980b7b3a968b6&txTime=5F9F7171; Play: rtmp://liveplay.walkye.com/live/demo3 next to the last step, we gathering video in raspberry pie and flow
3. Get raspberry PI video input stream and push it to local NGINx
In the previous section, we installed FFMPEG
You can use the following command line to obtain the camera video stream and specify the format and size of the video to push to the local NGINx
The local Nginx pushes the video stream to the remote live stream address based on the content in the configuration file
Before executing this command, we first check that the nginx configuration is consistent with the generated address. If not, please modify the configuration and restart nginx
If no error is reported after nginx restarts, the streaming address is correct and accessible. Then use ffmpeg command to collect the video stream and push it to execute the following command
Ffmpeg - 24-640 x480 video_size framerate - I/dev/video0 - vcodec h264 -f FLV RTMP: / / 127.0.0.1:1935 / HLSCopy the code
Command line parameter definition
-framerate framerate refers to the number of frames per second. The higher the number of frames, the more traffic will be consumed and the smoother the picture will be. Of course, the number of frames may be dropped due to poor network conditions
-video_size Indicates the video size
-i Video stream source. The USB driver dev/video0 is specified here. The specific device path can be provided according to your actual situation
– VCOdec encoding mode. In this example, the encoding mode is H264, that is, H264 soft coding
The -f format, FLV in this example, supports RTMP streams. The player can directly access xxx. FLV or RTMP :// XXX
The last parameter RTMP: / / 127.0.0.1:1936 / HLS is specified for video streaming over the delivery address This case is pushed to the local first nginx, then by nginx RTMP module coding then pushed to the remote Specific reference on a “live raspberries pie box (a)”
If the following result is displayed after execution, raspberry PI has started to push the camera video stream to push stream service
And then go to Tencent cloud – live streaming service to check the stream is also visible
At last! Use the broadcast address you defined to view the live stream
You can preview directly in Tencent live streaming management, or use streaming media player like VLC to fill in the address to view the live streaming effect