obsproject / obs-studio

OBS Studio - Free and open source software for live streaming and screen recording
https://obsproject.com
GNU General Public License v2.0
60.34k stars 7.99k forks source link

Apple VT Encoder (mac-vth264) recording with fractional frame rate does not match OBS frame rate #2760

Closed juniorporciuncula closed 2 years ago

juniorporciuncula commented 4 years ago

Platform

Operating system and version: macOS Mojave (10.14.6) OBS Studio version: 25.0.7

Expected Behavior

Streaming and Recording must record the files with the selected frame rate on OBS

Current Behavior

Streaming and Recording are recorded with 25 fps (even if I set OBS for 30fps) and 50fps (even if I set OBS for 60fps) This doesn't happen with x264. On x264 the recording will respect the OBS frame rate.

Steps to Reproduce

Set OBS for 30 fps and record the video using Apple VT Hardware Encoder.

Additional information

I've tried a lot of versions of OBS, but this problem occurs with all version, in any macOS I've tested (Yosemite, El Capitan, High Sierra and Mojave) Captura de Tela 2020-04-19 às 21 52 56

Fenrirthviti commented 4 years ago

Can you please properly fill out the bug report template?

snicolai-blog commented 4 years ago

I just used the VT hardware encoder at 30 fps for a recording over an hour long this morning. The local recording is at 30 fps as shown by the QuickTime player. The primary video source was a video camera at 1280x720 30 fps.

MacOS X 10.14.6 (18G4032) MacBook Pro (Retina, 15-inch, Mid 2014) Running with en-us locale settings.

OBS 25.0.6

juniorporciuncula commented 4 years ago

I just used the VT hardware encoder at 30 fps for a recording over an hour long this morning. The local recording is at 30 fps as shown by the QuickTime player. The primary video source was a video camera at 1280x720 30 fps.

MacOS X 10.14.6 (18G4032) MacBook Pro (Retina, 15-inch, Mid 2014) Running with en-us locale settings.

OBS 25.0.6

Please, download the software "Invisor Lite" and check the REAL (Original) fps of your video

snicolai-blog commented 4 years ago

That shows 30 fps as well.

Screen Shot 2020-04-19 at 8 49 37 PM
juniorporciuncula commented 4 years ago

That shows 30 fps as well.

Screen Shot 2020-04-19 at 8 49 37 PM

You must look at the EXTENDED tab

snicolai-blog commented 4 years ago

It's 30 fps there as well.

Screen Shot 2020-04-19 at 9 08 32 PM

Can you fill out the template properly with the information about your setup? This may be something very specific about your setup, and you haven't told us anything about it.

juniorporciuncula commented 4 years ago

My setup is i7 8700k, 32GB RAM, Vega 64, Samsung EVO 860 1TB

Your video information show Variable Framerate, mine show Constant, I dont know why, these options doesn't even show on OBS settings

Captura de Tela 2020-04-19 às 23 17 46

snicolai-blog commented 4 years ago

Here's another short one off my FaceTime camera on my Mac. This is off a recorded mkv file. The other one was an mkv remuxed by OBS to mp4.

Screen Shot 2020-04-19 at 9 24 22 PM
snicolai-blog commented 4 years ago

What is your video source? Can you repeat the test I just did? Record a few seconds of the FaceTime camera to an mkv file. Try it with both a 1920x1080 and a 1280x720 canvas and output.

juniorporciuncula commented 4 years ago

What is your video source? Can you repeat the test I just did? Record a few seconds of the FaceTime camera to an mkv file. Try it with both a 1920x1080 and a 1280x720 canvas and output.

My video source is a Blackmagic Cinema Camera connected to a Blackmagic Intensity Pro (HDMI). I also have an Logitech BRIO. I'll recording both x264 and Apple VT on both cameras. My OBS is set to 30fps.

energizerfellow commented 4 years ago

I'd laugh if Apple VT is trying to be "helpful" by using PAL fps rates if the OS is set to a locale in one of the traditional PAL/SECAM markets.

RytoEX commented 4 years ago

@juniorporciuncula Could you please verify your system locale setting? Could you please also post an OBS log from a session where this happens? You can attach it to a post rather than posting it inline.

PatTheMav commented 4 years ago

So I just checked with Apple VT Hardware encoding (and I'm firmly in PAL territory) and FaceTime Cam included and the recordings had 60fps and 30fps respectively (no other "Original Frame Rate").

Note that recorded MKVs will have a Constant Framerate, the MP4s muxed by OBS will have variable frame rates.

juniorporciuncula commented 4 years ago

Hi, guys. Here is the Log: https://obsproject.com/logs/yV-rF_XEPhBO-ZAi

My location is Brasil

Here is the media info on Invisor Lite Captura de Tela 2020-04-30 às 18 34 58

juniorporciuncula commented 4 years ago

I also tried the recording on MKV format, but the problem is the same. There aren't 30 frames per second, you can see the "jumping" frames on the recorded video.

RytoEX commented 4 years ago

Looking at your log, you have your OBS video FPS set to 29.97 FPS (30000/1001), not 30 FPS. This turns out to be an important detail.

On Windows, I am unable to reproduce this using NVENC. However, QuickSync does seem to produce files that MediaInfo shows as VFR if using a fractional FPS that does not reduce to an integer value in OBS. It is possible that the VT encoder on your system is using QuickSync (from the i7-8700K) under the hood and resulting in the same issue.

I'm not sure if this is something we can fix, or if this is an issue with QuickSync or the VT encoder.

juniorporciuncula commented 4 years ago

29,970 is to mantain the TBC with my Blackmagic Camera. But the problems occurs even with the OBS set to 30fps. If somebody want I can generate a new log with OBS on 30fps

juniorporciuncula commented 4 years ago

with x264 OBS records perfect with 30, 29,970, 24... with Apple VT OBS only records with 25fps or 50fps.

RytoEX commented 4 years ago

Yes, I do want a log showing the exact issue you're describing. These are invaluable diagnostic tools for us.

The fact that it works fine on x264 but not on Apple VT is interesting, but I'm not sure exactly what's going on here. Curiously, 25.111/29.97, 25/30, 50/60 are all about 0.83. I'll need the macOS folks to look into it and weigh in.

snicolai-blog commented 4 years ago

In addition to the log, you mentioned that you have a different camera, but we haven't seen if it can be reproduced with a different camera, or is it something specific to the Blackmagic setup you are using. If you can reproduce it with a built-in FaceTime camera, that will make it easier for others to reproduce it, since they likely have that hardware.

Apple also has a software version of the VT encoder. Does it happen with that?

datalooper commented 4 years ago

I can also confirm that VT is only really working in 25fps or 50fps. I just went through for about 2 hours trying to get non-choppy video using the Apple VT and changing the fps to one of those values worked brilliantly. WTF.

humphd commented 4 years ago

I'm really happy to have stumbled on this issue, since I'd just about given up on using the Apple VT encoder. Then I switched my frame rate to 25 and it's perfect.

carlosferrari commented 4 years ago

Hi everyone! I have a similar issue with my OBS. My main goal is to record from my Sony A7III using a BM Deck Link Mini Recorder 4K. I'm recording at 2160p@24 from camera using Apple VT H264 Hardware Encode but the output file is a 20fps. Here is the log: https://obsproject.com/logs/ZWWKAYNAjnUD-WK0 Here is the screenshot from invision lite: Screen Shot 2020-06-29 at 18 53 37

I thought it was from my camera/capture device (I have tried an Elgato CamLink 4K too) but when I was recording the screen to edit with the capture from the camera I got the same wrong fps with VT H264 when recording at 1080p@24fps. Here is the log: https://obsproject.com/logs/wIECwmlwV1vqK-y_ (copy with underline or is's not found) Here is the screenshot from invision lite: Screen Shot 2020-06-29 at 19 06 42

Fun fact, I'm from Brazil as is the OP @juniorporciuncula x264 works without an issue Feel free to ask me what you need!

energizerfellow commented 4 years ago

Yes, I do want a log showing the exact issue you're describing. These are invaluable diagnostic tools for us.

The fact that it works fine on x264 but not on Apple VT is interesting, but I'm not sure exactly what's going on here. Curiously, 25.111/29.97, 25/30, 50/60 are all about 0.83. I'll need the macOS folks to look into it and weigh in.

This is likely a bug in Apple VT relating to the Brazil-specific legacy of PAL-M. PAL-M was unique in the world for combining the PAL color system on a 59.95 hz M system (525-line with 60 * 1000 / 1001 ~= 59.94 fps) instead of the global standard of PAL color on 50 hz . The math here being:

50 / ( 60 * 1000 / 1001 ) ~= 0.834167

This multiplier seems to apply on all these cases as you end up with things like:

24 ( 50 / ( 60 1000 / 1001 ) ) = 20.02

More info on PAL-M: https://en.wikipedia.org/wiki/NTSC#PAL-M_(Brazil) https://en.wikipedia.org/wiki/PAL-M

This "fun" continues into the HD era with ISDB-T International, aka ISDB-Tb, aka SBTVD: https://en.wikipedia.org/wiki/ISDB-T_International

In theory setting your locale to anything other than Brazil in macOS should fix this issue, but might require a non-ISDB-T country.

An interesting test case would be a Japan, Philippines, or non-Panama Central America locale as they where historically NTSC, but on ISDB-T today.

carlosferrari commented 4 years ago

In theory setting your locale to anything other than Brazil in macOS should fix this issue, but might require a non-ISDB-T country.

Hi! Unfortunately setting locale to US didn't work. When setting 24fps records at 20fps, when setting 29.97fps records at 25fps, when setting 30fps records at 30fps.

Should I test with other locale?

snicolai-blog commented 4 years ago

It may not be the locale, it might be something in the video descriptor that the VT encoder sees and triggers this behavior.

energizerfellow commented 4 years ago

Here is the log: https://obsproject.com/logs/ZWWKAYNAjnUD-WK0 Here is the screenshot from invision lite: Screen Shot 2020-06-29 at 18 53 37

@carlosferrari I noticed in your OBS logs that you're running in RGBA mode, which may be part of the problem. The Apple VT encoder will have to do the RGB -> yuv420p transcode. You're also getting full-range YUV output, which can cause color accuracy problems in lots of players/editors/transports.

It may not be the locale, it might be something in the video descriptor that the VT encoder sees and triggers this behavior.

@snicolai-blog Quite possible, yes, but I've seen some increasing evidence that Intel's Quick Sync encoding may be broken at sub-30 fps (not sure if NTSC 29.97 or true 30.00 yet) on older iGPUs, if not all of them. Not sure if this is a hardware and/or driver side issue, but I've seen this in the wild on Windows as well.

When setting 24fps records at 20fps, when setting 29.97fps records at 25fps, when setting 30fps records at 30fps.

@carlosferrari What do you get when you try 29.97 fps with a YUV-native output mode like NV12, i420, or i444? Also try fps rates in the 60-120+ range to see if the final encode gets the correct fps rate. Partial vs full-range may have an effect as well.

carlosferrari commented 4 years ago

@carlosferrari I noticed in your OBS logs that you're running in RGBA mode, which may be part of the problem. The Apple VT encoder will have to do the RGB -> yuv420p transcode. You're also getting full-range YUV output, which can cause color accuracy problems in lots of players/editors/transports. @carlosferrari What do you get when you try 29.97 fps with a YUV-native output mode like NV12, i420, or i444? Also try fps rates in the 60-120+ range to see if the final encode gets the correct fps rate. Partial vs full-range may have an effect as well.

@energizerfellow Sorry for the late reply, busy week. Here are the results. With constant framerates it work. When using NTSC 24P or 23.97 or 59.97 it doesn't.

60fps 59 97fps 50fps 48fps 30fps 29 97fps 25fps 20fps 10fps

carlosferrari commented 4 years ago

How can we bump this? OBS for mac is useless with this bug.

thomaslfessler commented 3 years ago

Bump as well. The macOS version needs more attention. The windows based codebase chews up CPU and GPU bandwith on macos. Frame rate performance issues are just a drop in the bucket.

PatTheMav commented 3 years ago

As with any Open Source project, you are free to fork and clone the repository, investigate issues and contribute to their solutions. Bumping the issue won't do a thing, as to my knowledge no maintainer has been able to reproduce this issue.

RytoEX commented 2 years ago

We can confirm that recording with the Apple VT encoder with a fractional frame rate results in the files appearing to have (in metadata viewers or other software that displays a media file's frame rate) a frame rate that does not match what the user set. We are still investigating this.

Using the Apple VT encoder with integer frame rates seems to work fine.

WizardCM commented 2 years ago

Fixed by #6644