BeatboxiOS - A sample implementation for merging multiple video files and/or image files using AVFoundation

Related tags

Image BeatboxiOS
Overview

MergeVideos

This is a sample implementation for merging multiple video files and/or image files using AVFoundation, fixed orientation issues. The project is written in Swift 4.

Features

  • Merge multiple video files.
  • Merge multiple video files with transition animation.
  • Add background music to a video file.
  • Merge multiple video files and multiple image files with transition animation.
  • Add text with fade in / fade out animation into a video file.

Requirements

  • iOS 9.0+
  • Xcode 9.2+
  • Swift 4+

Usage

Drag the file VideoManager/KVVideoManager.swift into your project.

Please refer to the sample project MergeVideos for more details. (Don't forget to run pod install before opening the project).

  • Merge multiple video files
let videoAsset1 = AVAsset(url: urlVideo1!)
let videoAsset2 = AVAsset(url: urlVideo2!)
        
KVVideoManager.shared.merge(arrayVideos: [videoAsset1, videoAsset2]) { (outputURL, error) in
      if let error = error {
           print("Error:\(error.localizedDescription)")
      }
      else {
           if let url = outputURL {
               print("Output video file:\(url)")
           }
     }
}
  • Merge multiple video files with transition animation
let videoAsset1 = AVAsset(url: urlVideo1!)
let videoAsset2 = AVAsset(url: urlVideo2!)
        
KVVideoManager.shared.mergeWithAnimation(arrayVideos: [videoAsset1, videoAsset2]) { (outputURL, error) in
      if let error = error {
           print("Error:\(error.localizedDescription)")
      }
      else {
           if let url = outputURL {
               print("Output video file:\(url)")
           }
     }
}
  • Add background music to a video file
let videoAsset = AVAsset(url: urlVideo!)
let musicAsset = AVAsset(url: urlMusic!)
        
KVVideoManager.shared.merge(video:videoAsset, withBackgroundMusic:musicAsset) { (outputURL, error) in
      if let error = error {
           print("Error:\(error.localizedDescription)")
      }
      else {
           if let url = outputURL {
               print("Output video file:\(url)")
           }
     }
}
  • Merge multiple video files and multiple image files and text with transition animation
let videoData = VideoData()
videoData.isVideo = true
videoData.asset = AVAsset(url: urlVideo!)

let imageData = VideoData()
imageData.isVideo = false
imageData.image = UIImage(named: "sample-image")
        
let textData = TextData()
textData.text = "HELLO WORLD"
textData.fontSize = 50
textData.textColor = UIColor.green
textData.showTime = 3 // Second
textData.endTime = 5 // Second
textData.textFrame = CGRect(x: 0, y: 0, width: 400, height: 300)
        
KVVideoManager.shared.makeVideoFrom(data: [videoData, imageData], textData: [textData]) { (outputURL, error) in
     if let error = error {
           print("Error:\(error.localizedDescription)")
      }
      else {
           if let url = outputURL {
               print("Output video file:\(url)")
           }
     }      
}

Note

This is a sample implementation to demonstrate the functions in AVFoundation with just some simple animations, but you got the idea !

You would be able to add more complicated transition animation, text showing animation by using Core Animation !!!

You might also like...
๐Ÿ“น Your next favorite image and video picker
๐Ÿ“น Your next favorite image and video picker

Description We all love image pickers, don't we? You may already know of ImagePicker, the all in one solution for capturing pictures and selecting ima

Twitter Image Pipeline is a robust and performant image loading and caching framework for iOS clients

Twitter Image Pipeline (a.k.a. TIP) Background The Twitter Image Pipeline is a streamlined framework for fetching and storing images in an application

SwiftColorArt is a demo application that includes Swift files with all classes and extension necessary to create a font color schema matching to an image
SwiftColorArt is a demo application that includes Swift files with all classes and extension necessary to create a font color schema matching to an image

SwiftColorArt SwiftColorArt is a demo application that includes Swift files with all classes and extension necessary to create a font color schema mat

An image download extension of the image view written in Swift for iOS, tvOS and macOS.
An image download extension of the image view written in Swift for iOS, tvOS and macOS.

Moa, an image downloader written in Swift for iOS, tvOS and macOS Moa is an image download library written in Swift. It allows to download and show an

AsyncImage before iOS 15. Lightweight, pure SwiftUI Image view, that displays an image downloaded from URL, with auxiliary views and local cache.

URLImage URLImage is a SwiftUI view that displays an image downloaded from provided URL. URLImage manages downloading remote image and caching it loca

AYImageKit is a Swift Library for Async Image Downloading, Show Name's Initials and Can View image in Separate Screen.
AYImageKit is a Swift Library for Async Image Downloading, Show Name's Initials and Can View image in Separate Screen.

AYImageKit AYImageKit is a Swift Library for Async Image Downloading. Features Async Image Downloading. Can Show Text Initials. Can have Custom Styles

A complete Mac App: drag an image file to the top section and the bottom section will show you the text of any QRCodes in the image.

QRDecode A complete Mac App: drag an image file to the top section and the bottom section will show you the text of any QRCodes in the image. QRDecode

An instagram-like image editor that can apply preset filters passed to it and customized editings to a binded image.
An instagram-like image editor that can apply preset filters passed to it and customized editings to a binded image.

CZImageEditor CZImageEditor is an instagram-like image editor with clean and intuitive UI. It is pure swift and can apply preset filters and customize

Convert the image to hexadecimal to send the image to e-paper

ConvertImageToHex Convert the image to hexadecimal to send the image to e-paper Conversion Order // 0. hex๋กœ ๋ณ€ํ™˜ํ•  ์ด๋ฏธ์ง€ var image = UIImage(named: "sample

Owner
null
Agrume - ๐Ÿ‹ An iOS image viewer written in Swift with support for multiple images.

Agrume An iOS image viewer written in Swift with support for multiple images. Requirements Swift 5.0 iOS 9.0+ Xcode 10.2+ Installation Use Swift Packa

Jan Gorman 601 Dec 26, 2022
Image slide-show viewer with multiple predefined transition styles, with ability to create new transitions with ease.

ATGMediaBrowser ATGMediaBrowser is an image slide-show viewer that supports multiple predefined transition styles, and also allows the client to defin

null 200 Dec 19, 2022
add text(multiple line support) to imageView, edit, rotate or resize them as you want, then render the text on image

StickerTextView is an subclass of UIImageView. You can add multiple text to it, edit, rotate, resize the text as you want with one finger, then render the text on Image.

Textcat 478 Dec 17, 2022
FLImagePicker - A simple image picker supported multiple selection

FLImagePicker A simple image picker supported multiple selection. Features Multiple selection Gesture supported Dark mode Easy modification Installati

Allen Lee 4 Aug 17, 2022
An implementation of High Pass Skin Smoothing using Apple's Core Image Framework

YUCIHighPassSkinSmoothing An implementation of High Pass Skin Smoothing using CoreImage.framework Available on both OS X and iOS. Ports A MetalPetal b

Yu Ao 1.2k Dec 17, 2022
๐Ÿ“ท A composable image editor using Core Image and Metal.

Brightroom - Composable image editor - building your own UI Classic Image Editor PhotosCrop Face detection Masking component ?? v2.0.0-alpha now open!

Muukii 2.8k Jan 3, 2023
๐Ÿ“ท A composable image editor using Core Image and Metal.

Brightroom - Composable image editor - building your own UI Classic Image Editor PhotosCrop Face detection Masking component ?? v2.0.0-alpha now open!

Muukii 2.8k Jan 2, 2023
GPUImage 2 is a BSD-licensed Swift framework for GPU-accelerated video and image processing.

GPUImage 2 Brad Larson http://www.sunsetlakesoftware.com @bradlarson [email protected] Overview GPUImage 2 is the second generation of th

Brad Larson 4.8k Dec 29, 2022
An open source iOS framework for GPU-based image and video processing

GPUImage Brad Larson http://www.sunsetlakesoftware.com @bradlarson [email protected] Overview The GPUImage framework is a BSD-licensed iO

Brad Larson 20k Jan 1, 2023
A GPU accelerated image and video processing framework built on Metal.

MetalPetal An image processing framework based on Metal. Design Overview Goals Core Components MTIContext MTIImage MTIFilter MTIKernel Optimizations C

null 1.5k Jan 4, 2023