popcornmix / omxplayer

omxplayer
GNU General Public License v2.0
1.01k stars 334 forks source link

Strange "qlitches" after streaming some time rtsp #127

Open RaumKraehe opened 10 years ago

RaumKraehe commented 10 years ago

Hello and sorry for my poor englich.

I have some problems streaming rtsp streams with the raspberry pi and omxplayer. Initially everything works well but after the streaming is running some time (5 Minutes) i get some strange "glitches" on the screen.

    Build date: Sun, 05 Jan 2014 15:51:34 +0100
    Version   : 74f4be2 [master]
    Repository: https://github.com/popcornmix/omxplayer.git

    Linux raspberrypi 3.10.24+ #614 PREEMPT Thu Dec 19 20:38:42 GMT 2013 armv6l GNU/Linux

Tested with 64/128/256 MB Ram. Makes no differenz.

I am using atm a Matrox Maevex BP52215 hardware encoder witch is able to encode H264 in 1080p@60 FPS. I can watch the stream without any problems on serveral different devices and programms. It runns fine on my Ipad, on the original Matrox reciever and i can watch the stream with vlc. No glitches at all.

Videoproof: http://www.youtube.com/watch?v=rue_Ch0VPno

On the left side you see vlc decoding on the right side you see the rasperry pi is decoding 1080p@60fps with 15 Mb/s very well.

But after some time (about 2-5 min) i get these results:

http://www.youtube.com/watch?v=sGUPgVr-vnw

You can see the glitches on the right side. Raspberry pi is decoding here.

So, what i have tested to get off the glitches:

  1. Reducing Bandwith
  2. Reducing GOP. Actually my GOP is 3. I sending I/P/B. with higher GOP the glitches are seen longer and the picture is much more distorted.
  3. Sampling only every second picture. To get max. 30 fps. But the result ist not as smooth as it should be.
  4. I have the feeling that the Option "--live" helps a bit. but not much.

All these steps can reduce the glitches but dont stopping them to appear. Thy become a bit smaller. All glitches are always on the bottom of the screen, never on top.

I am not shure if this problem is really affected bei omxplayer. Maybe some of the h264 hardware driver is broken? Who knows? I dont. :(

Starting omxplayer gives me this info:

pi@raspberrypi ~ $ omxplayer --live rtsp://192.168.5.96:8554 Invalid framerate 90000, using forced 25fps and just trust timestamps Video codec omx-h264 width 1920 height 1080 profile 66 fps 25.000000 Audio codec aac channels 2 samplerate 32000 bitspersample 16 Subtitle count: 0, state: off, index: 1, delay: 0 V:PortSettingsChanged: 1920x1080@24464.00 interlace:0 deinterlace:0 par:1.00

It looks like there is a problem with the 60fps? But the glitches are still there if i am forcing 30fps. But smaller.

omxplayer stream info:

pi@raspberrypi ~ $ omxplayer -i rtsp://192.168.5.96:8554 [h264 @ 0x1808f50] Missing reference picture, default is 0 [h264 @ 0x1808f50] decode_slice_header error [h264 @ 0x1808f50] RTP: missed 456 packets [h264 @ 0x1808f50] RTP: missed 732 packets [h264 @ 0x1808f50] concealing 2077 DC, 2077 AC, 2077 MV errors in I frame [h264 @ 0x1808f50] RTP: missed 662 packets [h264 @ 0x1808f50] Invalid level prefix [h264 @ 0x1808f50] error while decoding MB 67 33 [h264 @ 0x1808f50] concealing 4182 DC, 4182 AC, 4182 MV errors in I frame [h264 @ 0x1808f50] RTP: missed 398 packets [h264 @ 0x1808f50] RTP: missed 633 packets [h264 @ 0x1808f50] RTP: missed 717 packets [h264 @ 0x1808f50] RTP: missed 428 packets [h264 @ 0x1808f50] RTP: missed 603 packets [h264 @ 0x1808f50] RTP: missed 1 packets [h264 @ 0x1808f50] RTP: missed 21 packets Input #0, rtsp, from 'rtsp://192.168.5.96:8554': Metadata: title : Session streamed with GStreamer comment : rtsp-server Duration: N/A, start: 0.031600, bitrate: N/A Stream #0:0: Video: h264 (Baseline), yuv420p, 1920x1080, 90k tbr, 90k tbn, 180k tbc Stream #0:1: Audio: aac, 32000 Hz, stereo, fltp have a nice day ;)

Missing packets, Errors in I-Frame. All this sounds good. to explain the glitches. But why every other device i had testes shows the stream fine? Why the raspberry is able to play the stream for 5 Minutes without any problems?

Interresting Fact: If i take 2 Raspberrys and these two devices are showing the same stream side by side, both of the devices showing the glitches at the same time!

Please help. :)

RaumKraehe commented 10 years ago

You can find the log file (-g) here: https://dl.dropboxusercontent.com/u/6880789/omxplayer.log

popcornmix commented 10 years ago

Can you record the stream to a file (perhaps using vlc) and then try playing the file on the Pi? If that fails, then it's related to decoder on Pi, and I can analyse the file.

If that works, then it's more likely network packet loss. Are you using ethernet or wifi? Is the rtsp using udp or tcp?

RaumKraehe commented 10 years ago

thanks for the answer.

  1. Should i record the stream direktly on the raspberry or on the other machine running vlc. (Windows)
  2. I thougt by myself that maybe i have a network problem so i decided to build up a network for the test only. 1 Gb/s, wired, nothing else exept the stream is running. I can monitor the switch and i didnt see any packet losses.
  3. Thats a good question. How i can find that out?
popcornmix commented 10 years ago

Record on good system (vlc on windows). Then try playing the file on Pi.

RaumKraehe commented 10 years ago

atm i got it to dump the stream with mplayer on the rasperry to a pipe or file and then i let omxplayer to player this file. When i did so i have no errors or glitches but the performance is very poor.

I tryed to record but i have to recode the stream using vlc. or i did not see the point. :)

To the network: all my clients are attached to the network. Thats are 1 Ipad, 1 Matrox encoder, 2 Raspberrys und 2 clients with vlc. But only the raspberrys showing the glitches. No other device shows any problems.

popcornmix commented 10 years ago

I'm guessing rtsp is using udp, and the bandwidth is high enough that the Pi is not keeping up. As it's udp the packets are dropped. If you dump to a file and play it over network it will not drop any packets, but may stop to buffer frequently if bandwidth is not available.

What is the bitrate of the stream? What bandwidth can you get from the PC to to the Pi using iperf? How busy (using top for example) is the Pi when omxplayer is running?

RaumKraehe commented 10 years ago

i also guess so. But i read that others was able to play a stream even with higher bandwith.

  1. Bitrate of the stream is about 15 Mb/s. But even with 5 Mb/s i have glitches but they are "smaller"
  2. Client connecting to 192.168.5.89, TCP port 5001 TCP window size: 64.0 KByte (default)

    [ 3] local 192.168.5.94 port 59143 connected with 192.168.5.89 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 95.4 MBytes 79.8 Mbits/sec

I think it is ok.

  1. omxplyer uses about 44-54% CPU.
RaumKraehe commented 10 years ago

What i am wondering about:

if i record the stream with mplayer and after that playing the dump with omxplayer the result is completly different than streaming directly. The Picture ist much more "clear" and "sharp" but it plays slower and not so smooth. strange.

popcornmix commented 10 years ago

That would be explained by difference in udp and tcp protocols. udp packets can be dropped if not dealt with in time. tcp packets will be retransmitted, so will always be correct, but may be late.

RaumKraehe commented 10 years ago

i got down to 5 Mb\s´again. The picture is now realy crappy and still after 3-5 mins the glitches come up.

What i dont understand: If the performance is so poor that the raspi has to drop packets why this never happend in the first 3-5 Minutes? And why i am getting more glitches over the time? If packets are droped than it should happen randomly from time to time. I am using a constant bitrate. No VBR. And why then two raspis side by side dropping the same packets at the same time? That sounds strange. :)

popcornmix commented 10 years ago

Are you using --live in these tests? (You should be).

Ruffio commented 9 years ago

@RaumKraehe is this still an issue?