fzwoch / obs-vaapi

OBS Studio VAAPI support via GStreamer
GNU General Public License v2.0
118 stars 3 forks source link

Ability to set Profile #26

Open RushingAlien opened 5 months ago

RushingAlien commented 5 months ago

Profiles are not part of encoder option, but part of src pads

vah265enc

  SRC template: 'src'
    Availability: Always
    Capabilities:
      video/x-h265
                profile: { (string)main, (string)main-10 }
                  width: [ 1, 7680 ]
                 height: [ 1, 4352 ]
              alignment: au
          stream-format: byte-stream

vah264enc

  SRC template: 'src'
    Availability: Always
    Capabilities:
      video/x-h264
                profile: { (string)constrained-baseline, (string)main, (string)high }
                  width: [ 1, 4096 ]
                 height: [ 1, 2160 ]
              alignment: au
          stream-format: byte-stream
fzwoch commented 5 months ago

I would think the encoder select the proper ones depending on what features are being selected and used by the encoder? I haven't checked though..

Having features and profiles independently select-able is a UI nightmare in my opinion as it is unclear who wins, and probably just results in an error in case of mismatch.

RushingAlien commented 5 months ago

hm... then what encoder option would trigger those? or does it depend on the video stream it receives through the sink pad?

in any case, asking cause ffmpeg-vaapi, quicksync, etc has those options gambar

fzwoch commented 5 months ago

Ok, AVC and HEVC are a bit different here.

In AVC you could for example select to have b-frames, which cannot exist in baseline/constraint-baseline for example.

It is a bit less complex on the HEVC side. The decision on your example should be auto-selected depending on your set output format in OBS. As personally I do not see much sense when you select an 8-bit output format you want to encode with 10-bit. Or vice versa, if you set OBS to composite in 10-bit, why would you want your encode to be done in 8-bit then.

I guess there can be occasions were someone explicitly wants that - but I guess these are the rare edge cases. I blame it on the Pareto principle..

RushingAlien commented 5 months ago

ah, so if the video stream obs creates is 10 bit, vah265enc would automatically choose a 10-bit output? Then i too see this manual as very low priority.

fzwoch commented 5 months ago

ah, so if the video stream obs creates is 10 bit, vah265enc would automatically choose a 10-bit output?

I'd hope so. I think I verified that it is/was working at some point.. I hope it still does!

RushingAlien commented 3 months ago

gambar

I have confirmed that it does not, and below is the setting i used.
gambar

fzwoch commented 3 months ago

yuv420p10 sounds like 10 bit to me.

RushingAlien commented 3 months ago

Oh sorry I meant the "Main" part which says the profile. For example this is an obs-ffmpeg encoded video with main10 profile set

gambar

fzwoch commented 3 months ago

I need to check some time whats happening here. I'm not even sure what Main 10 and yuv420p10 together means. Main 10 shoul dbe 8 bit only, so no idea what to make out of it. Not that i think it makes a difference.. but bt.709 and 10 bit is probably not a good pair.

fzwoch commented 3 months ago

A quick test:

$ gst-launch-1.0 videotestsrc  ! vapostproc ! vah265enc ! video/x-h265,profile=main ! h265parse ! filesink location=x.265

$ mediainfo x.265 
General
Complete name                            : x.265
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
File size                                : 14.3 MiB
Frame rate                               : 30.000 FPS

Video
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main@L2@Main
Width                                    : 320 pixels
Height                                   : 240 pixels
Display aspect ratio                     : 4:3
Frame rate                               : 30.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
$ gst-launch-1.0 videotestsrc ! video/x-raw,format=P010_10LE ! vapostproc ! vah265enc ! video/x-h265,profile=main-10 ! h265parse ! filesink location=x.265

$ mediainfo x.265 
General
Complete name                            : x.265
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
File size                                : 10.7 MiB
Frame rate                               : 30.000 FPS

Video
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main@L2@Main
Width                                    : 320 pixels
Height                                   : 240 pixels
Display aspect ratio                     : 4:3
Frame rate                               : 30.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
$ gst-launch-1.0 videotestsrc ! video/x-raw,format=P010_10LE ! vapostproc ! vah265enc ! video/x-h265,profile=main ! h265parse ! filesink location=x.265

Fails to run!
$ gst-launch-1.0 videotestsrc  ! vapostproc ! vah265enc ! video/x-h265,profile=main-10 ! h265parse ! filesink location=x.265

Fails to run!

First is main profile at 8-bit. Second is main-10 at 10-bit. Other than the notice of 10-bit, there is no indication about main-10. Third one is a try to use 10-bit with main. Which fails because format and profile contradict each other. Fourth one is a try to use 8-bit with main-10. Which fails because format and profile contradict each other.

So I guess the correct profile will be selected depending on the input color bit depth.

RushingAlien commented 3 months ago

Hm... So is it just that gstreamer does not insert main10 as profile metadata or something?

Format profile                           : Main 10@L5@Main

This is the information i got when encoding ffmpeg with main10

fzwoch commented 3 months ago

Perhaps.. not even sure what this exact syntax is trying to say, or where these values come from. Using x265enc I can get the Main 10 at the beginning too. Then again, why is there a Main following the level?