[Recording] Lossless audio with FFMPEG-VAAPI ?

az2020

New Member
I saw this thread, and also a video (which I was able to understand better). I want to screenrecord, but have lossless audio (not lossless video & audio, "tremendous file size"). From what I gather, I should choose Settings>output>recording>type:Custom Output FFMPEG.

However, I have an AMD Ryzen 5/Vega 8 laptop (Mesa driver) which OBS-Studio seems to recognize (the GPU) when using the default "type: Standard." I've been getting terrific results using FFMPEG-VAAPI, CQP rate control, and QP 0:

obs-studio gpu.png


That seems to be some kind of lossless (indistinguishable?) video setting which I'm very happy with (I don't want to lose it!). When I switch to "type: Custom Output," I can see how to do lossless audio (assuming that video I linked to is the best, most lossless way to do it). But, I don't seem to have the same video choices (or, it's not as clear to me how to recreate that in what feels like a different "language.").

When I set "type: custom output (FFMPEG)," I do see "container format: Matroska" and then "video encoder: h264_vaapi (libx264)." I've got a feeling that's the first steps? But, how do I set CQP and QP=0, profile high? Those are freeform "encoder settings?"

Thank you! [Note: I'm running OBS 26.1.2+dfsg1-1 (on MX Linux 19.4)]
 
Last edited:

az2020

New Member
When I set "type: custom output (FFMPEG)," I do see "container format: Matroska" and then "video encoder: h264_vaapi (libx264)." I've got a feeling that's the first steps? But, how do I set CQP and QP=0, profile high? Those are freeform "encoder settings?"

Sorry to bump my own post. I realized the log might shed some light. I ran OBS using "Type: Standard" (as screenshotted in prior post):

Code:
05:41:11 PM.036: Starting recording due to hotkey
05:41:11 PM.041: ---------------------------------
05:41:11 PM.045: [FFMPEG VAAPI encoder: 'recording_h264'] settings:
05:41:11 PM.045:     device:       /dev/dri/renderD128
05:41:11 PM.045:     rate_control: CQP
05:41:11 PM.045:     profile:      100
05:41:11 PM.045:     level:        40
05:41:11 PM.045:     qp:           0
05:41:11 PM.045:     bitrate:      0
05:41:11 PM.045:     maxrate:      0
05:41:11 PM.045:     keyint:       120
05:41:11 PM.045:     width:        1920
05:41:11 PM.045:     height:       1080
05:41:11 PM.045:     b-frames:     0
05:41:11 PM.045:
05:41:11 PM.062: ---------------------------------
05:41:11 PM.062: [FFmpeg aac encoder: 'Track1'] bitrate: 160, channels: 2, channel_layout: 3

I think that gives me an idea what needs to be passed using "type: custom output (FFMPEG)" and chosing encoder h264_vaapi (libx264).

Is there a way to see the ffmpeg parms being passed? I don't know how to translate the above "standard" execution into what the "custom output" screen needs. (I tried running without parms, hoping I could see the difference in parms. But, it crashes as soon as I record. I think there's no default parms being used which I would amend with my own. I.e., it seems like it needs those parms passed to work.).
 

az2020

New Member
In case anyone else trying to use "custom output" screen recording with vaapi hardware encoder, I found this obsproject wiki where this conundrum was discussed just a month ago. This post near the end sums up (I mean, I recognize what he's feeling there about the "standard" screen recording works with VAAPI -- but gives no audio options, like losseless codec selection. And, the "custom output" way of coming at it doesn't seem to give any way to configure the VAAPI options for video.).

I was hoping I could see what the "standard" screen recording with VAAPI was passing to the encoder, and just pass that on the "custom output" screen. But, even if it were possible to see that, it sounds like the "custom output" screen wouldn't work with it.

That wiki conversation was closed. It's unclear if his view as accepted as a problem, or a workaround?

I've found a couple references that tie into the topic: this braniarc gist on github describes the options that could be passed (but the wiki post above asserts that it's too late to pass them in the "custom output" screen?). This ffmpeg wiki page discusses those same vaapi options.

If I'm on the wrong track, or if there's a workaround, I'd be happy to know. Basically, I just want to do that "standard" screen's VAAPI recording which is working *fabulously* for me. But, I want more choices than just AAC there. I want to be able to use flac or pcm, wav (lossless)? There doesn't seem to be anyway to get both. The "custom output" looks like the way. I don't know what parms to pass. If the log showed what it's passing when the "standard" screen is in effect, that would help. But, that obsproject wiki discussion suggests it won't work(? some options need to be applied before those options are acted upon?).

I'm thinking the best I can do is "standard" and set the audio bitrate to 320 (highest it can be). That would be better than 160, anyway. (The reason I want lossless when recording the screen is that I want to use ffmpeg's "loudnorm" filter to normalize the audio after recording. It's not the end of the world if use AAC 320. I was hoping to do a little better than that since it appears to be possible. But, then the vaapi encoder becomes the challenge.).

I hope someone can confirm if this is how it is.
 
Top