#6482 closed defect (fixed)

h264_videotoolbox encoder hardcodes SPS with 25fps

Reported by: tmm1 Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: vda
Cc: kernrj Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Using a sample source that's 60fps:

$ ffmpeg -i sample.mpg
Input #0, mpegts, from '/tmp/sample.mpg':
  Duration: 00:00:12.18, start: 62785.895789, bitrate: 10736 kb/s
  Program 1
    Stream #0:0[0xfed]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bottom first), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc

Converting via libx264 or other encoder will emit an SPS with the correct timing information:

$ ffmpeg -i sample.mpg -c:v h264 -profile:v high -level 4.2 -map v -frames 10 -y out-expected.h264

$ h264_analyze out-expected.h264 | grep -A3 timing_info | head -4
 timing_info_present_flag : 1
   num_units_in_tick : 1001
   time_scale : 120000
   fixed_frame_rate_flag : 0

$ ffmpeg -i out-expected.h264
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 59.94 fps, 59.94 tbr, 1200k tbn, 119.88 tbc

But using videotoolbox hardcodes to 25fps:

$ ffmpeg -i sample.mpg -c:v h264_videotoolbox -profile:v high -level 4.2 -map v -frames 10 -y out-vt.h264

$ h264_analyze out-vt.h264 | grep -A3 timing_info | head -4
 timing_info_present_flag : 1
   num_units_in_tick : 10000
   time_scale : 500000
   fixed_frame_rate_flag : 1

$ ffmpeg -i out-vt.h264
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 25 fps, 25 tbr, 1200k tbn, 50 tbc

Change History (6)

comment:1 Changed 18 months ago by tmm1

I tried to set the kVTCompressionPropertyKey_ExpectedFrameRate property but it made no difference. It's unclear how to signal to VT what values to put into the SPS timing info.

comment:2 Changed 15 months ago by lagnat

Im seeing this problem too but perhaps for a different reason.

Edit: Looks like this problem might be solved with High Sierra.

Last edited 15 months ago by lagnat (previous) (diff)

comment:3 Changed 15 months ago by cehoyos

  • Keywords vda added

comment:4 Changed 15 months ago by tmm1

@lagnat Can you try the h264_analyze on 10.13 generated h264 file to verify the problem is fixed?

comment:5 Changed 14 months ago by tmm1

Here's what I see after upgrading to macOS 10.13

$ h264_analyze out-vt.h264 | grep -A3 timing_info | head -4
 timing_info_present_flag : 0
   num_units_in_tick : 0
   time_scale : 0
   fixed_frame_rate_flag : 0
$ ffmpeg -i out-vt.h264
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 25 fps, 25 tbr, 1200k tbn, 50 tbc

The fixed fps is no longer part of the SPS. However ffmpeg still identifies the file as 25fps for some reason.

comment:6 Changed 14 months ago by tmm1

  • Resolution set to fixed
  • Status changed from new to closed

If I write it into a mpegts container, the fps is detected correctly. (Containers with a header like mp4 or mkv already worked previously).

macOS 10.12:

$ ffmpeg -i sample.mpg -c:v h264_videotoolbox -profile:v high -level 4.2 -map v -frames 10 -y -f mpegts out-vt.mpg
$ ffmpeg -i out-vt.mpg
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 25 fps, 29.97 tbr, 90k tbn, 50 tbc

macOS 10.13:

$ ffmpeg -i sample.mpg -c:v h264_videotoolbox -profile:v high -level 4.2 -map v -frames 10 -y -f mpegts out-vt.mpg
$ ffmpeg -i out-vt.mpg
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 180k tbc

So I think we can safely say this was a VT bug and has been fixed in the latest macOS.

Note: See TracTickets for help on using tickets.