컬렉션 이미지를 바탕으로 동영상을 제작하려고합니다. 이미지의 크기는 inputSize에 있습니다. 비디오의 크기는 outputSize에 유지됩니다.
비디오의 전체 높이에 맞는 이미지 비율을 원합니다.
하지만 설명 할 수없는 이유로 최종 비디오는 전체 높이 이미지 (좋음)를 보여 주지만 가로축으로 늘어납니다.
올바른 가로 세로 비율로 올바른 너비를 얻으려면 어떻게해야합니까?
내 코드 조각은 다음과 같습니다.
static let videoW: CGFloat = 720
static let videoH: CGFloat = 1280
let videoRatio = videoW / videoH
var inputSize = CGSize(width: 480, height:700)
static let outputSize = CGSize(width: videoW, height: videoH)
if let videoWriter = videoWriter {
let videoSettings: [String : AnyObject] = [
AVVideoCodecKey : AVVideoCodecH264,
AVVideoWidthKey : MovieBuilder.outputSize.width,
AVVideoHeightKey : MovieBuilder.outputSize.height,
]
let videoWriterInput = AVAssetWriterInput(mediaType: AVMediaTypeVideo, outputSettings: videoSettings)
let sourceBufferAttributes = [String : AnyObject](dictionaryLiteral:
(kCVPixelBufferPixelFormatTypeKey as String, Int(kCVPixelFormatType_32ARGB)),
(kCVPixelBufferWidthKey as String, Float(inputSize.width)),
(kCVPixelBufferHeightKey as String, Float(inputSize.height))
)
안녕하세요 비디오 설정에서 이것을 사전의 일부에 추가하십시오
AVVideoScalingModeKey : AVVideoScalingModeResizeAspectFill.
소스 bufferAttributes도 동영상 설정과 동일한 크기를 반영해야합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다