Skip to content

Instantly share code, notes, and snippets.

@Willib
Willib / export images to a video (async)
Last active May 28, 2023 13:24
export images(or one image) to a video in swift 3
//
// CXEImageToVideo.swift
// VideoAPPTest
//
// Created by Wulei on 16/12/14.
// Copyright © 2016年 wulei. All rights reserved.
//
import Foundation
import AVFoundation
@Willib
Willib / imageURL
Created January 6, 2017 07:42
iOS中判断一个URL是否为图片路径
private func imageToAssetURL(url: URL) -> URL?{
let pathExtention = url.pathExtension as CFString
let fileUIT = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtention, nil)?.takeRetainedValue()
if (UTTypeConformsTo(fileUIT!, kUTTypeImage)){
let param = CXEEngineInitParam()
let movieMaker = CXEImageToVideo(videoWidth:Int(param.sequence.width), videoHeight: Int(param.sequence.height))
let fileURL = movieMaker.createMovieFrom(url: url, duration: Int(CXPreparetValue.imageDuration))
return fileURL
}
return url