asciidisco / plugin.video.netflix

Inputstream based Netflix plugin for Kodi
MIT License
1.24k stars 225 forks source link

Videos stuttering, depending of their frame rate #600

Closed Badsheep closed 5 years ago

Badsheep commented 5 years ago

I'm submitting a ...

Prerequisites

I'm using an test version of Memphiz, named "kodi-20190104-0921308d-scriptobs_race-x86_64"

BUT it's the same with all the recent versions, like rc3 or rc4.

Description

I noticed that some Netflix videos are stuttering, on a old iMac from 2009 and on a recent MacBook Pro from 2017.

Settings : fullscreen mode, with a video projector plugged in mirroring, in 1080p. Auto adjust frame rate who works nicely :

24fps > my hdmi output switches to 24fps 25fps > my hdmi output switches to 50fps 23,976fps > my hdmi output switches to 60fps

(24,50 & 60 are the 3 modes proposed by this video projector) All the speeds are correctly detected and applied to the hdmi output, whether I use the local files or streaming.

Here's the problem :

On the old iMac :

Strange no ?

And more strange :

On the recent MacBook Pro, when I plug my videoprojector on it (mirroring, 1080p, using a dodocool hub)

crazy no ? Any help ? I'll post Logs as soon as possible.

Operating System

Additional informatin on the environment

Mac os 10.13.6

Badsheep commented 5 years ago

I'd like to precise something strange, by the way : It switches of frame rate output WITHOUT NOTHING declared in the whitelist. Is it normal ?

EDIT - Other information :

I use another streaming addon-on, "Catchup TV & more", that streams French tv, at 25fps, and it's fluid. That is why I suspect a bug in the Netflix add-on.

Badsheep commented 5 years ago

Update after more testing :

I was wrong about the MacBook Pro everything works fine.

BUT

On my old iMac, just to test, I installed the Youtube add-on, setup to use inputstream adaptive to read mpd from Youtube : everything works and is fluid, at all rates (23,976, 24, 25)

So :

I case of it might help to debug :

When I play a Youtube video and it hit "O", it display "video decoder : ff-h264 (SW)" (even if it's REALLY using inputstream adaptive, I'm sure of it I did test) When I play a Netflix video, it says "video decoder : inputstream.adaptive.h264.decoder (SW)"

Does Netflix add-on handle inputstream adaptive in a different way than Youtube add-on does ? Would it be possible to handle it so that it works like the Youtube add-on does ?

Badsheep commented 5 years ago

Here's my log. (sorry it's too big (1Mo) to go on hastebin or similar...)

I did the following steps :

All at 1080p. Video Component in Verbose Logging mode.

Thank you very much !!

peak3d commented 5 years ago

1,) Because of DRM restrictions Netflix is decoded using CPU, our device will not have enough power to decode 1080p in realtime. YT / Others have less restrictions and h/w decoder is used.

2.) If whitelist is empty, kodi uses same logic as 17.x, switch refreshrate, but no resolution. -> No bug, its a feature

Badsheep commented 5 years ago

Hello,

Thanks for answering so fast !

2) Ok cool I didn't know. I was trying to understand how the whitelist is working.

1) Well I don't think so because I desactivated hardware acceleration... And the computer is really able to read 1080p24, 1080p25 from Youtube without any stutters

Le lun. 14 janv. 2019 à 08:53, Markus Pfau notifications@github.com a écrit :

1,) Because of DRM restrictions Netflix is decoded using CPU, our device will not have enough power to decode 1080p in realtime. YT / Others have less restrictions and h/w decoder is used.

2.) If whitelist is empty, kodi uses same logic as 17.x, switch refreshrate, but no resolution. -> No bug, its a feature

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/asciidisco/plugin.video.netflix/issues/600#issuecomment-453922840, or mute the thread https://github.com/notifications/unsubscribe-auth/Ar6qd59dJx2AIlkRAXyHoJUFPPFd5f6eks5vDDeCgaJpZM4ZyYqd .

Badsheep commented 5 years ago

I even have stutters from Netflix when I use 720p, or even 576... It's really not a CPU problem to me, that's why I suspect something strange.

peak3d commented 5 years ago

Then you'll have to provide a debug log, enable video component debugging, and play a netflix movie some seconds

Badsheep commented 5 years ago

It's here.

peak3d commented 5 years ago

Have you enabed "Sync Playback To display" in settings::player::video ?

Edit: From timing / decoding I cannot see any issues, sry. Edit2: NX normaly does not play 24fps, normal is 23.97, so I wonder why 24 is selected.

Badsheep commented 5 years ago

Yes I tried, without success (it changes nothing). The auto frame rates works perfectly, I don't think the problem comes from here...

Badsheep commented 5 years ago

Ok well I think I have to accept the idea that this iMac is too old... Still it's very strange for all the reasons given (CPU not high, Youtube working perfectly,...)

Badsheep commented 5 years ago

Netflix can play 24fps movie (French/European movies like "Moi césar" for example)

In Netflix I found 23,976fps (American movies, falsy called 24fps in the states) 24fps (French/European movies) 25fps (French European TV shows, for example the show of "Blanche Gardin")

All rates are correctly detected by Kodi, and it sets the right frame rate in the HMDI output. It's just that ONLY the 24fps are correctly played.

peak3d commented 5 years ago

To be sure that audio does not play into your issue you can select Media:Video in inputstream.adaptive settings and verify if the the video without audio plays fine. I see some A/V corrections in log.

Badsheep commented 5 years ago

ok I think I already tested that but I test right away.

EDIT-Sorry I misunderstood, I haven't test that before... I test now.

peak3d commented 5 years ago

You could also try forum.kodi.tv, there are other Mac users which may arrived your issue, too

Badsheep commented 5 years ago

I already did :)

Badsheep commented 5 years ago

OK I tested with only video, same issue...

peak3d commented 5 years ago

1.) How does stutter look like? Every x secs a hickup? 2.) Pls. switch off video component logging, and enable a/v logging instead and provide a log after playing NX some seconds, thx.

Badsheep commented 5 years ago

Hello,

Well to be precise, no it's at all a hickup every second or something like that. ( I know that kind of issues as I work in sound for movies, and I know what it looks like when it's a repetitive drop frame...)

No, in my case, it looks more like it's in slow motion all the time... Let me just explain something I noticed, in case it might help :

When I set logging on, it displays the realtime rate (and others stuff) on the top left of the screen.

When I'm reading a 24fps, the frame rate constantly hesitate between 23,4 and 24,4, and it's perfectly fluid (I think the display is wrong and the real frame rate is a perfect 24)

When I 'm reading a 23,967 movie, the rate switches to 60fps (NTSC): that's the frequency allowed by my video projector, and it's working absolutely well when I'm reading a 23,976fps local video file, or a 1080p23,976 source from Youtube (the display "hesitates" between 59,5 and 60,5, and the movie is perfectly fluid).

But in the case of the Netflix plugin, the real fps hesitates between about 42 to 46fps... And that's really the impression I have when I watch. And the CPU is around 70%, like it's always when I'm reading 1080p movies, local or via streaming.

I do the new logging right now.

Badsheep commented 5 years ago

There it is.

I played a 23,967 movie (stutters) , then a 24 movie (fluid).

peak3d commented 5 years ago

Yes, looks odd, I'll try to reproduce on my windows device

Edit: What I can say from log:

10:42:10.057 T:140735637267328 DEBUG: PrepareNextRender: frameOnScreen: 3896329.285129 renderPts: 4062669.682978 nextFramePts: 4041666.000000 -> diff: 21003.682978 render: 1 forceNext: 0 10:42:10.098 T:140735637267328 DEBUG: PrepareNextRender: frameOnScreen: 3937676.479129 renderPts: 4104016.876978 nextFramePts: 4083333.000000 -> diff: 20683.876978 render: 1 forceNext: 0 10:42:10.140 T:140735637267328 DEBUG: PrepareNextRender: frameOnScreen: 3979390.094129 renderPts: 4145730.491978 nextFramePts: 4125000.000000 -> diff: 20730.491978 render: 1 forceNext: 0

RenderLoop should be called every vsync, this is every 16ms on your 60Hz display. But it is not -> This should be investigated by someone who has comparable device / issue

Badsheep commented 5 years ago

hm hm...

I don't really understand what you said but I'm glad you pointed a problem :)

peak3d commented 5 years ago

It's quite simple, there is a loop which renders GUI and video, on every VSYNC this loop should be visited and it checks if there is a new video frame to render. If this loop is too slow (misses VSYNCS, e.g. arrives only 30 times a second), Video frames could be too late and will be dropped.

Edit: I guess 23.97 on 24 Hz (Sync playback enabled) plays smooth, right?

Badsheep commented 5 years ago

Hello,

I just checked, and the loops are alright...

I tested a 24fps after the 23,976fps, and the values you found were about the 24fps.

So in the case of 23,976, it's 16ms :

10:41:36.218 T:140735637267328 DEBUG: PrepareNextRender: frameOnScreen: 343498536.815350 renderPts: 343565203.487103 nextFramePts: 343593250.000000 -> diff: -28046.512897 render: 0 forceNext: 0 10:41:36.252 T:140735637267328 DEBUG: PrepareNextRender: frameOnScreen: 343531964.464350 renderPts: 343598631.136103 nextFramePts: 343593250.000000 -> diff: 5381.136103 render: 1 forceNext: 0 10:41:36.269 T:140735637267328 DEBUG: PrepareNextRender: frameOnScreen: 343549214.378350 renderPts: 343615881.050103 nextFramePts: 343634958.000000 -> diff: -19076.949897

And in 24fps it's 41ms : (your example)

0:42:10.057 T:140735637267328 DEBUG: PrepareNextRender: frameOnScreen: 3896329.285129 renderPts: 4062669.682978 nextFramePts: 4041666.000000 -> diff: 21003.682978 render: 1 forceNext: 0 10:42:10.098 T:140735637267328 DEBUG: PrepareNextRender: frameOnScreen: 3937676.479129 renderPts: 4104016.876978 nextFramePts: 4083333.000000 -> diff: 20683.876978 render: 1 forceNext: 0 10:42:10.140 T:140735637267328 DEBUG: PrepareNextRender: frameOnScreen: 3979390.094129 renderPts: 4145730.491978 nextFramePts: 4125000.000000 -> diff: 20730.491978 render: 1 forceNext: 0

The problem doesn't come from here

Badsheep commented 5 years ago

Edit: I guess 23.97 on 24 Hz (Sync playback enabled) plays smooth, right?

no it doesn't work...

peak3d commented 5 years ago

no it doesn't work...

Is no answer :-)

10:41:36.218 ... 10:41:36.252 ...

^^ This is more than 16, for me it is NOT Ok.

Badsheep commented 5 years ago

:) you're right :)

When I checked on the log, by accident, I fund lines that were EXACTLY separated by 16ms (I swear !) Then I come back to write, went back to the log page to copy lines, and you're right, it's not 16ms everywhere ! It looks really random....

Wheras when reading the 24fps stream it's always and strictly 41ms... I haven't check all the lines but it seems like :)

Badsheep commented 5 years ago

And sorry if I wasn't clear : the 23,976 with sync playback doesn't play smooth with 24. it plays exactly the same than with 60.

EDIT mmmm wait wait wait

maybe you're right I managed to make it smooth a moment... Let me try 2 or 3 thing

Thank you very much for your help !

Badsheep commented 5 years ago

OK I'm back after a few tests :

YES you're right, when I set my screen frequency at 24fps, with auto frame rate OFF :

All that is true with local video files and Netflix add-on.

Now I set my screen frequency to 60Hz (ntsc) : The 23,976 videos of Netflix are stuttering like before, whereas they should be perfectly fluid, like the 23,976 local files and Youtube streams are.

So what creates stuttering in my config could be the 23,976 > 60Hz operation (or 25>50), but ONLY with Netflix ad-on (local videos and streaming from Youtube have no problem)

peak3d commented 5 years ago

Could be color conversion for example, but should be investigated by Mac user with same h/w as you have (widevine does not output NV12), could be that it is s/w converted / convered by shader which takes time.

Badsheep commented 5 years ago

OK thanks again for your help...

As you mentioned "color", I tried to play a bit with the images options in Kodi...

And in fact when I enable Dithering, the 23,976 of Netflix is much smoother !! (with the original configuration, auto frame rate ON, with a 60Hz hdmi output)

Strange, no ? And the other strange thing is that the rate displayed on top left seems completely false (it's written below 40, but it's really really more fluid than before - it must be very close of 60Hz I think)

The bad points :

So unfortunately it won't be a good workaround for me... But still it's interesting that enabling a option that should consume CPU makes the playback MUCH better ??

Badsheep commented 5 years ago

Could be color conversion for example, but should be investigated by Mac user with same h/w as you have (widevine does not output NV12), could be that it is s/w converted / convered by shader which takes time.

And in that case, the CPU, or the RAM, or something wouldn't be overload ?

Badsheep commented 5 years ago

I use a workaround, I did a whitelist with 1080p24 and 50Hz (and removed the 60Hz). Then overrided the 23,976 to play at 24 using the advancedsettings.xml As I mostly watch 23,976 or 24fps on Netflix, it's ok.

Still if one day anybody finds the bug, it would be cool ! I'm sure it could improve the plugin performance, not only for old iMac but for everybody...

Anyway thanks again Peak3d for your help !

Badsheep commented 5 years ago

Hello,

If it can help anybody to find a solution for this problem, I noticed that when I press "O" during the playback (to display the playback information), the video is darker (which is normal)... BUT FLUID !

Strange no ?

It changes the speed of playback, as it can be saw by displaying the debug informations.

For example in my test of 25fps video ("Blanche Gardin")

It's the same with 23,976 videos, it's basically stuttering but it's fluid when I hit "O".

Badsheep commented 5 years ago

Seems fixed with Leia 18.2 !!

Now it stutters a little bit, but I'm quite sure it's related with the venerable age of my iMac... But the problem described in the beginning of the thread is gone...

And the behavior when I hit "O" is more normal : it slows the system and stutters more.

So I think this bug was related to kodi itself and can be marked as solved.