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
57.78k stars 7.74k forks source link

[Media Source] Playback of intra-refresh video is inconsistent #7338

Open Joefis-x20s opened 1 year ago

Joefis-x20s commented 1 year ago

Operating System Info

Windows 10

Other OS

No response

OBS Studio Version

28.0.1

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/Z9gc2nE1-H-WTNyf

OBS Studio Crash Log URL

No response

Expected Behavior

A MPEGTS Stream with the flag "intra-refresh=1" should playback correctly when opening it in Media Source.

Current Behavior

Playback of an intra-refresh mpegts stream* does not load first try.

To load an intra-refresh video you have to start your stream with the flag removed or disabled. Then end that stream. If you don't refresh the playback of the media source and then start the stream again with the flag "intra-refresh=1" it will play correctly.**

Playback of .ts video files recorded with this flag playback correctly on first load.

*using UDP MPEGTS (libx264, HEVC_NVENC and h264_NVENC)

** Using SRT you are unable to "hotswap" the SRT stream with new settings without refreshing the Media Source (If doing P2P)

Steps to Reproduce

  1. Create a UDP/SRT MPEGTS stream output in OBS using either (libx264, HEVC_NVENC or h264_NVENC)
  2. Add "intra-refresh=1" to the Video Encoder Settings/x264 Options
  3. Attempt to playback the stream using Media Source in OBS
  4. If done correctly audio should play however no video just blackscreen.

If using UDP you can temp fix this issue by: 1a. Stopping the stream you are currently playing in the Media Source 2a. Disable/Remove "intra-refresh" 3a. Start the stream again. (It will now play correctly) 4a. Stop the stream again. 5a. Add/Enable "intra-refresh" Then start the stream again without touching the media source and then the video will playback correctly with intra-refresh.

Anything else we should know?

intra-refresh changes how keyframes are encoded. Rather than using I frames at specific intervals, intra-refresh will "keyframe" the video as a progressive scan. (left to right with x264) (top to bot with NVENC) This makes is more ideal when broadcasting low latency content or content that needs more consistant data per frame. Also better resiliance to packet loss.

Enabling "Use hardware decoding when available" makes x264 work perfectly. (HOWEVER playback of NVENC with hardware decoding will ignore the rolling keyframe data and just show p frame/motion data)

matiaspl commented 1 year ago

Under linux It looks like nvdec isn't able to properly decode intra refresh enabled streams at all without the restart trick you're talking about... unless you access nvdec through VAAPI. In that case the decoding runs fine (tested against a stream from a Matrox hardware encoder and an x264 encoded sample stream)

Amazingly enough if you use ffplay+x264 the streams decodes fine.