dec05eba/gpu-screen-recorder-issues

[BUG] Record in VFR?

Closed this issue · 24 comments

Describe the bug
This probably isn't a bug, but either just me misunderstanding something, or asking for something that isn't supported.
I am recording a game that I will not be able to run at fullspeed. The gameplay footage will obviously then vary heavily in framerate throughout the recording. I wanted to record the video in VFR so that there are no duplicate frames. While gpu-screen-recorder supports vfr for recording, it still makes you choose a constant framerate via -f. As is, I need to re-encode after recording via ffmpeg -i video.mkv -vf mpdecimate -vsync vfr output.mkv to achieve what I want. Is it possible to record footage natively in VFR?

To Reproduce
Attempt to record any video; -f is required.

Desktop (please complete the following information):

The framerate that you set with -f in vfr mode is the max framerate allowed. If your recording fps drops below that then it will stay below that in those times without trying to duplicate the frames (unlike in cfr that will try to duplicate frames to match -f). So it should already work like you expect without having to re-encode the video. What happens right now if you dont re-encode with ffmpeg?
Note that some frames may be duplicate anyways not because gpu screen recorder is duplicating them but because whatever you are recording hasn't updated the frame between the time gpu screen recorder records the next frame.

I clearified the behavior a bit now when you run gpu-screen-recorder --help

If I don't re-encode with ffmpeg, it's at 60 FPS regardless of game framerate. Ultimately, in that case, I guess the game itself probably updates the display every 60 frames or something, even if it's clearly running below that.

oh then it's a different feature you want. You want recording to match the game fps? that's not the expected behavior and meaning of vfr in gpu screen recorder.
Also you said this is the case with the flatpak version but is that really true? there is actually a difference in the flatpak version and when you install gpu screen recorder from source. If you use the flatpak version it will match recording to the games fps because thats how amd driver works by default. When you install gpu screen recorder from source it will allow it to run without such fps limit but this method doesn't work in flatpak so its not done there.

Ahhh, gotcha. Yeah, that's what I was requesting.
Just for confirmation:
Recording (via ./gpu-screen-recorder -w 174063619 -a "$(pactl get-default-sink).monitor" -o m.mkv -fm vfr -f 60)

m.mp4

Reencoding via ffmpeg -i m.mkv -vf mpdecimate -vsync vfr output.mkv

output.mp4

Oh ok I see, so the game is limited in performance by the cpu? but yeah this functionality is not supported right now. I will consider adding it sometime in the future.

No, the game is limited in performance by the GPU. The CPU isn't anywhere close to being maxed on any thread. Anyways, if recording matching game FPS isn't supported, understandable.

Also, where did I say this was the case with the flatpak version? I stated in the initial post that this was tested from source, not flatpak. I apologize if I've caused any confusion; please let me know if there's anything that needs clarification.

Oh ok I misunderstood. But yes, with the flatpak version it should behave as you expected here as a side effect of how the amd driver works. Try it and see if it does.

Oh, huh, gotcha, I'll try it. If possible, is there any way for me to get identical functionality when building from source? Whether that be by different compile options, environment settings when building, etc.

sudo setcap -r $(which gpu-screen-recorder) should do that

Had to change the command to sudo setcap -r gpu-screen-recorder since this is just a binary I built.

Failed to set capabilities on file `gpu-screen-recorder' (No data available) The value of the capability argument is not permitted for a file. Or the file is not a regular (non-symlink) file
Do I need to make install for this to work? Or is this something that needs to be done during building?

Had to change the command to sudo setcap -r gpu-screen-recorder since this is just a binary I built.

i dont know how you installed it but sure, as long as getcap gpu-screen-recorder doesn't say cap_sys_nice=ep then it should work

Oh, right- I had to build via meson, I think the install script might've had issues? I don't remember why I had to build via meson, sorry.

Anyways, the issue is that trying to setcap gives me the error I posted in that message. I assume it's something to do with how I built it?

That error is a bug in the old linux mint version of setcap, it means that it had no effect since it didn't do anything (since you likely didn't install gpu-screen-recorder and only built it instead). Try running getcap gpu-screen-recorder to see what it says.

getcap gpu-screen-recorder doesn't produce any output.

ok then that setcap command is not needed. But hmm, I guess the thing I mentioned wont work for you so for now you will have to re-encode the video. But also the video framerate does actually drop below 60 in the video you posted, it drops down to 25 at one point but it doesn't match the games fps exactly yeah.
I forgot to ask. What is the exact reason you want to do this? is it to reduce file size when producing duplicate frames is unnecessary?

Recording with the flatpak version also doesn't match game FPS.

flatpak.mp4

Anyways, if it's just unsupported, fair enough. If possible would be a nice feature to have in future versions.

As for why I want to do this, I want to be able to step frame by frame through my recordings, as it's useful sometimes, and thus I like to match the game fps.

Additionally, sometimes I want to analyze performance in post.

btw, what is the exact command you use to record the game with? or if you use the gtk application what option do you use? do you record the monitor or the game window only?

./gpu-screen-recorder -w 174063619 -a "$(pactl get-default-sink).monitor" -o m.mkv -fm vfr -f 60

@HeroponRikiBestest I added a new option -fm content, can you try it? it currently only works with window capture (the way you are capturing right now) and it should match the recording fps to the game fps (when the window content updates). It requires -f option as well, but it's purely the max video fps (some games run at 1000-2000 fps in loading screens, dont want to record video at such fps lol).
Also this time make sure to install gpu-screen-recorder instead of only building it (after running the meson build command run ninja -C build install).

Awesome, works great as far as I can tell! Thank you so much for adding this, works exactly like I was hoping.

m.mkv.zip

As for your latter note, afaik I can't meson install because there are some other issues with my meson setup that I still never figured out.

Also, curious; will support eventually be added for other options besides window capture? If not, understandable, was just wondering.

Monitor capture on x11 yes. It's not possible on wayland yet, but maybe it will be when pipewire support is added.