When I play the HLS output on a VideoJS client/player, I used to observe pixelated view (A view where there are few pixels / macro blocks yet to be replaced by new frames, and the view is distorted). I used a transport stream that has h.264 encded streams. This is also called macro blocking. The set up is same as what I have been using, an adaptive transport stream source over internet, a convertor to RTSP, and HLS encoder using ffmpeg. The possible causes can be:
a. The client is unable to process the frames
b. The HLS encoder is not able to process the frames
c. The RTSP streamer is not able to process.
Client processing can be a reason if the HLS fragments produced in the server reflect proper quality.
It is a little tricky to isolate between the HLS encoder and RTSP streamer. A good way to understand can be by playing the Adaptive Transport Stream source. This is most likely to work. The players will have a capability to buffer the content.
It is also possible to use an RTSP client to play the RTSP stream. The player will be able to play clearly for the most part. The RTSP delivery system is more robust than the HLS stream and takes care of buffering ensuring better quality.
I check the ffmpeg logs, and found the following constantly thrown out, at regular intervals.
{ message: ‘ffmpeg_xxx:Err[rtsp @ 000001b459c6e640] max delay reached. need to consume packet’,
{ message: ‘ffmpeg_xxx:Err[rtsp @ 000001b459c6e640] RTP: missed 7 packets’,
{ message: ‘ffmpeg_xxx:Err[h264 @ 000001b45b81fac0] left block unavailable for requested intra mode’,
{ message: ‘ffmpeg_xxx:Err[h264 @ 000001b45b81fac0] error while decoding MB 0 29, bytestream 13200’,
{ message: ‘ffmpeg_xxx:Err[h264 @ 000001b45b81fac0] concealing 184 DC, 184 AC, 184 MV errors in I frame’,
{ message: ‘ffmpeg_xxx:Err[h264 @ 000001b459c6ab80] co located POCs unavailable’,
All these indicate that there is an issue in transcoding the RTSP stream due to packet loss, or decoding the macroblocks. DC, AC and MV errors are co-efficients used in Digital Cosine Transforms of the raw video compression algorithms. These can be listed as:
a. Issue between I frames
b. Issue between P frames
c. Issue between B frames
Out of these, B frames will not create much of an issue. if prolonged I frames are missing, one can get buffering indications on the client, or there can be a video which is stuck. Progressive frames work on exiting I frames and if we lose data we are likely to have macro blocks which are not processed.
There are few more items we can look into:
a. Change the bitrate with respect to quality
b. Change the buffer used while processing, increasing helps
c. Change the transcoding to multiple stages and not perform all at once.
In my case I still had pixelated view, so decided to make sure that RTSP streamer does not read from internet but it can from a local file. This definitely improved the quality. In effect now I need to ensure that in memory buffer is not sufficient, rather parsing content from local file system helps.