These are the answers to the most common questions asked about our SDK.
- How do I start/stop recording with a tap?
- How do I add an AR mask to the app (without AR cloud).
- How do I start the Video Editor with a preselected audio track?
- How do I use the Video Editor several times from different entry points?
- How do I add a color filter (LUT)?
- I want to enabled slideshow animation.
- I want to change cursor color.
- I want to change progress bar position.
- How does video editor work when token expires?
- Which buttons available if Face AR disabled?
- I want to change screens' layout.
- I want to change music button position.
- How can I get a track name of the audio used in my video after export?
- I want to change the font.
- I want to check whether my token is expired.
- The file “luts” couldn’t be opened because there is no such file.
- I want to add audio filters.
- I want to change icons and name for effects.
- I want to turn off Drafts feature.
- I want to change visible tabs in gallery.
- I want to get exported video metadata.
By default, the user must hold the “record” button to film and release it to stop filming.
To change that, set the captureButtonMode property of the RecorderConfiguration entity to .video.
var config = VideoEditorConfig()
config.recorderConfiguration.captureButtonMode = .video
If you don’t want to pull the masks from the backend, you can include them in the app itself.
A mask is a bundle of files within a specific folder in the YourProject/bundleEffects/ directory. The preview.png file in the filter folder is used as an icon within the app, and the name of the directory is also the name of the mask.
Note Please, don’t change the name of the bundleEffects folder, otherwise, the app will not work. If it doesn’t exist already, create it manually.
To do so, add the MediaTrack instance as a parameter to the presentVideoEditor method.
videoEditorSDK?.presentVideoEditor(
from: YourViewController,
animated: true,
musicTrack: MediaTrack(...),
completion: nil
)
Before you want to use VideoEditor again, you need to deinitialize your current editor instance in your entry point class scope. You need to set 'yourVideoEditorSdkInstance' = nil after following funcs called(done and cancel).
// Video Editor Delegate implementation example
extension ViewController: BanubaVideoEditorDelegate {
func videoEditorDone(_ videoEditor: BanubaVideoEditor) {
// User finished editing sessoin, need to dismiss video editor and export video
videoEditorSDK?.dismissVideoEditor(
animated: true
) { [weak self] in
self?.exportVideo(...) { ... in
self?.'yourVideoEditorSdkInstance' = nil
}
}
}
func videoEditorDidCancel(
_ videoEditor: BanubaVideoEditor
) {
// User canceled editing sessoin, need to dismiss video editor
videoEditorSDK?.dismissVideoEditor(
animated: true,
completion: {
self?.'yourVideoEditorSdkInstance' = nil
}
)
}
}
Use the following approach if you want to create BanubaVideoEditor instance again.
For example on your tap button action:
@IBAction func videoEditorButtonTapped(_ sender: UIButton) {
if 'yourVideoEditorSdkInstance' = nil {
'yourVideoEditorSdkInstance' = BanubaVideoEditor(...)
}
}
Color filters (LUTs) are special graphic files placed into the /luts directory inside the host project folder.
To add your own icon that will be used to represent this particular effect in the list, you should place it into the /assets folder.
The name of the icon resource must be the same as the graphic file ID
the / luts directory.
If you want to change the name, you need to specify the new name in the string resources:
/* glitch filter name */
"com.banuba.filter.name.lux" = "Lux";
/* remy filter name */
"com.banuba.filter.name.remy" = "Remy";
/* hyla filter name */
"com.banuba.filter.name.hyla" = "Hyla";
/* neon filter name */
"com.banuba.filter.name.neon" = "Neon";
/* retro filter name */
"com.banuba.filter.name.retro" = "Retro";
/* sunny filter name */
"com.banuba.filter.name.sunny" = "Sunny";
/* egypt filter name */
"com.banuba.filter.name.egypt" = "Egypt";
/* spark filter name */
"com.banuba.filter.name.spark" = "Spark";
/* byers filter name */
"com.banuba.filter.name.byers" = "Byers";
/* lilac filter name */
"com.banuba.filter.name.lilac" = "Lilac";
/* vinyl filter name */
"com.banuba.filter.name.vinyl" = "Vinyl";
/* japan filter name */
"com.banuba.filter.name.japan" = "Japan";
/* chile filter name */
"com.banuba.filter.name.chile" = "Chile";
/* glitch filter name */
"com.banuba.filter.name.glitch" = "Glitch";
/* grunge filter name */
"com.banuba.filter.name.grunge" = "Grunge";
/* canada filter name */
"com.banuba.filter.name.canada" = "Canada";
/* chroma filter name */
"com.banuba.filter.name.chroma" = "Chroma";
/* norway filter name */
"com.banuba.filter.name.norway" = "Norway";
/* korben filter name */
"com.banuba.filter.name.korben" = "Korben";
/* sunset filter name */
"com.banuba.filter.name.sunset" = "Sunset";
/* instant filter name */
"com.banuba.filter.name.instant" = "Instant";
/* england filter name */
"com.banuba.filter.name.england" = "England";
/* pinkvine filter name */
"com.banuba.filter.name.pinkvine" = "Pinkvine";
/* vivid filter name */
"com.banuba.filter.name.vivid" = "Vivid";
/* bright filter name */
"com.banuba.filter.name.bright" = "Bright";
To be able to turn off slideshow animation use following property of RecorderConfiguration
and CombinedGalleryConfiguration
entities.
let config = VideoEditorConfig()
config.combinedGalleryConfiguration.isPhotoSequenceAnimationEnabled = true
config.recorderConfiguration.isPhotoSequenceAnimationEnabled = true
All you need is just to set your color into cursorColor
parameter in MainOverlayViewControllerConfig
entity.
let config = VideoEditorConfig()
config.overlayEditorConfiguration.mainOverlayViewControllerConfig.cursorColor = .white
Progress bar position contains two types of layout:
- top
- bottom (by default)
To change progress bar position you need to modify progressBarPosition
property of RecorderConfiguration
entity.
let config = VideoEditorConfig()
config.recorderConfiguration.progressBarPosition = .top
Token provided by sales managers has an expiration term to protect Video Editor SDK from malicious access. When the token expires the following happens:
- video resolution will be lowered to 360p on camera, after trimmer and after export
- Banuba watermark is applied to every exported video
Also FaceAR SDK you may expect the following actions if the token expires:
- on the first expired month a watermark with "Powered by Banuba" label will be added on the top of both recorded and exported videos
- after the first month the camera screen will be blurred and a full-screen watermark will be displayed
Please keep your licence up to date to avoid unwanted behavior.
AdditionalEffectsButtons contains options set which describes buttons identifiers.
Without Face AR you could use buttons with following identifiers.
Camera Screen:
- sound
- toggle
- flashlight
- timer
- speed
- muteSound
Postprocessing Screen:
- sticker
- sound
- text
- effects
- time
- color
There are two screens which could be modified with additional layout:
- Camera
- Postprocessing
To be able to change layout you need to set useHorizontalVersion
equals true
. This properties are parts of RecorderConfiguration
and EditorConfiguration
entities.
let config = VideoEditorConfig()
config.recorderConfiguration.useHorizontalVersion = true
config.editorConfiguration.useHorizontalVersion = true
The music button consists of three positions:
- bottom
- center
- top
To be able to change the location of the button, you need to set the desired value in the array with additionalEffectsButtons, for the button with the identifier .sound
, set up the position
property.
let config = VideoEditorConfig()
config.recorderConfiguration.additionalEffectsButtons = [
AdditionalEffectsButtonConfiguration(
identifier: .sound,
imageConfiguration: ImageConfiguration(imageName: ""),
selectedImageConfiguration: ImageConfiguration(imageName: ""),
titlePosition: .bottom,
position: .top
),
]
/// Video Editor main entity and entry point.
/// Can present and hide root view controller.
/// Has default export method.
public class BanubaVideoEditor {
/// Simple metadata of music composition settings
public var musicMetadata: MusicEditorMetadata? { get }
...
}
MusicEditorMetadata
contains the array of MusicEditorTrack
which contains the following fields:
// MARK: - MusicEditorTrack
public struct MusicEditorTrack: Codable {
///Track URL
public var url: URL
///Track original URL
public var originalURL: URL
///Track title
public var title: String
///Track id
public var id: Int32
/// Track volume
public var volume: Float
...
}
or if you want to know what track was played on the camera screen you can use:
/// Video Editor main entity and entry point.
/// Can present and hide root view controller.
/// Has default export method.
public class BanubaVideoEditor {
/// Music track which will be played on camera recording
public var musicTrack: MediaTrack? { get }
...
}
You can change the font for the whole video editor by calling in VideoEditorConfig
this method:
func applyFont(_ font: UIFont)
or change for each screen separately by calling the appropriate methods:
func updateFullScreenActivityFonts(_ font: UIFont)
func updateRecorderFonts(_ font: UIFont)
func updateAlbumsFonts(_ font: UIFont)
func updateEditorFonts(_ font: UIFont)
func updateToastFonts(_ font: UIFont)
func updateTextEditorFonts(_ font: UIFont)
func updateSlideShowFonts(_ font: UIFont)
func updateTrimVideoFonts(_ font: UIFont)
func updateTrimVideosFonts(_ font: UIFont)
func updateFilterFonts(_ font: UIFont)
func updateVideoCoverSelectionFonts(_ font: UIFont)
func updateExtendedVideoCoverSelectionFonts(_ font: UIFont)
func updateAlertFonts(_ font: UIFont)
Changing the font does not affect its size. The font size will be taken by default or specified by you in the entity configuration.
Starting from '1.0.18' version it is available to check if token is expired.
/// Check whether token is expired
/// - Parameters:
/// - token: your token that you want to verify.
public static func isTokenExpired(
token: String
) -> Bool
You need to import BanubaLicenseServicingSDK
.
Then call the static method isTokenExpired(token: String)
on the License
entity.
For example:
let token: String = "Put token"
let result: Bool = License.isTokenExpired(token: token)
if you are using BanubaTokenStorageSDK
here is a usage example:
self.loadToken { token in
let result = License.isTokenExpired(token: token)
}
This error occurs because your application bundle doesn't contains required luts folder.
You need to copy luts folder to your project.
Filters availability depends on the token. However, in order for them to be available, you need to add an implementation of the VoiceFilterProvider
entity.
Example how to inherit VoiceFilterProvider
to your own entity:
import BanubaMusicEditorSDK
import UIKit
/// Example voice filter provider
struct ExampleVoiceFilterProvider: VoiceFilterProvider {
private let filters: [VoiceFilter]
// MARK: - VoiceFilterProvider
func provideFilters() -> [VoiceFilter] {
return filters
}
init() {
filters = [
VoiceFilter(
type: .elf,
title: NSLocalizedString("com.banuba.musicEditor.elf", comment: "Elf filter title"),
image: UIImage(named:"elf")
),
VoiceFilter(
type: .baritone,
title: NSLocalizedString("com.banuba.musicEditor.baritone", comment: "Baritone filter title"),
image: UIImage(named:"baritone")
),
VoiceFilter(
type: .echo,
title: NSLocalizedString("com.banuba.musicEditor.echo", comment: "Echo filter title"),
image: UIImage(named:"echo")
),
VoiceFilter(
type: .giant,
title: NSLocalizedString("com.banuba.musicEditor.giant", comment: "Giant filter title"),
image: UIImage(named:"giant")
),
VoiceFilter(
type: .robot,
title: NSLocalizedString("com.banuba.musicEditor.robot", comment: "Robot filter title"),
image: UIImage(named:"robot")
),
VoiceFilter(
type: .squirrel,
title: NSLocalizedString("com.banuba.musicEditor.squirrel", comment: "Squirrel filter title"),
image: UIImage(named:"squirrel")
)
]
}
}
Then the instance of the ExampleVoiceFilterProvider needs to be passed to the configuration.
var config = VideoEditorConfig()
config.musicEditorConfiguration.audioTrackLineEditControllerConfig.voiceFilterProvider = ExampleVoiceFilterProvider()
The name of the icon for the effect must match the identifier of the effect. Below is a table with the name, ID and icon of the default effect.
In order to change the name of the effect, you need to do it in the localization file.
To turn off Drafts feature just disable it in FeatureConfiguration
entity:
var config = VideoEditorConfig()
config.featureConfiguration.draftsConfig = .disabled
To setup visible tabs for gallery just configure it in CombinedGalleryConfiguration
entity:
var config = VideoEditorConfig()
config.combinedGalleryConfiguration.visibleTabsInGallery = [.video, .photo]
In order to find out which filter, effects, masks and music was applied to the video, you need to refer to the instance of the entity BanubaVideoEditor
.
Instance:
let videoEditorSDK = BanubaVideoEditor(
...
)
// to get color filter
let videoFilter = videoEditorSDK?.metadata?.colorOnVideoMetadata
// to get effects
let videoEffects = videoEditorSDK?.metadata?.effectsOnVideoMetadata
// to get gifs
let videoGif = videoEditorSDK?.metadata?.gifOnVideoMetadata
// to get texts
let videoText = videoEditorSDK?.metadata?.textOnVideoMetadata
// to get music track from record screen
let videoMusicTrack = videoEditorSDK?.musicTrack
// to get music tracks from editor screen
let videoTracks = videoEditorSDK?.musicMetadata?.tracks