Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#5357 closed enhancement (fixed)

support for options of VideoToolbox H.264 Encoder

Reported by: ponpon Owned by: kernrj
Priority: wish Component: avcodec
Version: git-master Keywords: avfoundation
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

thank ffmpeg team for the good app.

i have comments and requests on VideoToolbox? H.264 Encoder.

comment and request
comment
doesn't VideoToolbox? H.264 Encoder output a proper size to display? probably VideoToolbox? H.264 doesn't set par or sar on a video stream.
i tried

ffmpeg  -y -i city_4cif.y4m -c:v h264_videotoolbox -profile:v high -vf scale=720:480 -aspect 4:3 h264_videotoolbox.264
ffmpeg  -y -i city_4cif.y4m -c:v h264_videotoolbox -profile:v high -vf scale=720:480 -aspect 4:3 h264_videotoolbox.mp4
ffmpeg  -y -i city_4cif.y4m -c:v libx264 -profile:v high -vf scale=720:480 -aspect 4:3 libx264.264

only h264_videotoolbox.264 isn't properly displayed with mpv. can't confirm display aspect ratio.
seeing videotoolboxenc.c, kVTCompressionPropertyKey_CleanAperture and kVTCompressionPropertyKey_PixelAspectRatio aren't supported. is it a cause?

request of support for the below properties in VTCompressionSession.h.
in particular, i strongly request kVTCompressionPropertyKey_Quality, kVTCompressionPropertyKey_FieldCount, and kVTCompressionPropertyKey_FieldDetail.

for options of general encoding
kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration
kVTCompressionPropertyKey_AllowTemporalCompression
kVTCompressionPropertyKey_DataRateLimits
kVTCompressionPropertyKey_Quality
kVTCompressionPropertyKey_H264EntropyMode

for capture or real-time distribution? i don't well understand the below.
kVTCompressionPropertyKey_MoreFramesBeforeStart
kVTCompressionPropertyKey_MoreFramesAfterEnd
kVTCompressionPropertyKey_MaxH264SliceBytes

for capture or real-time distribution
kVTCompressionPropertyKey_RealTime

for confirming whether hardware encoding or not
kVTCompressionPropertyKey_UsingHardwareAcceleratedVideoEncoder

for interlaced encoding
kVTCompressionPropertyKey_FieldCount
kVTCompressionPropertyKey_FieldDetail

for proper color to display
kVTCompressionPropertyKey_ColorPrimaries
kVTCompressionPropertyKey_TransferFunction
kVTCompressionPropertyKey_YCbCrMatrix

Attachments (3)

h264_videotoolbox.264 (510.2 KB) - added by ponpon 2 years ago.
h264_videotoolbox.mp4 (605.0 KB) - added by ponpon 2 years ago.
libx264.264 (1.8 MB) - added by ponpon 2 years ago.

Change History (6)

Changed 2 years ago by ponpon

Changed 2 years ago by ponpon

Changed 2 years ago by ponpon

comment:1 follow-up: Changed 2 years ago by kernrj

  • Owner set to kernrj
  • Status changed from new to open

Several of these can be used now
kVTCompressionPropertyKey_PixelAspectRatio
The pixel aspect ratio (PAR) is set when the display aspect ratio (DAR) is set on the command line using -aspect (PAR and DAR are related - the DAR set on the command line will generate the correct PAR in the output). This can also be set using AVCodecContext.sample_aspect_ratio with the API .

kVTCompressionPropertyKey_H264EntropyMode
Entropy coding can be set with -coder to cabac or cavlc (ac or vlc for short).

kVTCompressionPropertyKey_MoreFramesBeforeStart
kVTCompressionPropertyKey_MoreFramesAfterEnd
These are hints that other frames will be concatenated before or after the current session's frames. They can be set with -frames_before 1 and -frames_after 1. Not all devices support these concatenation flags - they will be ignored when not supported.

kVTCompressionPropertyKey_RealTime
Set with -realtime 1. This is a hint that real-time encoding is more important than quality.

kVTCompressionPropertyKey_ColorPrimaries
kVTCompressionPropertyKey_TransferFunction
kVTCompressionPropertyKey_YCbCrMatrix
Colorimetry info is used when available. They can be set using the API.

Some parameters won't be added
kVTCompressionPropertyKey_Quality
This isn't supported with H.264. It's normally used for JPEG encoding.

kVTCompressionPropertyKey_AllowTemporalCompression
Setting this to false disables P and B-frames, which can be achieved by setting the gop size to 1 (-g 1)

kVTCompressionPropertyKey_UsingHardwareAcceleratedVideoEncoder
This is an output parameter that's true when hardware encoding will be used, but this isn't directly exposed. Encoding will fail if hardware encoding is not supported. If you want to allow software encoding, use -allow_sw 1. Hardware will always be used when available, even if software encoding is allowed.

The rest of these settings will be added in a future patch.

comment:2 Changed 2 years ago by cehoyos

  • Component changed from undetermined to avcodec
  • Keywords avfoundation added
  • Priority changed from normal to wish
  • Resolution set to fixed
  • Status changed from open to closed
  • Type changed from defect to enhancement
  • Version changed from unspecified to git-master

comment:3 in reply to: ↑ 1 Changed 2 years ago by ponpon

Replying to kernrj:
gj
i am enjoying your work and looking fotward to the future patches.

Note: See TracTickets for help on using tickets.