Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#5357 closed enhancement (fixed)

support for options of VideoToolbox H.264 Encoder

Reported by: ponpon Owned by: Rick Kern
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 8 years ago.
h264_videotoolbox.mp4 (605.0 KB ) - added by ponpon 8 years ago.
libx264.264 (1.8 MB ) - added by ponpon 8 years ago.

Change History (6)

by ponpon, 8 years ago

Attachment: h264_videotoolbox.264 added

by ponpon, 8 years ago

Attachment: h264_videotoolbox.mp4 added

by ponpon, 8 years ago

Attachment: libx264.264 added

comment:1 by Rick Kern, 8 years ago

Owner: set to Rick Kern
Status: newopen

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 by Carl Eugen Hoyos, 8 years ago

Component: undeterminedavcodec
Keywords: avfoundation added
Priority: normalwish
Resolution: fixed
Status: openclosed
Type: defectenhancement
Version: unspecifiedgit-master

in reply to:  1 comment:3 by ponpon, 8 years ago

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

Note: See TracTickets for help on using tickets.