Jump to content

Playback Lagging on High-Bitrate Movies


bhelm

Recommended Posts

i play .mkv's that are getting remuxed for streaming. some movies freeze every some seconds, some only on high-bitrate scenes (rain, wild-river water, action) and sometimes a movie runs fine for an hour and freezes just once for 15 secs and then continues to run fine.

 

How much MB does Emby buffer in advance on the FireTV / Web player ?

Is there/can you add a way to increase the buffer?

 

I have a hybrid internet connection that offers up to 50Mbit download speed - but it sometimes drops to 12 or 20Mbit for some seconds just to return back close to its full speed. Hybrid means it is 12Mbit over phone line and 38Mbit over cellular network. Its reasonable that there may be sudden drops on the speed at peak times.

 

The movie i were playing recently had 15GB of size and 120 minutes runtime. this means ~125MB per minute or ~20Mbit per second. This should not be impossible with my internet connection.

 

The FireTV has 2GB of RAM. if the Emby app would use 300MB for buffering, i think it could compensate for a 2-Minute drop of the internet speed.

 

It could also be possible to buffer to the internal storage or to an external usb and load a large amount of the video in advance. It would be fine for me to start the movie, pause it, make some popcorn and then enjoy a lagfree playback.

Link to comment
Share on other sites

i have had no time to watch a movie yesterday.

 

but i was curious how much emby actually buffers, so i did some tests on my firetv:

 

i started a movie, let it run for some seconds, paused it for a minute and then disconnected the network cable. after that i pressed play and measured the time how long the movie runs.

 

Emby: 22 to 30 seconds

Netflix: 2:50 Minutes

Amazon Video: 3:03 Minutes

 

Also tested on the Emby Webplayer with Firefox 55: 35 secs

with another 1080p movie: 50 secs

with a 720p movie: 1:35 minutes

 

i know that the 1080p movie on emby could have a higher bitrate than 1080p on netflix/amazon, but its not multiple times higher. i also know that netflix/amazon can change the bitrate on the fly if the internet gets slower, thats why i have waited some secs until the picture was best quality.

 

either emby detects the connection loss and quits before the buffer is empty or the buffer is significantly smaller than on netflix/amazon.

 

i took a look at the chunks created and noticed that some are much bigger than others:

-rw-rw-r-- 1 xxx xxx 11083352 Oct 10 18:04 af609d28516308b0345dc704f9dd4b27118.ts
-rw-rw-r-- 1 xxx xxx 12693384 Oct 10 18:04 af609d28516308b0345dc704f9dd4b27119.ts
-rw-rw-r-- 1 xxx xxx 15227060 Oct 10 18:04 af609d28516308b0345dc704f9dd4b27120.ts
-rw-rw-r-- 1 xxx xxx 16215188 Oct 10 18:04 af609d28516308b0345dc704f9dd4b27121.ts
-rw-rw-r-- 1 xxx xxx 12445036 Oct 10 18:04 af609d28516308b0345dc704f9dd4b27122.ts
-rw-rw-r-- 1 xxx xxx 13050208 Oct 10 18:04 af609d28516308b0345dc704f9dd4b27123.ts
-rw-rw-r-- 1 xxx xxx 28397212 Oct 10 18:04 af609d28516308b0345dc704f9dd4b27124.ts <---------
-rw-rw-r-- 1 xxx xxx 38448444 Oct 10 18:04 af609d28516308b0345dc704f9dd4b27125.ts <---------
-rw-rw-r-- 1 xxx xxx 36668084 Oct 10 18:04 af609d28516308b0345dc704f9dd4b27126.ts <---------
-rw-rw-r-- 1 xxx xxx 35456236 Oct 10 18:04 af609d28516308b0345dc704f9dd4b27127.ts <---------
-rw-rw-r-- 1 xxx xxx 35480488 Oct 10 18:04 af609d28516308b0345dc704f9dd4b27128.ts <---------
-rw-rw-r-- 1 xxx xxx 15753084 Oct 10 18:04 af609d28516308b0345dc704f9dd4b27129.ts
-rw-rw-r-- 1 xxx xxx 16123444 Oct 10 18:04 af609d28516308b0345dc704f9dd4b27130.ts
-rw-rw-r-- 1 xxx xxx 15118584 Oct 10 18:04 af609d28516308b0345dc704f9dd4b27131.ts
-rw-rw-r-- 1 xxx xxx 13450272 Oct 10 18:04 af609d28516308b0345dc704f9dd4b27132.ts

each chunk is ~5 seconds, so there are 5x5 (=25) seconds where the bitrate of the movie almost trippled (average per chunk is ~12mb, here is a longer list: https://pasti.ng/9WAt57Z5wQX ) and i would require 3x more bandwith to play those 25 secs than i need for the rest of the movie. and i think a larger buffer could compensate this.

 

if i calculate: 28+38+36+35+35 = 172MB for 25 secs of the movie. that would require a downstream of 6,8MB/s which i dont have (i have only 5MB/s max and i actually had a massive lag at this scene of the movie). The average of the movie is only 2MB/s.

 

So that is the reason why i think a larger buffer could help compensate this and other problems like 1-minute server overload or drop in internet speed when someone at home downloads a 300MB file.

 

Thank You.

Link to comment
Share on other sites

Jdiesel

This is one a drawback of using VBR for video files. During periods of high bitrate demand (usually fast action scenes) the bitrate can often double or triple the average bitrate of the file. If the period lasts too long it can cause the buffer to run out. These peaks can make an otherwise perfectly watchable video buffer at points.

 

@@Luke what is the default buffersize of exoplayer set to? 5s? Or is it based on the segments? The problem with setting the buffer to large is that people will have to wait for the buffer to fill before when watching a live stream or when FF/RW. People would get pretty angry if they have to wait 10s or 15s for their video to start. Maybe having an in-app setting would be nice for those with spotty network connections though

Edited by Jdiesel
Link to comment
Share on other sites

@@bhelm we may have been stream copying that video without transcoding, in which case that would explain the size fluctuation between segments. If we're not re-encoding the video, then we're subject to whatever is in the original video.

 

if you can provide the information requested in post #2 we can investigate further. thanks.

Link to comment
Share on other sites

in #1 i said that it is remuxing. i know that transcoding would *solve* the playback lag issues, in some cases this is the only way. i have set the max bandwith to 40 Mbits which should be fine. i guess it is complicated to detect if a VBR movie would stay within this limit all the time and enable the transcode automatically. i would like to see some "force transoding to max xxxMbit" option, because even if i choose 20Mbit in the app, it is not clear to me if it emby would detect the movie as subject to transcoding. on the other hand, if i choose a lower limit like 10 mbit, i can be relatively sure, but i will loose more quality than required.

 

i have reproduced the problem, sent logs at 20:04 GMT+2 and logged in user was Bernd. also see attached server logs.

i was starting the movie, seeking forward to 11:00 (the part where the high bitrate occures for 25 seconds), paused it until network traffic stops and let it play. it ran for ~1 minute and lagged for 8 seconds on the high bitrate part.

 

all the tests i did were with this scene so i can compare the results, and i have some conclusions:

 

Testing the scene with embys default player causes lags with high probability in the high bitrate scene but also sometimes (not always) before and after this.

 

I have setup Kodi as external player and set the cachesize variable to 500MB. I can see the paused kodi load 250MB from the emby server (using iftop, watching accumulated traffic). it ran the test scene without problems and continues (but i did not watch the full movie yet).

with the default kodi cache, freezes were even worse than with embys player.

@Jdiesel: even with the large buffer size, kodi starts playing quickly. the buffer can be filled in the background. emby also does it that way from what i have seen.

 

when looking at the read-ahead traffic of the emby player, its 60-80MB.

 

so i wish there would be a way to configure the buffer size for emby, like 100/150/200/250/300 MB.

it would help to avoid lags on a range of problems - even for users with local emby servers but unstable wifi connections, and also if i were transcoding everything - a larger buffer would help on temporary speed drops.

 

I could use the buffer-tuned kodi now, but it is not as comfortable as embys own player, because emby can not see when you stopped watching and does not let you resume at that point.

 

Last but not least: i have found the (known problem) that the ethernet port of the firetv is bad. its only 100Mbit and seems to cap at 30mbit for me. so this limited the maximum bandwidth of my 50Mbit internet. wifi was a little better but i think its not as stable as a wired connection. I have plugged an USB-to-Gbit Network Adapter to the firetv and now see better results than ever. My tests today were done that way.

ffmpeg-remux-f2032114-fcf4-4ad7-8224-b794445e66e8.txt

ffmpeg-remux-7234c467-3384-4880-b22b-152b47af2c16.txt

server-63643435331.txt

Edited by bhelm
Link to comment
Share on other sites

We don't currently have that kind of per segment bitrate information in our database. We could collect that during the library scan, but the time to perform that analysis would be considerable. So yes, when stream copying that means there will potentially be some fluctuation. We can certainly look into increasing video player buffer sizes though where possible. Thanks.

Link to comment
Share on other sites

Note that the trade-off to increasing buffer sizes on the client end is the memory footprint of the app...

Link to comment
Share on other sites

Jdiesel

Note that the trade-off to increasing buffer sizes on the client end is the memory footprint of the app...

 

It has never even crossed my mind to monitor the memory usage on the Android TV app. I'd imagine you'd have to target the minimum hardware specs which would probably be 1GB of memory unless there are devices out there with less than 1GB. 

Link to comment
Share on other sites

maegibbons

Note that the trade-off to increasing buffer sizes on the client end is the memory footprint of the app...

 

Emby is the only thing I use on my Fire TV's.  It can have it ALL :)

 

I never run more than 1 app at a time for sure.

 

I know you hate options but you could just have "Lean" and "Full Fat"

 

Krs

 

Mark

Link to comment
Share on other sites

because the "big internet streaming ones" (netflix, amazon) are seem to target a buffer that contains 3 minutes of material, emby could try to target 3 minutes too. So for low-bitrate material, a smaller buffer would be sufficient and on high-bitrate it should try to max out, with a limit of something like 30-40% of the devices memory. afaik, android stops other applications to free up memory if the foreground app requires more. when watching a movie, i dont care much about what happes to netflix and other apps that run in the background, as long as i can enjoy an uninterrupted movie.

 

Thank you :)

Link to comment
Share on other sites

  • 1 year later...
Gerrit507

Was this resolved anyhow?

 

I currently got the exact same issue on AndroidTV when playing 4K movies with a bit-rate of about 30 Mbps. As soon as there is an action scene with a lot of movement, the movies stucks and buffers. This can happen 10-20 times in a single movie. It's so annoying. It's direct play from home-network over lan, the network shouldn't be any problem in this case. I've played higher bit-rates with this TV.

Edited by Gerrit507
Link to comment
Share on other sites

Gerrit507

This would be an example. I think the cause of the issue is the variable bitrate. The app builds the buffer size from the bitrate of the beginning and then in action scenes the buffer runs out. Sometimes it can help to restart to movie at the time where it stopped and then apperantly it's building up a larger buffer. I don't see any reason why it's necessary to save memory on a device, which only purpose is to play that video at this time...

 

5c278affed209_movie.jpg

Link to comment
Share on other sites

I can try this. Can you give an technical explanation behind that suggestiion please?

 

You are assuming the wired connection is faster but that is not necessarily the case in all instances.  Theoretically, it should be but that assumes a lot about exactly how the wired connection is implemented in both hardware and software on the device.

 

We have anecdotal evidence that the wireless connection actually outperforms a wired one in some cases.  My theory for why this may be the case is that I'd venture to say that 90% of the people running these devices these days are doing so wireless.  That is just the way the world has gone.  You don't see houses advertised as network wired anymore because it simply isn't necessary anymore.

 

Due to that, I think that Nvidia spends all their time making sure the wireless performance is up to snuff and maybe not as much with the wired one.  That is all conjecture on my part but, again, we do have evidence that wireless can work better.

 

In 10 years I won't be surprised if most people don't even have wired internet connections as that will all be wireless as well.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...