This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.
To capture the video (filesize: 19MB), using the free "QuickTime Player" application:
// | |
// GIF2MP4.swift | |
// | |
// Created by PowHu Yang on 2020/4/24. | |
// Copyright © 2020 PowHu Yang. All rights reserved. | |
// | |
/* How to use | |
let data = try! Data(contentsOf: Bundle.main.url(forResource: "gif", withExtension: "gif")!) | |
let tempUrl = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("temp.mp4") |
// MARK: THANKS TO: http://stackoverflow.com/questions/4294996/get-uiimage-from-the-calayer-attached-to-avplayer-extract-frame-from-video-play | |
func finshedCapture(im:CGImage?, view:UIView, error:NSError?) { | |
if let img = im { | |
print("OK") | |
addImageViewWithImage(img, toView: view) | |
} | |
else { | |
print("Fail") | |
} | |
} |