One of "Live Broadcasting Troubleshooting Series": Failed to play

Following the series of articles "Detailed Explanation of Live Streaming Technology" , we have launched a new series of "Live Streaming Difficulties and Miscellaneous Diseases". We will gradually share the experience of assisting customers in solving live broadcast problems, and will also intersperse some basic knowledge of audio and video development. The optimization experience, hoping to help developers in the field of live broadcasting.


The contents of "Live Broadcasting Troubleshooting Series" include but are not limited to the following topics:

  • Failed to play
  • Caton live
  • slow start
  • high latency
  • Audio and video out of sync
  • mosaic serious
  • Play black screen, blurry screen, green screen
  • Play noise, noise, echo
  • On-demand drag is not allowed
  • Live broadcast fever problem
  • Other questions (to be continued)

For the first article, we start with the broadcast, because the most important part of watching the live broadcast is to open the player, and the direct feedback of many questions also comes from the audience.

There are many reasons for the failure of playback, not necessarily the problem of the player itself, but through the player, it is easy for us to troubleshoot the server or push-stream problems in turn. Below we will discuss the performance of playback failures, playback troubleshooting tools, and analysis of common problems.


### Playback failure performance The playback failure performance includes but is not limited to the following:

  1. "Loading" is always displayed on the interface, or an error prompts playback failure;
  2. The playback screen is stuck, but the UI button can be clicked;
  3. There is sound but no picture, and there is picture but no sound.

We do not discuss issues such as playback freezes, out-of-sync audio and video, mosaics, delays, and blurry screens. These topics will be discussed in subsequent articles. The focus of this article is: Why can't the live broadcast be "opened" smoothly flow?

### Playback Troubleshooter

Once we encounter that the video cannot be played, the first thing is to find a few other players to play it, do a comparison test, or do some basic analysis of the code stream, so as to better locate the source of the problem. The more common playback/analysis tools on the platform are as follows:

### Common playback failure troubleshooting basic concepts

From inputting the playback address to the player to displaying the playback screen, there are generally the following steps:

  1. DNS resolution, resolves the domain name in the playback address to the corresponding server IP address;

  2. Connect to the server and complete the http request or rtmp handshake process;

  3. Receive the data sent by the server, de-encapsulate the protocol, and get the audio and video data to decode and play.

If there is a problem in any link, it may cause playback failure. Different protocols, due to the protocol layer, the playback error is often different. In the following discussion, we mainly focus on RTMP/HTTP. The address for playing the test is as follows: RTMP live stream of Hong Kong Satellite TV: rtmp://live.hkstv.hk.lxdns.com/live/hks Test mp4 stream of W3C School: http://www.w3school.com.cn/i/ movie.mp4

Domain name resolution failed

If the domain name of the playback address cannot be resolved, it will cause the playback to fail. Generally, the network is disconnected or the domain name is invalid. During playback, an error similar to the following will be reported:

$ffplay rtmp://live.hkstv.hk.lxdns.com1/live/hks
Failed to resolve hostname live.hkstv.hk.lxdns.com1: nodename nor servname provided, or not known
Failed to resolve hostname live.hkstv.hk.lxdns.com1: No address associated with hostname

Of course, if there is a network, but the domain name resolution fails, ISP operators may return some pages similar to 404, or jump to other default web pages. Therefore, for HLS, HTTP-FLV, HTTP-mp4 and other code streams, it will be Read some "dirty data" and return some other error, for example:

$ ffplay http://www.w3school2.com.cn1/i/movie.m3u8
http://www.w3school2.com.cn1/i/movie.m3u8: Operation timed out

$ ffplay http://www.w3school2.com.cn1/i/movie.mp4
http://www.w3school2.com.cn1/i/movie.mp4: Invalid data found when processing input

When encountering this kind of error, you can generally try to ping the domain name to see if the ping is successful. If the ping fails, you may need to check the configuration of the domain name resolution.

Server connection failed

If the domain name is correct and there is a network connection status, the server IP address can be resolved normally, but the connection may still fail. service, which causes the player to fail to connect, and the errors for similar problems are as follows:

$ ffplay rtmp://www.jhuster.com/live/hks
Cannot open connection tcp://www.jhuster.com:1935
rtmp://www.jhuster.com/live/hks: Operation timed out

Because the server corresponding to www.jhuster.com does not provide rtmp streaming service, connecting to the server through 1935 will fail.

$ ffplay https://www.w3school.com.cn/i/movie.mp4
Connection to tcp://www.w3school.com.cn:443 failed: Connection refused

Because www.w3school.com.cn does not support https access, the request for https connection through the 443 interface fails.

Of course, it is also possible that this server is down although it provides rtmp streaming service. Therefore, we need to use the dig command to determine which server is finally accessed, and check why the server cannot be connected. Of course, the best It is to modify the ffpmeg source code and print the parsed server IP address, so that you can directly see the connected server address.

The requested resource does not exist

For the live broadcast address of the http protocol, the requested playback resource does not exist, and the returned error is still relatively fast, such as:

$ ffplay http://jhuster.com/live/hks.mp4
http://jhuster.com/live/hks.mp4: Server returned 404 Not Found
$ ffplay http://www.w3school2.com.cn/i/movie2.mp4
http://www.w3school2.com.cn/i/movie2.mp4: Invalid data found when processing input

Note: The above error may also be returned due to reading the "dirty data" of the jump page returned by the ISP operator.

The RTMP live broadcast protocol is very different from the HTTP protocol playback, that is, the data requested by the player is not necessarily "stored" in the server. Therefore, if the server cannot simply locate it through the URI, it will return 404. These data It may be that after the RTMP handshake, it is gradually generated by the production side and forwarded by the server to the client, so it is difficult to simply judge that "the resource does not exist".

Usually, for the live stream of RTMP protocol, if there is no push stream on the streaming end, the player usually returns an error after the read data times out, for example:

$ ffplay rtmp://live.hkstv.hk.lxdns.com/live/hks1
rtmp://live.hkstv.hk.lxdns.com/live/hks1: Input/output error

unsupported format

There are many network protocols, encoding formats, and encapsulation formats used for video streams. Network protocols such as http/https/rtmp/rtsp, etc., encoding formats such as h.264, mpeg4, aac, speex, etc., encapsulation formats such as flv, mp4, avi, rmvb, etc. Streams of these protocols and formats need to be specially supported by the player. Therefore, if the player encounters an unsupported protocol or format, it will also cause playback to fail, as shown below:

https://www.jhuster.com/xxxx.mp4 Protocol not found
https://www.jhuster.com/xxxx.rmvb Invalid data found when processing input

Only audio without video, or only video without audio

The reasons for this error may be as follows:

  1. The encoding format of the audio/video is not supported, causing the decoding to fail
  2. The data content of the audio/video is abnormal, causing the decoding to fail
  3. The probesizesetting too small, resulting in insufficient parsing stream information
  4. The first half of the stream/file itself has only audio without video, or only video without audio

The playback startup process for this problem has been completed, but there is a missing picture or audio missing, which can be regarded as a playback failure. Due to the limited space of this article, a special chapter will be extracted for analysis of this problem later.

Other playback failed

The above only analyzes the common playback failure problems. In fact, there are many reasons for the playback failure. It is impossible to list them all here. However, through the error report of ffplay, you may know the approximate reasons, and then debug and debug together with the server. Usually the root cause can be found. Here is a breakdown of common ffmpeg errors: http://ffmpeg.org/doxygen/trunk/error_8h_source.html


The author of this article: Lu Jun@七牛云. If you have questions that you are interested in, but are not in the above list, you can also write to [email protected] to communicate, welcome to follow Sina Weibo @Lu_jun or WeChat public account @Jhuster to get the latest articles and information.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325448325&siteId=291194637