Skip to content

Commit

Permalink
fix(ios): Scale videos
Browse files Browse the repository at this point in the history
  • Loading branch information
dragermrb committed Apr 8, 2022
1 parent 9835a5d commit aec5134
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions ios/Plugin/SimpleSessionExporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,14 @@ extension SimpleSessionExporter {
start: .zero,
duration: composition.duration)
videoComposition.instructions = [instruction]
let layerInstruction = compositionLayerInstruction(for: compositionTrack, assetTrack: assetTrack)

let layerInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: compositionTrack)
let transform = assetTrack.preferredTransform.scaledBy(
x: videoSize.width / assetTrack.naturalSize.width,
y: videoSize.height / assetTrack.naturalSize.height
)
layerInstruction.setTransform(transform, at: CMTime.zero)

instruction.layerInstructions = [layerInstruction]

// Export
Expand Down Expand Up @@ -144,16 +151,6 @@ extension SimpleSessionExporter {
}
}
}

private func compositionLayerInstruction(for track: AVCompositionTrack, assetTrack: AVAssetTrack) -> AVMutableVideoCompositionLayerInstruction {
let instruction = AVMutableVideoCompositionLayerInstruction(assetTrack: track)
let transform = assetTrack.preferredTransform

instruction.setTransform(transform, at: .zero)

return instruction
}

}

// MARK: - AVAsset extension
Expand Down

0 comments on commit aec5134

Please sign in to comment.