You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nice work for video export on Apple system by offering customizable audio&video settings.
I recently made an alternative implementation by reference of your codes. And found that
there is some error in [buildDefaultVideoComposition] when you try to make original
video center inside the target size.
The problem is you scaling the video differently in x/y directions when the target DAR
(w/h ratio) is not same to the original video.
matrix = CGAffineTransformScale(matrix, ratio / xratio, ratio / yratio);
That means you havn't preserved the aspect ratio of the original video after decoding.
Someone may wondering why the exported video seems all right. That just becasue AVVideoScalingModeResize is used implicitly for AVVideoScalingModeKey in the settings
of AVAssetWriterInput
/* AVVideoScalingModeResize - Crop to remove edge processing region;
scale remainder to destination area. Does not preserve aspect ratio. */
That means the exported video has been deformed twice during the video export. Deformation
is not gool for keeping video qualities, expecially when target DAR is reciprocal to the
original video DAR.
The fix is quite simple, just apply preferredTransform of the original videoTrack and
then set AVVideoScalingModeKey to AVVideoScalingModeResizeAspect. Here is my patch:
Hi Olivier,
Nice work for video export on Apple system by offering customizable audio&video settings.
I recently made an alternative implementation by reference of your codes. And found that
there is some error in
[buildDefaultVideoComposition]
when you try to make originalvideo center inside the target size.
The problem is you scaling the video differently in x/y directions when the target DAR
(w/h ratio) is not same to the original video.
That means you havn't preserved the aspect ratio of the original video after decoding.
Someone may wondering why the exported video seems all right. That just becasue
AVVideoScalingModeResize
is used implicitly forAVVideoScalingModeKey
in the settingsof
AVAssetWriterInput
As Apple comments:
That means the exported video has been deformed twice during the video export. Deformation
is not gool for keeping video qualities, expecially when target DAR is reciprocal to the
original video DAR.
The fix is quite simple, just apply
preferredTransform
of the original videoTrack andthen set
AVVideoScalingModeKey
toAVVideoScalingModeResizeAspect
. Here is my patch:The text was updated successfully, but these errors were encountered: