google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.73k stars 6.03k forks source link

4K High bit rate video Frame drop seriously Play by UDP #8091

Open arlimm318 opened 4 years ago

arlimm318 commented 4 years ago

version: Exoplayer-dev-v2 2.11.7 device: STB hisi android version:4.4 run mem: 1G

When I played the 4K video over UDP by exoplayer, it looked very slow. But The Android MediaPlayer is ok. But ,the the 4K video over http by exoplayer is ok.

I doubt the player is good for UDP support.

The parameters of the video are 4K(3840 x 2160) 50fps and 40Mb bitrate .

andrewlewis commented 4 years ago

I doubt the player is good for UDP support.

Do you have any ideas about where the inefficiency in UDP support is, so we can try to address them?

Unfortunately I don't think we have this test device, and there isn't enough information here for us to reproduce your setup anyway (we'd need a test stream too).

If you can take bug reports after playing the media first with MediaPlayer then with ExoPlayer and attach them, we can check whether the same decoders are being used and see if there's signs of anything obviously going wrong in the media framework based on logging. Beyond that I don't think we have enough information to help.

arlimm318 commented 4 years ago

The test Video is to big ,Can't upload. Only parameters of test videocan be provided for the time being。 4K(3840 x 2160) 50fps and 40Mb bitrate .

andrewlewis commented 4 years ago

If you can address the question in my previous comment or share more findings from your own investigations we can try to do something to improve the situation. Otherwise I don't think it's actionable for us.

arlimm318 commented 4 years ago

4k2.pcap_232.0.10.69_50000_00.zip 4k2.pcap_232.0.10.69_50000_01.zip 4k2.pcap_232.0.10.69_50000_02.zip 4k2.pcap_232.0.10.69_50000_03.zip 4k2.pcap_232.0.10.69_50000_04.zip

arlimm318 commented 4 years ago

4k2.pcap_232.0.10.69_50000_05.zip 4k2.pcap_232.0.10.69_50000_06.zip 4k2.pcap_232.0.10.69_50000_07.zip 4k2.pcap_232.0.10.69_50000_08.zip 4k2.pcap_232.0.10.69_50000_09.zip

arlimm318 commented 4 years ago

4k2.pcap_232.0.10.69_50000_10.zip 4k2.pcap_232.0.10.69_50000_11.zip 4k2.pcap_232.0.10.69_50000_12.zip

arlimm318 commented 4 years ago

The Test video is too big,so I compressed him into different volumes. total 13 volumes

arlimm318 commented 4 years ago

the log play 4k by exo exo_4k.log

arlimm318 commented 4 years ago

the log play 4k by mediaplayer ,Very smooth [Uploading mediaplayer_4k.log…]()

andrewlewis commented 4 years ago

Based on your first comment, the device is running an old Android version 4.4 (API 19), so we don't get the benefit of timed frame release and I think that version was still using dalvik not ART (though it had a testing version of ART available). We've been experimenting with async MediaCodec methods, but those too were added later than this version. Also video tunneling isn't available, and that can help a lot on low end devices. The earliest official version of Android TV was Android 5 Lollipop (API 21). You could see if there is a system update available for the device to try using some of these features that can help performance for in-app player implementations.

The MediaPlayer log link doesn't seem to be working for me, but I'm not sure there's any point in looking at it as I can tell from the ExoPlayer logs we are trying to use what looks like a hardware decoder (we aren't picking a software decoder, which is what I wanted to check).

Finally, you could try playing a format that's cheaper to extract. The logging provided contains some logs (presumably added by you?) that mention H265Reader, which suggest this is an MPEG-TS stream. Do you see the same performance difference if you play an MP4?

arlimm318 commented 4 years ago

I can confirm that exoPlayer uses a hardware decoder. I understand The high Android API supports asynchronous decoding. But ,the the same 4K video played over http by exoplayer is ok on the same device,Although this device is quite old(API19), but played over udp is not ok。 I think, thismeans that the device has the ability to play the 4k video. Could you please explain that,Why the http is ok but the udp is not ok?

andrewlewis commented 4 years ago

When you play this using MediaPlayer are you using HTTP or UDP?

arlimm318 commented 4 years ago

UDP

andrewlewis commented 4 years ago

Please could you actually share the logs from MediaPlayer? Contrary to my previous message there may be some useful logging from NuPlayer about how the stream is being handled.

It would also be useful if you provide instructions for producing a similar UDP stream, or at least some more information on how it was produced. E.g., is this RTP over UDP or something else?

arlimm318 commented 4 years ago

The log of mediaplayer 1.log

arlimm318 commented 3 years ago

why the UdpDataSource copyarray when readData. the code in UdpDataSource function { public int read(byte[] buffer, int offset, int readLength) } line 143

@Override public int read(byte[] buffer, int offset, int readLength) throws UdpDataSourceException { ......... ........... ........ System.arraycopy(packet.getData(), packetOffset, buffer, offset, bytesToRead); packetRemaining -= bytesToRead; return bytesToRead; }

I think , If the bit rate is high, copy data may be inefficient. And why not just read the data?

ojw28 commented 3 years ago

@lcf87 - Does the question above overlap with the work you're doing at all? I wonder whether it works to do packet.setData(buffer), so that the data is read directly into the buffer and the System.arraycopy can be avoided.

@arlimm318 - Whilst we will look at the above, it seems very unlikely that this is the problem. We haven't seen performance problems due to memory copies elsewhere.

arlimm318 commented 3 years ago

Does the LoadControl work when playing UDP streams? I'm going to set the buffertime parameters, but it doesn't seem to work.

arlimm318 commented 3 years ago

I found a way to solve the problem,I use C code to receive UDP streams and it adds a buffer,Caton's problems have improved markedly。

andrewlewis commented 3 years ago

@lcf87 Any thoughts on the question about the array copy above? I think this can be closed once you've taken a look.