CocoaSplit icon indicating copy to clipboard operation
CocoaSplit copied to clipboard

Stream FPS doesn't match preview's

Open LordHDL opened this issue 11 years ago • 15 comments

I set it to 60 fps. While streaming I can see very smooth video in both CamTwist and CocoaSplit's preview, but the resulting stream fluctuates between 55-60. My stream is stable, so pending output is always at 1 and dropped frames always at 0.

LordHDL avatar Dec 01 '13 16:12 LordHDL

Are you seeing a mismatch between fps in/fps out or are they both showing the same less-than-60fps?

zakk4223 avatar Dec 10 '13 15:12 zakk4223

They both show around 59.9 constantly. Only the decimal fluctuates so it might sometimes say 59.7 for instance. It never shows 58 or lower, only the stream itself is affected.

LordHDL avatar Dec 10 '13 15:12 LordHDL

If you stream and analyze it with this: http://r-1.ch/analyze-twitch-vod.php what does it look like?

zakk4223 avatar Dec 13 '13 10:12 zakk4223

stream analysis

I know stream technology is imperfect. Currently there is no 60 fps stream I've watched that is perfectly smooth, but back when I used different stream software I got a consistently better frame rate than what I'm getting now (basically as good as CocoaSplit's preview) using the same settings and CPU.

LordHDL avatar Dec 13 '13 13:12 LordHDL

So I decided to change some settings for testing, and with these new settings I did a live test.

live analysis

Huge improvement in frame variance. My guess is that changing from VBR to CBR did it, although in the past I used VBR with other software and didn't have this issue, which leads me to believe CocoaSplit is doing something funky with VBR.

LordHDL avatar Dec 13 '13 19:12 LordHDL

The fact that the vod you analyzed produced no values for the x264-settings is also a bit odd, it certainly produced values for the vods I pointed it at. I dunno if that's some twitch quirk or an indication there was something odd with the encoder config though.

zakk4223 avatar Dec 14 '13 21:12 zakk4223

Yeah I found that weird too. I tried other broadcasters and browsers too to make sure and the same happened. The information seemed complete when I analyzed live streams, but for some reason now even that doesn't work. Is that analysis tool official or made by a 3rd-party?

LordHDL avatar Dec 14 '13 21:12 LordHDL

It's a third party, and I bet the Twitch changes yesterday broke it

zakk4223 avatar Dec 14 '13 21:12 zakk4223

I streamed earlier today with the March 6 build and this issue is still present. I did a ton of testing beforehand using local recordings and the local videos don't exhibit the FPS drop. The Twitch analysis tool was updated a while back so I used it today.

stream analysis

Here's what this actually looks like on Twitch: http://www.twitch.tv/ihdl/c/3838233

As you can see it's hardly 60 fps smooth, yet it appears smooth in the preview, local recordings, and by extension CamTwist.

LordHDL avatar Mar 06 '14 20:03 LordHDL

So apparently the preview option is contributing to this. I did some more testing and I consistently get those dips in frame rate you see in the image above when I have preview on. Turning it off resulted in a smoother output and a perfectly horizontal blue bar in the analysis. However, even doing this the live output still doesn't match the smoothness of the preview. It's just alleviated some.

This affects other frame rates too, like 30 fps, so best bet is to just leave preview off while live. There is still something else at work, though.

LordHDL avatar Apr 17 '14 14:04 LordHDL

Out of curiosity I did the analysis on your channel while you happened to be live. Here's what it gave me, followed by a test on my own channel a bit earlier:

zakklol

ihdl

LordHDL avatar Apr 17 '14 15:04 LordHDL

Hmm, I put in some debugging output locally and I think I know what is going on here:

If the entire 'capture frame->preview frame->encode frame' sequence takes longer than one frame (so 16ms at 60fps) the next frame is dropped. Since two threads can't update an OpenGL context simultaneously, there's a lock in the preview rendering code to prevent that from happening. So occasionally the main UI thread will grab the context and this then causes the CocoaSplit thread to block long enough that it will drop/delay a frame. You can make it worse if you grab the CocoaSplit window and move it around a lot, since it causes more UI redraws.

It was done this way because initially I tried to render the preview out to the screen as quickly as possible, because I was using it as a way to get fullscreen preview of BlackMagic devices. I've pretty much abandoned that use so I'm pretty sure I can rewrite this in a way that won't block the capture thread sometimes, but at a cost of increasing the latency of the preview sometimes.

Disabling preview should make things better, as you've noted.

I'm still not sure about the preview/live smoothness thing. I need to come up with a way to reproduce that locally. It may have something to do with the frame capture timing being slightly off from the 'native' framerate.

zakk4223 avatar Apr 18 '14 19:04 zakk4223

Did a 60 fps stream recently and this issue is still present. Preview and local recordings are perfectly smooth, but with the same encoding settings a live stream performs at around 40-48 fps (the log says 60, though). Tested with the current stable build and not experimental CoreImage one.

LordHDL avatar Sep 01 '14 14:09 LordHDL

Are you watching the stream on a mac? I just noticed on a 2012 rMBP with safari twitch's video stats show 40-ish FPS meanwhile windows running on a 2010 mbp shows 60fps....and it's because on the mac the flash player is dropping frames constantly.

Does it look any different if you use live streamer (http://livestreamer.tanuki.se/en/latest/) to watch it via VLC?

zakk4223 avatar Sep 02 '14 05:09 zakk4223

I am, however my experience is still varied so I don't think flash player is the only factor. Some observations:

  • I can watch other streamers on Twitch/Hitbox at 60 fps and see full smoothness in Safari on OS X that I can't achieve with CocoaSplit (except in preview/local recording).
  • I have some old Twitch videos (like the one linked above) that are almost full 60 fps with occasional drops (around 55 fps) and can see this reflected in iStat Menus GPU information.
  • I have a Hitbox video that appears to run at 40 fps in Safari and Chrome, but almost 60 when viewed with Livestreamer. A friend of mine (uses Windows) claims it did not look smooth while live but the archive itself looks smooth for him in browser even though it doesn't for me.

I certainly don't think flash is helping but there's clearly something else going on as this doesn't seem to affect users of OBS/XSplit.

LordHDL avatar Sep 02 '14 15:09 LordHDL