Author Topic: Cut OBS x264 video becomes garbled  (Read 1929 times)

phaolo

  • Newbie
  • *
  • Posts: 43
Cut OBS x264 video becomes garbled
« on: July 10, 2019, 08:50:18 AM »
Hello, I noticed that when I cut OBS videos (directly, without re-encoding), the result becomes broken.
I just get a grey garbled image in VLC.

Example videos (Enter the Gungeon shop):
https://drive.google.com/file/d/1Ud4yCLwVOCJ0i5cR6iFgwhopzBJqkDv8/view?usp=sharing
https://drive.google.com/file/d/118Su4EAYeSW6fCxJA9L1q2eu0y7O1L0p/view?usp=sharing

I see this in VLC:
https://drive.google.com/file/d/1VF2zJsRPMDfA6YKgEUOJz8AZDTtsw-oC/view?usp=sharing

Do you know why?

P.s: and re-encoding to H265 sometimes works, but other times I get a video with freezing frames
« Last Edit: July 12, 2019, 03:24:04 PM by phaolo »

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3466
Re: Cut OBS x264 video becomes garbled
« Reply #1 on: July 11, 2019, 02:16:52 PM »
Thank you for the sample. mpv complains

Code: [Select]
[mkv] This is a broken file! Packets with incorrect keyframe flag found. Enabling workaround.
when playing the source video.

I'll look into this later. Probably the file is really broken, but it would be interesting to investigate whether we could deal with it better.


eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3466
Re: Cut OBS x264 video becomes garbled
« Reply #2 on: July 11, 2019, 06:25:52 PM »
The H.264 video stream in the sample is indeed broken in the following way: it doesn't contain proper IDR (instant decoder refresh) frames except of the very first frame but uses recovery, i.e. some non-IDR frames (P-frames) are encoded in a way which allows forward decoding to succeed when initiated at these frames. For this purpose, these frames must be announced in a preceding NAL (network abstraction layer) unit of type SEI (supplemental enhancement information) as recovery points. These SEI units are absent in the sample. Instead, non-IDR recovery frames are marked as IDR at the NAL layer, profoundly confusing decoders – at least in case of libavcodec at heart of VLC, mpv and Avidemux.

Freezing frames when re-encoded are probably the result of problems during the decoding phase, e.g. when a recovery frame is somewhat damaged and the decoder has to wait until the next recovery point passes by.

phaolo

  • Newbie
  • *
  • Posts: 43
Re: Cut OBS x264 video becomes garbled
« Reply #3 on: July 12, 2019, 01:06:23 AM »
Thank you for replying.
Then this seems an OBS problem.
Tomorrow I'll write to the devs and point to this thread.

Btw, can these files be repaired in a non-destructive way? :\
« Last Edit: July 12, 2019, 01:09:12 AM by phaolo »

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3466
Re: Cut OBS x264 video becomes garbled
« Reply #4 on: July 12, 2019, 05:26:22 PM »
Btw, can these files be repaired in a non-destructive way? :\

Probably yes. It might be possible to inject a SEI NAL unit of the recovery type before each recovery point. I'll look into available options later.

phaolo

  • Newbie
  • *
  • Posts: 43
Re: Cut OBS x264 video becomes garbled
« Reply #5 on: July 16, 2019, 10:33:02 PM »
Thank you. I really hope it will be possible.

In the meantime, OBS devs are checking this issue too.
Changing the color to NV12 instead of I444 seems to avoid the error, even if it's not really a solution for me.
« Last Edit: July 16, 2019, 10:34:44 PM by phaolo »

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3466
Re: Cut OBS x264 video becomes garbled
« Reply #6 on: July 17, 2019, 09:36:17 PM »
Changing the color to NV12 instead of I444 seems to avoid the error, even if it's not really a solution for me.

Could you please provide a short sample in NV12 colorspace which works?

phaolo

  • Newbie
  • *
  • Posts: 43
Re: Cut OBS x264 video becomes garbled
« Reply #7 on: July 17, 2019, 11:54:48 PM »
I can't! The forum program blocks me when I add the Google Drive link :/

Code: [Select]
An Error Has Occurred!
CleanTalk: *** Forbidden. Please enable JavaScript. ***

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3466
Re: Cut OBS x264 video becomes garbled
« Reply #8 on: July 18, 2019, 10:44:58 AM »
CleanTalk is a disaster, topped only by the disaster without CleanTalk. Please provide the link per PM.

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3466
Re: Cut OBS x264 video becomes garbled
« Reply #9 on: July 18, 2019, 01:10:47 PM »
Thank you for the sample. The video stream is indeed fully okay. It is yuv420p, not nv12. What did you mean by "changing color to NV12"?

phaolo

  • Newbie
  • *
  • Posts: 43
Re: Cut OBS x264 video becomes garbled
« Reply #10 on: July 18, 2019, 09:18:54 PM »
Thank you for the sample. The video stream is indeed fully okay. It is yuv420p, not nv12. What did you mean by "changing color to NV12"?
OBS has these color options:

format:
- NV12 (default)
- I420
- I444 (what I prefer)
- RGB

space:
- 601 (default)
- 709 (what I use)

range:
- partial (default)
- full (what I use)

The broken samples were obtained with I444, 709, full.
The last correct one, instead, with NV12, 601, partial.

I don't know why it's wrong.

Btw I'm just a normal user, ideally you devs should talk directly ;P
Here is the thread, in case you're interested to suggest something to OBS:
( CleanTalk stopped me again -_- )

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3466
Re: Cut OBS x264 video becomes garbled
« Reply #11 on: July 18, 2019, 09:40:33 PM »
What happens if you strip the protocol prefix from links, making them unclickable?

I understand, you refered to OBS settings, not the real properties of the output.

phaolo

  • Newbie
  • *
  • Posts: 43
Re: Cut OBS x264 video becomes garbled
« Reply #12 on: July 18, 2019, 09:44:49 PM »
It doesn't work, I''l send you a PM.

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3466
Re: Cut OBS x264 video becomes garbled
« Reply #13 on: July 18, 2019, 10:00:57 PM »

phaolo

  • Newbie
  • *
  • Posts: 43
Re: Cut OBS x264 video becomes garbled
« Reply #14 on: July 19, 2019, 05:05:17 PM »
They finally replied again.
So, the culprit is the old x264 version they're using.. I hope they'll update it soon (not in years).

I'd prefer not to go back to those crappy NV12 or i420 colors as they suggested.
I'll keep using i444 and fix all the files with your method at some point in the future.
(I hope it will be also scriptable, because I made a ton of recordings)