Incorrect Framerate for videos imported from OBS (2.79+)
Closed, ResolvedPublic

Description

System Information
Windows 7, 8GB RAM, GeForce 1060 with 6GB VRAM

Blender Version
Broken: All versions above 2.79, including 2.79 and 2.8 test builds
Worked: 2.78 and any previous version I've used for video editing, as far back as 2.5.

Short description of error
Videos which are correctly interpreted as being 30fps in 2.78 are being loaded in as 1000fps in 2.79. Somehow, the video playback is still fine, but the number of frames is incorrect and zoom in the vse panel is limited. A 2 minute video has over 120,000 frames. Altering the framerate in the rendering panel only alters the duration of the audio. mp4 files files produced by ffmpeg/blender seem to be fine, but mp4/mkv containers produced by OBS induce the issue.

Exact steps for others to reproduce the error
Launch blender or reload startup file. Open VSE. Add attached video file to VSE by any method. Check the render properties panel. Blender has set framerate to "Custom (1000.0)" with some other unfamiliar variables defined below. Repeat process in 2.78 and notice that the correct framerate (30) is automatically detected, meaning this is a recent change in how blender handles frame rate detection.

Attached is a video that demonstrates the issue for testing purposes.

LazyDodo (LazyDodo) triaged this task as Incomplete priority.Jan 22 2018, 9:59 PM

i'm pretty sure this one is already fixed, please try a build from http://builder.blender.org to validate the issue indeed is already solved.

I just downloaded blender-2.79-42a5624-win64 and blender-2.80-4d3d002-win64 a few hours ago, and the bug occurs in both, so I would say it is not fixed.

The issue existed on the export side, not the import side, the mkv attached is actually set to 1000 fps

Input #0, matroska,webm, from '2018-01-22 15-30-49.mkv':
  Metadata:
    ENCODER         : Lavf57.84.100
  Duration: 00:00:03.03, start: 0.000000, bitrate: 913 kb/s
    Stream #0:0: Video: h264 (Main), yuv420p(tv, bt470bg/unknown/unknown), 1920x1080 [SAR 1:1 DAR 16:9], 1k fps, 30 tbr, 1k tbn, 60 tbc (default)
    Metadata:
      DURATION        : 00:00:03.033000000
    Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
    Metadata:
      title           : Track1
      DURATION        : 00:00:02.926000000
`

But the same file loads fine in 2.78 and all previous versions of blender, and although it's odd to see that OBS is exporting a video with 1k fps, tbr defines the frame rate that the demuxer should use.

tbr defines the frame rate that the demuxer should use

where is this information from?

Christopher Anderssarian (Christopher_Anderssarian) raised the priority of this task from Incomplete to Needs Triage.Feb 7 2018, 6:32 PM

Shows reported results in blender-2.79-66521b3

The video playback is only fine because by default Blender sets the scene fps to the video fps. If you disable use video fps when adding the file (down left) you get an extremely slow video.

There is indeed something wrong with Blender's autodetection of fps. Using tbr instead of fps could be useful if the fps value is wrong (like the "1000 fps" OBS videos which play normally in any video player).

Also from what I could see the code uses r_frame_rate for detecting the fps, but the video I loaded in Blender showed 1000 fps even though ffprobe showed 60/1 fps for the video which made me even more confused. The avg_frame_rate did show 1000/1 though.

tbr is indeed what one is supposed to be using here, at least as per FFmpeg documentation. The issue is: libav removed it (probably, because it was "guessed" value). tbn is what exists in both libav and FFmpeg, but seems it is not trustful value. Since FFmpeg is what all distors are coming back to, and what is was supposed to be used will try to get code back to use tbr when using FFmpeg.