obsproject / obs-amd-encoder

AMD Advanced Media Framework Encoder Plugin for Open Broadcaster Studio
https://obsproject.com/forum/threads/amd-advanced-media-framework-encoder-plugin-for-obs-studio.52305/
GNU General Public License v2.0
454 stars 87 forks source link

Frame Skipping while streaming causes encoder to drop ALL frames #117

Closed Xbye closed 7 years ago

Xbye commented 7 years ago

Specs: Discord Image

OBS Version: OBS 0.16.2 (64bit, windows)

Plugin Version: 09:40:38.762: [AMF Encoder] Version 1.3.3.1-1.3.0.5

AMD Driver: non-whql-win10-64bit-radeon-software-crimson-16.10.1-oct6

LOG / Video: https://www.twitch.tv/3ybx/v/98589039?t=1m5s https://gist.github.com/anonymous/b836dfe5fd0379056e7ba94a7fddcb8a

OLD

RX 480 - Quality / Balanced Preset(s)

Using the simple encoder, and using all the default parameters except adjusting profile level to manually be 4.1 .

Link : https://www.twitch.tv/3ybx/v/97548798?t=4min25s

It doesn't seem to want to recover afterwards, and bitrate just drops to ~350. I'm going to be making a separate issue for another problem. This is not the first time I've used frame skipping. All other times I've tried to use it result in the same problem.

Xaymar commented 7 years ago

https://github.com/Xaymar/OBS-AMD-Advanced-Media-Framework/wiki/Troubleshooting-Guide

Xbye commented 7 years ago

This is usually caused by the encoder not keeping up, but there is no go-to solution. You will have to try one or more of the following:

Change 'Memory Type' (Expert) to 'Host'. Change 'Compute Type' (Expert) to 'Disabled'. Change 'Surface Format' (Expert) to 'NV12' and also do this in OBSs Advanced Settings. Disable B-Picture Reference. Reduce Resolution and Framerate (you might be hitting the limits of your motherboard). Lower the Quality Preset to 'Balanced' or 'Speed' (warning, massive quality difference).

All the settings are already set, My GPU doesn't support b-picture reference so the option to disable it isn't even there. The stream is running 480 @ 60 fps, is that really too much for my motherboard?

http://www.gigabyte.com/products/product-page.aspx?pid=4488#ov

Xaymar commented 7 years ago

Finally: Report an Issue

So you actually made it down here. Darnit and I thought I could get away with less work. Well, here's what I'll need of you:

  • Full System Specifications (Motherboard, CPU, GPU, RAM, HDD, etc.) (You can generate this with the free Speccy tool)
  • Currently Installed OBS Version
  • Currently Installed Plugin Version
  • Currently installed AMD Driver (if beta/preview version, include full download name)
  • Log Files for each Video included in the Issue with Debug Tracing active
  • Full Description of the Issue

Once you have all of that, click this link and start writing your Description, include links to the log and recording and don't forget your full system specifications.

Xbye commented 7 years ago

Alright. I'll see if I can take care of that later today. Shall I re-open this issue with an edited OP or just make a new post then?

Xaymar commented 7 years ago

Just edit the op and reopen it then.

Xaymar commented 7 years ago

Bumping this issue since I changed the repository name.

Xbye commented 7 years ago

@Xaymar I have updated the original post with a log with me using frame skipping. Also tested it with Quality preset. Again, quality preset regardless of Resolution/FPS causes very noticeable input lag/unsmoothness in my games. CS:GO, CrossCode, Left4Dead 2. Though, I guess tha tissue should be discussed over at the proper issue.

Xaymar commented 7 years ago

I couldn't see any Frame Skipping happening in that log file, so it's not the encoder or the plugin. Likely means that either your GPU is faulty or your system is overloaded.

Xbye commented 7 years ago

I couldn't see any Frame Skipping happening in that log file, so it's not the encoder or the plugin. Likely means that either your GPU is faulty or your system is overloaded.

The thing is though that it only happens when I have frameskipping enabled, and it's being used for livestreaming. Works fine with recording, even with frameskipping. I wish someone else with an RX 480 could chip in on this.

Also want to add, I had a very similar experience with quicksync. I have no way to configure it outside of OBS Studio's settings so I assume it has some form of "frame-skipping"? If I used quicksync for streaming, I ran into a similar issue where the stream would just "drop frames" like the above video but not to that extreme amount of a degree. Currently using quicksync for local recording and I have zero issues with it other than the occasional unsmooth frame that I guess is from having uncapped framerate?

Xaymar commented 7 years ago

It only happens while live streaming and Frame Skipping is active? If so, then the issue isn't even the encoder or the system. The problem is then that OBS sees that it can't send a certain frame and then waits until the next identical or higher priority frame before continueing, so that the stream doesn't end up being broken.

Xbye commented 7 years ago

It only happens while live streaming and Frame Skipping is active? If so, then the issue isn't even the encoder or the system. The problem is then that OBS sees that it can't send a certain frame and then waits until the next identical or higher priority frame before continueing, so that the stream doesn't end up being broken.

Yeah. I can test it again later if you want (Recording with frame-skipping enabled, as opposed to streaming with) accurate proof. It's been a while since I have though so it's probably best that I do test it again just to make sure I'm not remembering something wrong.

so that the stream doesn't end up being broken.

It's sure doing a good job not being broken! ( ͡° ͜ʖ ͡°)

Xaymar commented 7 years ago

Try 16.11.1 with 1.4.0.0 and report back.

Xaymar commented 7 years ago

It's been 4 days, I can safely assume this is no longer happening?

Xbye commented 7 years ago

@Xaymar

It's been 4 days, I can safely assume this is no longer happening?

I can not test the new version yet until CBR is fixed. Do you want me to test the old version with it's recording + frame skipping?

Xaymar commented 7 years ago

No, I want you to test the new version. 1.4.1.1 and 1.3.3.1 are technically identical except that 1.4.1.1 does not Initialize the encoder twice. If you can't provide up to date information, I will close this issue for tracking purposes.

Xbye commented 7 years ago

@Xaymar Alright, will try then but I'll have to downgrade back afterwards since CBR is still broken in that version, at least it was last I checked(?).

I also went ahead and tested the current (old) version, using the exact same settings for recording that I would for livestreaming. (IE. CBR, bitrate, resolution, fps, ect.) 1 LOG: https://gist.github.com/anonymous/98db795d6cefc6201912cf7e3dab6593

It started doing the exact same thing, which is odd because it never did that before and I figured I remembered wrong, however...

I then changed one setting, the CBR. I set it to CQP (which I used for recordings instead) but left all the other settings the same as if I were to stream. The issue was then gone. It seems like the issue was related to either CBR or Filler Data perhaps? I then tried again recording with CBR, but had Filler Data disabled and my video card seemed to crash and restarted with OBS closing with no crash log visible.

I'll update to 1.4.1.1 shortly, but thought I'd give you this info.

Xbye commented 7 years ago

@Xaymar

LOG: https://gist.github.com/8e5d9403ca1c63ef490f7b0bbf61e7f9

Just tested the new version. Unlike the previous version, the frame dropping issue happened immediately when starting the recording whereas before it didn't happen until I had some fast motion. I will now be testing frame-skipping with VBR instead of CQP/CBR like I did with the old version in the upper post.

Xaymar commented 7 years ago

Your Frames (except the first one) are all 30 bytes big. Did you record a black screen or something?

14:22:02.351: [Plugin::GetOutput]    Trace: Packet: Type(1), PTS(   6), DTS(   4), Size(      30)
14:22:02.351: [AMFEncoderVCE]    Debug: QueryOutput(-1) End: frame pts=7 outputFrames=8
14:22:02.351: [AMFEncoderVCE]    Trace: SubmitInput() End: frame pts=8 inputFrames=9, TaskID=11
14:22:02.351: [Plugin::GetOutput]    Trace: Packet: Type(1), PTS(   7), DTS(   5), Size(      30)
14:22:02.351: [AMFEncoderVCE]    Debug: QueryOutput(-1) End: frame pts=8 outputFrames=9
14:22:02.351: [AMFEncoderVCE]    Trace: SubmitInput() End: frame pts=9 inputFrames=10, TaskID=12
14:22:02.351: [Plugin::GetOutput]    Trace: Packet: Type(1), PTS(   8), DTS(   6), Size(      30)
Xbye commented 7 years ago

@Xaymar I don't believe so.

Sorry it took me so long to reply... I kept falling culprit to the Twitch preset resetting from VBR back to CBR, heh. Anyways, after doing some testing I got the following:

3 Accidental CBR Attempts 1 VBR Attempt 1 CQP attempt

Every single CBR attempt was met with the same fate, immediately "frame skipping" like crazy and the bitrate was exceptionally low in VLC media player. Same goes for the VBR attempt. I then however switched to CQP and the issue was resolved.

LOG: https://gist.github.com/anonymous/83bae3cc0fbcb6a0b2a805a01b9609b4

I'm not 100% sure what the issue is, but I'm assuming it has to do with a target bitrate, or perhaps a target bitrate being too low as CQP works fine. I also have a somewhat similar issue back when I tried to stream with quick-sync.

Xaymar commented 7 years ago

I kept falling culprit to the Twitch preset resetting from VBR back to CBR, heh.

I've "fixed" that in the next version, presets disable things that they override. Should hopefully make that error easier to spot.

(log file links)

Both log files show that you are still on Driver 16.11.1, try upgrading to 16.11.2

Xbye commented 7 years ago

@Xaymar Upgraded to 16.11.2 after using DDU.

LOG: https://gist.github.com/08599b2047f1027c37941e8c08f3014f VIDEO: http://www.mediafire.com/file/1qll5lpdi12q6s4/%28Monday%29November+07%2C+2016+-+03%3B45PM.mkv

Issue still persists for CBR (and assuming, VBR). I also took the liberty to upload the video file to ensure you there isn't user error and I'm capturing a black screen.

Xbye commented 7 years ago

Please let me know if you need anymore testing, as I want to start streaming today and I'll need to downgrade back to the previous version for CBR.

Xaymar commented 7 years ago

There's a thread on reddit now that I use to gather more information about a similar bug. If you need to stream then downgrade to whatever worked for you.

Xaymar commented 7 years ago

@Xbye Your last log file is missing debug information, but from the looks of it only I-Frames were being encoded. Can you try the following for the next test:

Edit: MikhailAMD explained what RateControlSkipFrame does to me, so here is it simplified: It repeats the last frame if rate control can't keep up with the target settings. Looks like a dropped frame but in reality it's not being dropped - just being skipped because it can't keep the target settings.

Xbye commented 7 years ago

@Xaymar I am currently in safemode, as per your troubleshooting instructions.

However, I am unable to complete this step:

Delete the folders containing *ativce0.dat**

There is no ativce anything in here, simply other things. This was after I used DDU in safemode. Here is an image: DISCORD - DISCORD2

Regardless, these files were created on the 4th, which I am assuming when I installed 16.11.1 and they weren't getting picked up (deleted) by DDU so I'm going to delete these then try the new plugin again.

Xaymar commented 7 years ago

@Xbye The folder I had to delete started with "c030" and then a 7 or an 8.

Xbye commented 7 years ago

@Xaymar This one? - c0308528.inf_amd64_a2b44dc88890e31a It's empty, since I deleted the above .dll I showed a picture of.

EDIT: I deleted it. Took me a while since Win10 was having a fus saying I don't have permissions. Upgrading from Win7 really fucked up my permissions. Still though, it was empty and had no ativce in it, just those other DLLs I sent a picture of above.

Xaymar commented 7 years ago

Yes that one.

Xbye commented 7 years ago

Alright so, I'm going to be following through with this using CBR and trying to stream:

@Xbye Your last log file is missing debug information, but from the looks of it only I-Frames were being encoded. Can you try the following for the next test:

Set Profile Level to 4.2 Set VBV Buffer Strictness to 0% Set Enforce HRD to Enabled Set Min QP to 1 (Known bug with RX 4xx cards)

A lot of those options are really far in the "View Mode" section.

Xaymar commented 7 years ago

Min/Max QP and VBV Buffer is visible with Advanced. Enforce HRD and Profile Level is visible with Expert.

Xbye commented 7 years ago

Twitch preset is currently overriding the following:

Profile Level Minimum QP VBV Buffer Strictness

I'm going to have to disable it for this frameskipping + CBR test.

EDIT: Typed the wrong QP.

Xaymar commented 7 years ago

You're supposed to change Minimum QP, but that is also replaced by Twitch preset.

Xbye commented 7 years ago

Yes, sorry about that typed the wrong QP. Before I start the stream I took the liberty of searching through my files for ativce - DISCORD

This is a complete clean install, AMD normal uninstaller, DDU safemode, and manually deleting folders then rebooting and installing: non-whql-win10-64bit-radeon-software-crimson-16.11.2-nov4.exe

Not sure if I'm suppose to have VCE02 in there 🤔

Xaymar commented 7 years ago

There's always two vce .dats there. Not sure why or what they do, but if I saw things right those are used by the driver as the firmware for VCE.

Xbye commented 7 years ago

Wednesday - November 09th, 2016 @ 5:25 AM

Just streamed for 10 minutes doing a variety of stuff, such as staring at walls, jumping around, flicking my mouse, going into dark rooms, going to desktop, ect. To my current knowledge, everything seems to be working. Frankly the quality looks much better than the previous versions but I am noticing that even though it states 60 fps in Twitch and OBS, I can tell at some scenes it didn't maintain 60 fps. Probably normal.

VIDEO (Temporary): https://www.twitch.tv/3ybx/v/100006917 LOG: https://gist.github.com/anonymous/2225c36dc4b85d670cdd1c2bd727a197

STEPS I DID TO GET HERE: 1.) Followed this guide: Xaymar's FAQ

2.) Uninstalled AMD driver normally, through Windows 10 control panel add/remove programs.

3.) Booted into safemode. Ran DDU (Display Driver Uninstaller) to further remove anything left by AMD drivers.

4.) Manually searched in C:\Windows\System32\DriverStore\FileRepository for ATI .

5.) Did not find suggested .dll or files but found these: Discord Image inside folder c0308528.inf_amd64_a2b44dc88890e31a

6.) Deleted them, and the folder itself. Required SYSTEM permissions. May have to give yourself ownership of folder to delete properly.

7.) Rebooted back to normal desktop. Installed the latest driver: non-whql-win10-64bit-radeon-software-crimson-16.11.2-nov4.exe

8.) Used the suggested settings variables given to me by Xaymar

Set Profile Level to 4.2 Set VBV Buffer Strictness to 0% Set Enforce HRD to Enabled Set Min QP to 1 (Known bug with RX 4xx cards)

Xbye commented 7 years ago

Going to be doing another, longer test with CS:GO right now by the way. Doesn't hurt to do more tests!

Xbye commented 7 years ago

Issue not resolved: https://gist.github.com/anonymous/820195e394759a1cf1e7e9997c95adab

:( Used quality setting. Going back to balanced.

Xaymar commented 7 years ago
05:57:00.655: [Plugin::GetOutput]    Trace: Packet: Type(1), PTS(25220), DTS(25218), Size(    5566)
05:57:00.655: [AMFEncoderVCE]    Debug: QueryOutput(-1) End: frame pts=25221 outputFrames=25222
05:57:00.655: [AMFEncoderVCE]    Trace: SubmitInput() End: frame pts=25224 inputFrames=25225, TaskID=25227
05:57:00.655: [Plugin::GetOutput]    Trace: Packet: Type(1), PTS(25221), DTS(25219), Size(    5598)
05:57:00.655: [AMFEncoderVCE]    Debug: QueryOutput(-1) End: frame pts=25222 outputFrames=25223
05:57:00.655: [AMFEncoderVCE]    Trace: SubmitInput() End: frame pts=25225 inputFrames=25226, TaskID=25228
05:57:00.655: [Plugin::GetOutput]    Trace: Packet: Type(1), PTS(25222), DTS(25220), Size(    5512)
05:57:00.655: [AMFEncoderVCE]    Debug: QueryOutput(-1) End: frame pts=25223 outputFrames=25224
05:57:00.655: [AMFEncoderVCE]    Trace: SubmitInput() End: frame pts=25226 inputFrames=25227, TaskID=25229
05:57:00.655: [Plugin::GetOutput]    Trace: Packet: Type(1), PTS(25223), DTS(25221), Size(    5528)
05:57:00.655: [AMFEncoderVCE]    Debug: QueryOutput(-1) End: frame pts=25224 outputFrames=25225
05:57:00.655: [AMFEncoderVCE]    Trace: SubmitInput() End: frame pts=25227 inputFrames=25228, TaskID=25230
05:57:00.755: [Plugin::GetOutput]    Trace: Packet: Type(1), PTS(25224), DTS(25222), Size(      37)
05:57:00.755: [AMFEncoderVCE]    Debug: QueryOutput(-1) End: frame pts=25225 outputFrames=25226
05:57:00.755: [AMFEncoderVCE]    Trace: SubmitInput() End: frame pts=25228 inputFrames=25229, TaskID=25231
05:57:00.755: [Plugin::GetOutput]    Trace: Packet: Type(1), PTS(25225), DTS(25223), Size(      37)
05:57:00.755: [AMFEncoderVCE]    Debug: QueryOutput(-1) End: frame pts=25226 outputFrames=25227
05:57:00.755: [AMFEncoderVCE]    Trace: SubmitInput() End: frame pts=25229 inputFrames=25230, TaskID=25232
05:57:00.755: [Plugin::GetOutput]    Trace: Packet: Type(1), PTS(25226), DTS(25224), Size(      37)
05:57:00.755: [AMFEncoderVCE]    Debug: QueryOutput(-1) End: frame pts=25227 outputFrames=25228
05:57:00.755: [AMFEncoderVCE]    Trace: SubmitInput() End: frame pts=25230 inputFrames=25231, TaskID=25233
05:57:00.755: [Plugin::GetOutput]    Trace: Packet: Type(1), PTS(25227), DTS(25225), Size(      37)
05:57:00.755: [AMFEncoderVCE]    Debug: QueryOutput(-1) End: frame pts=25228 outputFrames=25229
05:57:00.755: [AMFEncoderVCE]    Trace: SubmitInput() End: frame pts=25231 inputFrames=25232, TaskID=25234
05:57:00.755: [Plugin::GetOutput]    Trace: Packet: Type(1), PTS(25228), DTS(25226), Size(      37)
05:57:00.755: [AMFEncoderVCE]    Debug: QueryOutput(-1) End: frame pts=25229 outputFrames=25230
05:57:00.755: [AMFEncoderVCE]    Trace: SubmitInput() End: frame pts=25232 inputFrames=25233, TaskID=25235
05:57:00.755: [Plugin::GetOutput]    Trace: Packet: Type(1), PTS(25229), DTS(25227), Size(      37)

Seems that for some reason your card stops encoding properly after 420,4 seconds. Unsure why, I never had this happen to me before.

Xbye commented 7 years ago

420BlazeIT!

Okay so, I am doing more testing. I switched from Quality to Balanced. No issues so far.

Xbye commented 7 years ago

@Xaymar I just finished a 1hr 27min livestream using the Balanced quality preset. No issues whatsoever...

Assumption, the 4xx cards are terrible and can't handle the Quality quality preset regardless of resolution.

Xaymar commented 7 years ago

Well they are in the low to mid-end current generation segment and there are quite a few driver issues that need to be fixed. With future driver upgrades you may see an improvement in how well it can handle Quality.

Though this behaviour doesn't look like a hardware restriction to me, more like something is messing up somewhere and causes that encoding session to break. If you could get me a memory dump, log file and raw video file of when it happens, that would be great. For the raw video file, just set the recording to use the stream encoder - obs duplicates the packets then and stores them to disk.

Xbye commented 7 years ago

@Xaymar Do me a favor and explain how to do the memory dump again? Also, you want me to use Quality with frame-skipping again to try and reproduce the bug, correct?

Xaymar commented 7 years ago

Do me a favor and explain how to do the memory dump again?

Open Task Manager, right click on obs64.exe (or obs32.exe) and click "create dump file"

Also, you want me to use Quality with frame-skipping again to try and reproduce the bug, correct?

Yup.

Xbye commented 7 years ago

You released a new plugin and a new driver version was released today. Do you want me to use everything I currently have, or try the newer versions of both doing clean installs of each? Just want to make sure for when I have some time.

Xaymar commented 7 years ago

Normal uninstall + update of the driver should work if you did the full clean uninstall routine once. Unsure if this was fixed in this driver upgrade, but you can test if you want to.

Xbye commented 7 years ago

Arrrrrgh, great! Time to uninstall stuff then reinstall everything then overclock everything again!

Xbye commented 7 years ago

Just did a clean install and just checked my system32 before rebooting. Those same 4 files are still there.

Xbye commented 7 years ago

@Xaymar OBS LOG: https://gist.github.com/anonymous/e308e8058992efba546d8ff46bbbeb54 TwitchTV Video(Temporary): https://www.twitch.tv/3ybx/v/100092531

Minidump + OBS Log + HDD Video: https://www.dropbox.com/s/xyaw4313nzapwh5/Xbye%20Nov%209th%20Frame%20Skipping%20Quality.zip?dl=0 Since MediaFire decided to a dick and fail to upload, I am now trying Dropbox.

Xbye commented 7 years ago

@Xaymar I just had the issue happened when trying to play The Culling, which doesn't have proper VSync + FPS max controls. I am using the Balanced preset.

https://gist.github.com/2d94a73dba81f2389c3aaca46a0f55ec

trillerr commented 7 years ago

I believe I am running into a similar issue (though while recording). Though for me it consistently occurs right around 3 seconds in. My first run was with a high bitrate 24Mb. After that I dropped down to 5000 and tried tweaking initial buffer fullness. I ran DDU and made sure to clear any c030 files before updating to 16.11.3 and the latest OBS/plugin release.

2016-11-09 19-08-26.txt

Additionally I saw that you added full range color support. I have switched over from partial but the color range in the logs remains the same. I have tried switching back to partial and haven't still experience the drop after three seconds.

https://cloud.githubusercontent.com/assets/780584/20161192/540d8d84-a6b2-11e6-815c-bb2280a9a81c.PNG