Skip to content

Latest commit

 

History

History
562 lines (446 loc) · 27.6 KB

File metadata and controls

562 lines (446 loc) · 27.6 KB

FAQ

These are the answers to the most common questions asked about our SDK.

  1. How do I start/stop recording with a tap?
  2. How do I add an AR mask to the app (without AR cloud).
  3. How do I start the Video Editor with a preselected audio track?
  4. How do I use the Video Editor several times from different entry points?
  5. How do I add a color filter (LUT)?
  6. I want to enabled slideshow animation.
  7. I want to change cursor color.
  8. I want to change progress bar position.
  9. How does video editor work when token expires?
  10. Which buttons available if Face AR disabled?
  11. I want to change screens' layout.
  12. I want to change music button position.
  13. How can I get a track name of the audio used in my video after export?
  14. I want to change the font.
  15. I want to check whether my token is expired.
  16. The file “luts” couldn’t be opened because there is no such file.
  17. I want to add audio filters.
  18. I want to change icons and name for effects.
  19. I want to turn off Drafts feature.
  20. I want to change visible tabs in gallery.
  21. I want to get exported video metadata.

1. How do I start/stop recording with a tap?

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

2.How do I add an AR mask to the app (without AR cloud)

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.

3. How do I start the Video Editor with a preselected audio track?

To do so, add the MediaTrack instance as a parameter to the presentVideoEditor method.

videoEditorSDK?.presentVideoEditor(
  from: YourViewController,
  animated: true,
  musicTrack: MediaTrack(...),
  completion: nil
)

4. How do I use the Video Editor several times from different entry points?

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(...)
   }
}

5. How do I add a color filter (LUT)?

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.

Default image color filter Name ID
glitch 101000
instant 101001
grunge 101002
retro 101003
pinkvine 101004
england 101005
spark 101006
korben 101007
remy 101008
canada 101009
sunny 101010
chroma 101011
byers 101012
lilac 101013
bright 101014
hyla 101015
vinyl 101016
lux 101017
egypt 101018
japan 101019
sunset 101020
vivid 101021
neon 101022
chile 101023
norway 101024

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";

6. I want to enable slideshow animation

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

7. I want to change cursor color

All you need is just to set your color into cursorColor parameter in MainOverlayViewControllerConfig entity.

let config = VideoEditorConfig()

config.overlayEditorConfiguration.mainOverlayViewControllerConfig.cursorColor = .white

8. I want to change progress bar position

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

9. How does video editor work when token expires?

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.

10. Which buttons available if Face AR disabled?

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

11. I want to change screens layout.

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

12. I want to change music button position.

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
  ),
] 

13. How can I get a track name of the audio used in my video after export?

/// 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 }
...
}

14 I want to change the font

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.

15. I want to check whether my token is expired.

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)
}

16. The file “luts” couldn’t be opened because there is no such file.

This error occurs because your application bundle doesn't contains required luts folder.

You need to copy luts folder to your project.

17. I want to add audio filters

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()

18. I want to change icons and name for effects.

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.

Default image effect Name ID
Flash 102000
VHS 102001
TV-Foam 102002
Glitch 102003
Acid whip 102004
Zoom 102005
Soul 102006
Cathode 102007
Rave 102008
Polaroid 102009
Glitch 2 102010
Transition 102011
Transition 4 102012
Zoom 2 102013
Kaleidoscope 102014
DSLR Kaleidoscope 102015
Lumiere 102016
DV Cam 102017
VHS 2 102018
Stars 102019
Heat Map 102020
Pixel Static 102021
Pixel Dynamic 102022
Glitch 3 102023
0.5x 104000
2x 104001

In order to change the name of the effect, you need to do it in the localization file.

19. I want to turn off Drafts feature.

To turn off Drafts feature just disable it in FeatureConfiguration entity:

  var config = VideoEditorConfig()
  
  config.featureConfiguration.draftsConfig = .disabled

20. I want to change visible tabs in gallery

To setup visible tabs for gallery just configure it in CombinedGalleryConfiguration entity:

  var config = VideoEditorConfig()
  
  config.combinedGalleryConfiguration.visibleTabsInGallery = [.video, .photo]

21. I want to get exported video metadata

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