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
59.01k stars 7.85k forks source link

Sources that have 50 interlaced fields deinterlaced with Yadif 2x look choppy if OBS output is set to 60fps #3402

Open zoton2 opened 4 years ago

zoton2 commented 4 years ago

Platform

Operating system and version: Microsoft Windows 10 Pro (10.0.19041 Build 19041) OBS Studio version: 25.0.8 (64-bit, Windows)

Expected Behavior

Sources with 50 interlaced frames deinterlaced with Yadif 2x (at least, may also happen with other types that produce 50 frames) should look smooth when the OBS output frame rate is higher than 50 (in my tests 60), and should act the same way as a regular source that runs at 50fps progressively does (where there is 5 different frames, followed by 1 identical).

Current Behavior

Said setup looks choppy and the frames appear to be 2 different frames, followed by 1 identical, but poorly "chosen" from the video so it looks choppy because of that.

Steps to Reproduce

  1. In Settings > Video set the overall FPS to 60.
  2. Add a source that outputs at 50 interlaced frames (in my example, my PAL PlayStation 2).
  3. Turn on Yadif 2x deinterlacing for that source.
  4. Notice the frame rate appears to choppy and poor.
  5. In Settings > Video set the overall FPS to 50.
  6. Notice the video is now smooth.

Additional information

Here is an example video where I put my capture card with Yadif 2x deinterlacing on a 50i source next to an already recorded 50fps progressive video using the Media Source (which was also recorded in OBS, but when I had the overall FPS set to 50). Notice how the one on the left looks much more choppy than the one on the right: https://www.youtube.com/watch?v=5JH5TjwS1Es

My capture card is pretty old (Avermedia Game Broadcaster HD) fed by an OSSC, but I feel this happens with any source. I noticed last year there was a PR to fix some deinterlacing in regards to the GV-USB2, but I dunno if this caused this issue or not, but I assume not.

This issue has been around for nearly 2 years at least (if not all the time), when I first noticed it myself in January 2019, just never got around to filing a bug report. I would like to try and debug/fix it myself but my coding knowledge in this area is poor, I assume if it is caused by the deinterlacing it's probably in libobs/obs-source-deinterlace.c, and I feel as it works fine if you set the OBS output frame rate to 50fps then it must be using whatever that is set to instead of what the source actually is?

Also, this persisted onto my new PC I just made so I know it's not a hardware issue (unless it's my capture device).

If this is happening with any source, I'll try to get an example file that other people can test with (as I understand sometimes getting a source like this to test with is difficult).

mufunyo commented 4 years ago

It would be helpful if you could reproduce this with two media sources instead of a progressive media source vs an interlaced video device source.

zoton2 commented 4 years ago

I am currently looking into making a recording that is interlaced that can be played back with the OBS Media Source. I have ones that can be played back with the VLC Source, but VLC's library itself seems to do deinterlacing on that, making it a bit useless for this test.

zoton2 commented 4 years ago

I was able to make a video using ffmpeg that plays back with the OBS Media Source, but that appears to look smoother, but it still appears to have a bug but the duplicated frame amount seems different, so it actually seems closer to 30fps. It is still fixed if the OBS output frame rate is set to 50fps though, so I feel it's related.

OBS set to 60fps output (notice how the right one does appear to look "smoother" but the FPS is still lower than it should be): https://www.youtube.com/watch?v=c_PIjlE4qyI

OBS set to 50fps output (both look smooth and full 50fps): https://www.youtube.com/watch?v=YAafvsuaAcU

Example MP4 interlaced recording from my capture device using ffmpeg: recording.zip

PatTheMav commented 1 year ago

I'm not able to reproduce the issue with the provided interlaced recording on OBS 28.0.3, or I'm not able to "see" it - output seems smooth per the Youtube example provided.

zoton2 commented 1 year ago

Went back just now and checked with the latest OBS (28.1.2) and it is still an issue. It's probably easier to notice if you frame step using a player watching back a recording, if it's correct it should have 5 unique frames followed by 1 duplicate frame (which is the 50p > 60p conversion), compared to how it is when it's "broken" (50i > 60p conversion in OBS) which seems like 2 unique frames, 1 duplicate frame, 1 unique, 1 duplicate... (and maybe a few more, I lost track counting).

I see it wasn't mentioned here but IIRC I was told in this Discord server this was by "design" as everything is processed based on the canvas framerate (so I assume it's basically deinterlacing it as if it was 60i? not sure of the technicalities), so I imagine it's not fixable anyway without a big overhaul.

EDIT: Quote from the old Discord conversation, from beeanyew

it's because the deinterlacing isn't based on the source frame rate, instead it flips the field every time the canvas updates. there's not a whole lot that can be done about it without reworking how the deinterlacing works so while it's unfortunate that it ends up that way for 50i sources, it's kind of intended behavior and not technically a bug

PatTheMav commented 1 year ago

@zoton2 that sounds unfortunate but also correct in how it's currently implemented.

If you don't mind, I would close this issue (as it's not a bug per se) and encourage you to open a feature request to implement "correct" de-interlacing with correct pulldown behaviour for diverging canvas framerates.

mufunyo commented 1 year ago

I would disagree that this is by design. The current implementation only works if the source frame rate exactly matches the canvas frame rate, and explodes in the user's face when that is not the case. That should never happen, and so I would class this as a bug.

Going forward, I see two options:

crannofonix commented 5 months ago

Hope this gets fixed very soon, I run a news channel on YouTube where I sometimes have to use 50 (25x2) and 60fps feeds on my livestreams, so as you would expect I stream in 60fps which makes the 50fps feed look more like 40 or 48.