ShareX / ShareX

ShareX is a free and open source program that lets you capture or record any area of your screen and share it with a single press of a key. It also allows uploading images, text or other types of files to many supported destinations you can choose from.
https://getsharex.com
GNU General Public License v3.0
28.11k stars 3.1k forks source link

Low framerate when recording screen, even though low cpu usage #1816

Closed mzso closed 5 years ago

mzso commented 7 years ago

Hi!

I use this command line:

-y -rtbufsize 300M -f gdigrab -framerate 60 -offset_x $area_x$ -offset_y $area_y$ -video_size $area_width$x$area_height$ -draw_mouse $cursor$ -i desktop -an -pix_fmt yuvj444p -vf scale=out_color_matrix=bt709 -c:v libx264 -r 60 -crf 22 -preset fast -tune zerolatency -x264opts colorprim=bt709:transfer=bt709:colormatrix=bt709 "$output$"

But when I watch the result the framerate is poor, even though the cpu suage is really high. Anything wrong with it?

I made screencast of it: 2016-08-24_12-26-52.zip

XCanG commented 7 years ago

@mzso do you try to run it in console? (in settings) I try your command and get 60 fps: http://hnng.moe/f/GRW

mzso commented 7 years ago

What do you mean "console"? I use it in sharex. With the custom command.

campbeb commented 7 years ago

@mzso I believe he means using the Test with CMD button to see what results you get.

sharex_2016-08-24_21-15-06

mzso commented 7 years ago

I get 8.8fps at best, and cpu usage around 25%... Is ffmpeg forced to run in single thread mode for some reason? for what reason could be the CPU usage be capped at such low value?

mzso commented 7 years ago

Okay this is incomprehensible. I only get 10 fps even if I change the preset to ultrafast... And similar cpu usage

XCanG commented 7 years ago

@mzso yeah, I mean this testing, but how you have so low FPS? What is you PC specs? Also try screen-capture-recorder instread of GDI. If it take a change in your FPS, may be problem here. Also I think problem may be in Aero if you on Windows 7, it very slow down capturing screen.

And again I make a test, see video https://my.mixtape.moe/cacoex.webm it working good for me.

mzso commented 7 years ago

I tried screen capture recorder. It didn't make a difference, when it worked. I have an E5450, but it's not even half utilized when I record...

XenHat commented 6 years ago

Using the same command as the OP, I get a "Test CMD" result of 62 fps, but a "real" video capture of 2-10 fps, recording an OpenGL application.

My specs:

CPU: Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz (3997.67 MHz)
RAM: 32713 MB
O/S: Microsoft Windows 10 64-bit (Build 16257)
GPU: NVIDIA Corporation GeForce GTX 970/PCIe/SSE2

OpenGL Version: 4.5.0 

NVIDIA 382.05

Sample Video: 3xK6sXG9.zip

XCanG commented 6 years ago

@XenHat as you have GTX 970 try to record with parameters: Video Codec: H.264 NVENC (.mp4) Then on tab NVENC use your bitrate, 3000 is ok, you may use slow (high quality 2 passes) method also but if default record normally. For audio I suggest AAC.

So ShareX will show something like that in output:

-y -rtbufsize 100M -f dshow -framerate 30 -i video="screen-capture-recorder":audio="virtual-audio-capturer" -c:v h264_nvenc -r 30 -preset slow -b:v 3000k -pix_fmt yuv420p -c:a aac -strict -2 -ac 2 -b:a 128k "output.mp4"

Source depend on you, I use virtual devices.

loicbisiere commented 6 years ago

Same problem for me. If I set mic recording to none, there is no problem. I suspect it's a sound recording synchronisation with the video that limit the video recording framerate.

mzso commented 6 years ago

@loicbisiere commented on 2017. nov. 8. 17:55 CET:

Same problem for me. If I set mic recording to none, there is no problem. I suspect it's a sound recording synchronisation with the video that limit the video recording framerate.

Good to know. Quite sure it's an ffmpeg issue though since I experienced before with plain ffmpeg. Maybe you could report it to them.

dcalag commented 6 years ago

I was having the same issue and after doing some experimentation with the ffmpegs params I found that for me removing the '-tune zerolatency' param solves the problem. Also, I had to use the 'super fast', 'very fast' or slower preset. The video still had low fps with the 'ultra-fast' preset.

nicolasparada commented 6 years ago

@dcalag Thanks, removing the zerolatency tune improved the fps 😊

mzso commented 6 years ago

@dcalag commented on 2017. dec. 11. 20:18 CET:

I was having the same issue and after doing some experimentation with the ffmpegs params I found that for me removing the '-tune zerolatency' param solves the problem. Also, I had to use the 'super fast', 'very fast' or slower preset. The video still had low fps with the 'ultra-fast' preset.

Or maybe just improves it? It's not just libx264 that's affected. I got framedrops even with -vcodec rawvideo which doesn't compress the video at all. (I recorded to an SSD so drive speed isn't an issue.)

gridphp commented 6 years ago

In my case "-rtbufsize 300M" seems to be the culprit. I removed it and it work smooth with defaults.

Jaex commented 6 years ago

Are you sure it is not coincidence. It should be unlikely for it to get better when rtbufsize is removed.

XenHat commented 6 years ago

Seems like I completely forgot to reply to this. I just tested various things, and while the Test with CMD function seems to "produce" 60 fps video, the actual recording in many, many circumstances seems to suffer from severe stutter and low FPS issues.

I also tried @XCanG 's advice to use NVENC, so I used the following parameters -y -rtbufsize 100M -f dshow -framerate 60 -i video="screen-capture-recorder" -vcodec rawvideo -c:v h264_nvenc -r 60 -preset losslesshp -b:v 5000k -pix_fmt yuv420p "output.mp4"

I can't say it helped achieve 60 fps as well as I hoped. =( I can't send the video due to size (180MB zipped)..

mzso commented 6 years ago

Since ffmpeg is so bugged, I wonder if something else could be used for screen recording? Mencoder? MPV?

XenHat commented 6 years ago

ffmpeg works fine in other well known projects, such as OBS Studio.

mzso commented 6 years ago

@XenHat commented on 2018. febr. 25. 19:10 CET:

ffmpeg works fine in other well known projects, such as OBS Studio.

Well, for screen recording it has horrible issues, as evidenced by this conversation here.

RealDavidoff commented 5 years ago

I have the same problem with sharex: it records choppy like hell, despite that I tried all parameters you posted above, except for this which I can't find where to set it: "with the ffmpegs params I found that for me removing the '-tune zerolatency' param solves the problem"

The odd thing is, I never noticed it until today, so it cannot have been choppy recording before, I would have noticed. But my system had no change, and I even rebooted it to see if sharex performs better after fresh reboot, but it does not unfortunately.

Any help much appreciated! Thx

dcalag commented 5 years ago

RealDavidoff: to remove -tune zerolatency go to 'Task settings - Capture/Screen recorder - Screen recording options button' and then click on 'Uso custom commands' at the bottom and edit the commands to remove the '-tune zerolatency' part.

RealDavidoff commented 5 years ago

Oh that was easy, thank you so much. Odd is, now today I recorded a bit from youtube, and with my change from yesterday (sound off) it was fine, like the other poster said. However, I sometimes really need sound with footage, so I am glad I can now test without that latency thing and WITH sound. That aside, I find sharex GREAT, it is so powerful, almost scary. I use screen recording a lot and before depended on Camstudio, which in comparison is weaker than weak.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

mzso commented 5 years ago

What's the point in this stupid stale bot? It certainly didn't solve the issue. Only hid it.

AntumDeluge commented 5 years ago

I am having a similar issue with FFmpeg on both a Windows system (using gdigrab) & a Linux system (using x11grab). The problem occurs with I try to capture the entire desktop (1920x1080 on Windows system, 1600x900 on Linux).

When trying to capture at 60fps, I only get around 24 or 25. I haven't solved the problem, but came across something that could be hint... maybe? By adding the -vsync 1 option to the end of the command line, FFmpeg reports the correct framerate. Checkout the output video with MediaInfo confirms a constant framerate of 60. However, playing the video, it appears choppy. This is because it is duplicating frames to produce the resulting 60fps. It uses around 40% of my CPU. It may be worth noting that when the -vsync 1 option is omitted, MediaInfo reports that the video uses a variable framerate.

Not sure if this will help anything, just though I would mention it.

My FFmpeg command (Linux):

ffmpeg -y -hide_banner -rtbufsize 1500M -probesize 100M -f x11grab -framerate 60 -s 1600x900 -i :0.0 -c:v mpeg4 -vtag xvid -qscale:v 0 -vsync 1 testcapture/out.mkv
mzso commented 5 years ago

I think the biggest issue here is with gdigrab. I changed to Screen Capture Recorder and the videos turned out fine. I wouldn't hold my breath about the ffmpeg people fixing this, since it's bugged for ages. I could even record fullscreen without framedrops using the ffv1 codec.

AntumDeluge commented 5 years ago

I think I had the same result with Screen Capture Recorder. But I will try it again.

I also used Captura, which uses FFmpeg as well, which worked fine.

mzso commented 5 years ago

@AntumDeluge commented on 2019. márc. 11. 00:12 CET:

I think I had the same result with Screen Capture Recorder. But I will try it again.

Perhaps you have other issues as well? It works rather fine with latest Sharex the the SCR that it downloads/installs when you click the button in the config window.

I also used Captura, which uses FFmpeg as well, which worked fine.

That would be weird because I had the same issues with using ffmpeg by itself, from command line.

mzso commented 5 years ago

@AntumDeluge commented on 2019. márc. 11. 00:12 CET:

I think I had the same result with Screen Capture Recorder. But I will try it again.

I also used Captura, which uses FFmpeg as well, which worked fine.

Okay. I maintain that the biggest issue was gdigrab, but with SCR it still sucks. There are stutters, audio crackle and such (as such in the video as well of course) in the app (epsxe) I'm recording. Nothing fixes this completely but not using sharex/ffmpeg. In contrast MSI afterburner has no effect whatsoever. I think the ShareX dev should consider some other backend for screen recording. FFMPEG is hopeless. (It also consistently butchers lossless full-range video. BT primaries are wrong or it becomes limited range. You need dig up various eclectic settings for different codecs to encode the recorded videos properly.)

XCanG commented 5 years ago

If you have issues with performance, then try to use Hardware Acceleration. More info here: https://trac.ffmpeg.org/wiki/HWAccelIntro

Knufje commented 4 years ago

I had the same problem to by using screen recording with an hotkey which started a custom screen recording, which I then applied to the entire screen. But when I started recording using the screen recording button in the application it self and using just the region of a game window which gave me a much better fps. (Not really a solution I know)

ArunEdathadan commented 4 years ago

My PC Spec is i5, 8GB (400GB SSD and 1TB HDD) Files are written to HDD though. The recording is too slow (Frame Rate).

Sample video https://www.youtube.com/watch?v=yqoHjZqVyX0&feature=youtu.be

danass commented 4 years ago

i have the same issue. Ive been tweeking all aroundi get the same results. i have gtx 1650 ss1to i7 10th gen ..

rdp commented 3 years ago

What does afterburner use?

ze0ss commented 3 years ago

This is still an issue for many, including me, shame it's been over 5 years, and no solution. I used the Screen Recorder Capture to get the audio as well, for which ShareX had to download and install something, otherwise the default one could not record the in-game audio. My game is flawless at around 75 fps, but the moment I start screen recording using Shift+PrntScrn, the Fps drops to less than 25 wtf. Help asap.

mzso commented 3 years ago

@ze0ss commented on 2021. ápr. 21. 15:55 CEST:

This is still an issue for many, including me, shame it's been over 5 years, and no solution.
I used the Screen Recorder Capture to get the audio as well, for which ShareX had to download and install something, otherwise the default one could not record the in-game audio.
My game is flawless at around 75 fps, but the moment I start screen recording using Shift+PrntScrn, the Fps drops to less than 25 wtf.
Help asap.

Your problem is not the same, at least mostly not. It's about dropping frames when there's nothing graphic resource hungry is running, without real justifiable cause. But it's an ffmpeg bug. And if I remember correctly it only happens when audio is recorded as well. So someone hypothesized some synchronization issue.

But your main problem is sharex is a screen recorder and not a game recorder. If I understand correctly it records whatever's shown on screen or part of the screen, which is not very efficient.

Meanwhile game recorders hook into Directx/Vulkan and get an image from there with less disruption to the program. So you really should be trying MSI afterburner. For which I recommend the UT-Video codec (full range RGB, without subsampling) for minimal impact on game performance (You'll need to record on a different HDD/SSD than where the game is, preferably a good one). And then re-encode it into whatever format is best for your purposes.

XCanG commented 3 years ago

This is still an issue for many, including me, shame it's been over 5 years, and no solution. I used the Screen Recorder Capture to get the audio as well, for which ShareX had to download and install something, otherwise the default one could not record the in-game audio. My game is flawless at around 75 fps, but the moment I start screen recording using Shift+PrntScrn, the Fps drops to less than 25 wtf. Help asap.

I can give you better advice, but it depend on your overall performance. So if you record in 60 fps and your game is ~75, then limit framerate for your game (or turn on vsync), then start recording. By doing that you will have some free resources to use.

Also what is recording settings you using? You may have unoptimal solution.

Alternatively just record on CPU.

Neoony commented 3 years ago

maybe try downloading newer/different version of ffmpeg?

ShareX does not exactly downloads the newest ffmpeg

e.g. https://www.gyan.dev/ffmpeg/builds/

you can replace the Documents\ShareX\Tools\ffmpeg.exe

but anyways I would never recommend ShareX for recording games Just use OBS its most likely gonna be better performance

Even gifs I record, I first record with OBS and then play the video in player and record gif (but mainly because of scaling the player window to reduce gif size easily)

ze0ss commented 3 years ago

Here's my settings @XCanG

image

ze0ss commented 3 years ago

but anyways I would never recommend ShareX for recording games

why not?

Just use OBS

ok, but in sharex, I only have to press Shift+prntscrn for starting or stopping the recording, in obs we need the whole obs window for controlling the recording.

@Neoony

mzso commented 3 years ago

@Neoony commented on 2021. ápr. 22. 01:11 CEST:

Even gifs I record, I first record with OBS and then play the video in player and record gif (but mainly because of scaling the player window to reduce gif size easily)

That's rather silly. You can just transcode video to animated GIF (also APNG). Via ffmpeg for example.

Neoony commented 3 years ago

why not?

Just use OBS

ok, but in sharex, I only have to press Shift+prntscrn for starting or stopping the recording, in obs we need the whole obs window for controlling the recording.

@Neoony

Like I said, OBS is most likely much more optimized for recording games. Not using ffmpeg ShareX is rather an office tool.

Of course there are hotkeys in OBS You dont need the OBS window at all

And you could probably set up automatic uploading from some folder over sharex

That's rather silly. You can just transcode video to animated GIF (also APNG). Via ffmpeg for example.

I usually record long videos of a match/round. Then I only want to clip gif of some small part of the video. Works perfect and is super easy and fast to do for what I need. Last time I tried converting video to gif over sharex, it was all bugged. And like I said, this makes it easy to scale resolution up or down to make shorter gif better quality (resolution), or longer gif worse or record only the parts I want and so on

Example: https://www.youtube.com/watch?v=oBedUnZiTHo (was still using radeon relive)

I dont mind the possible quality loss of recording gif from video instead of from game directly or converting...its just a gif anyways - being able to scale the window is exactly what I need for recording gifs and staying under 200mb for imgur

never actually heard about APNG, will check thx

Neoony commented 3 years ago

oh well and the ShareX video converter converts my 88MB 39sec mp4 into couple GB GIF or APNG (4.27GB APNG !!!) not sure if thats something in my settings but I did not use any custom arguments (lowest quality/size)

Is video converter supposed to be using settiings from "Task settings - Screen recorder - Screen recording options"? Otherwise I cant explain the absolutely huge size

The gif also does not really work

mzso commented 3 years ago

@Neoony commented on 2021. ápr. 22. 16:24 CEST:

oh well and the ShareX video converter converts my 88MB 39sec mp4 into couple GB GIF or APNG (4.27GB APNG !!!)
not sure if thats something in my settings but I did not use any custom arguments (lowest quality/size)

Is video converter supposed to be using settiings from "Task settings - Screen recorder - Screen recording options"?
Otherwise I cant explain the absolutely huge size

The gif also does not really work

Apng/gif are lossless formats, they're not meant for long, high resolution videos.

XCanG commented 3 years ago

@Neoony APNG is like a patch for PNG, not really good solution, but have advantages: 24bit color and transparency so you may need to optimize APNG later (it use raw frames as default and you need to replace them to difference only)

A new and better alternative would be WEBP (via libwebp binaries or ffmpeg).

@ze0ss settings look good, it more like you don't have enough performance to play + record then.

If you have NVIDIA video card, there is internal solution via Nvidia Geforce Experience, called Nvidia Share (previously known as Shadowplay) https://www.nvidia.com/en-us/geforce/geforce-experience/shadowplay/

OBS is also suitable as mentioned above.

Also about ffmpeg, if you tweak it settings, you can use GPU to record, check this page https://trac.ffmpeg.org/wiki/Capture/Desktop As you can see Windows settings pretty much reflect ShareX settings, BUT there is Hardware Acceleration section which show example how to record on your GPU, so you may edit ShareX command manually and use that settings instead.

And there is a bit of settings in ShareX as well, just try this recorders according to your graphic card brand NVIDIA / AMD from link above there was table for supported codecs on different video cards image

Also do note that HEVC is x265, it require more power to encode due it's heavy algorithms, however it have better quality and file size. But this not for your case and that not for ShareX anyway. It better to use only for offline non-realtime rendering. And if you upload that file on web, such as YouTube it will be converted in x264 anyway as x265/hevc have less support.

ze0ss commented 3 years ago

@XCanG I've started using obs thanks for that. I don't have any frame drops anymore whatsoever.

lynrayy commented 2 years ago

Any solution?

lynrayy commented 2 years ago

i set 2000m buffer but it keep saying [dshow @ 000001b7935feb80] real-time buffer [screen-capture-recorder] [video input] too full or near too full (87% of size: 2000000000 [rtbufsize parameter])! frame dropped!

mzso commented 2 years ago

@lynrayy commented on 2021. szept. 2. 23:10 CEST:

Any solution?

Never found one. It seems like you need to use something else to capture full screen video+audio.