ios – FFmpeg drawtext filter error: “Can not discover a legitimate font for the household Sans”

0
23
ios – FFmpeg drawtext filter error: “Can not discover a legitimate font for the household Sans”


I am attempting so as to add textual content overlay to a video utilizing FFmpeg’s drawtext filter in my iOS app, however I am encountering the next error:

error: Can not load default config file

ERROR: Can not discover a legitimate font for the household Sans

ERROR: Error initializing filter ‘drawtext’

ERROR: with args ‘textual content=write some factor :’

Here is the related a part of my FFmpeg command:

Copydrawtext=textual content=”write some factor “

Questions:

What’s inflicting this error, and the way can I resolve it?
Is there a method to specify a font that is assured to be obtainable on iOS units?
Are there any various approaches to including textual content overlay in FFmpeg that may keep away from this situation?

Setting:

Platform: iOS
FFmpeg: Utilizing MobileFFmpeg library
Swift

Any assist or steering can be drastically appreciated!

func makeGIFData(asset: AVAsset,  startTime: Double, endTime: Double, rotation: Double, overlayText: String) async throws -> Knowledge {
    let fileName = "(ProcessInfo.processInfo.globallyUniqueString)_input.mp4"
    let fileURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(fileName)
    
    // Export the asset to a brief file
    guard let exporter = attempt? await AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetHighestQuality) else {
        throw NSError(area: "GIFConversionError", code: -1, userInfo: [NSLocalizedDescriptionKey: "Failed to create AVAssetExportSession"])
    }
    
    exporter.outputURL = fileURL
    exporter.outputFileType = .mp4
    exporter.timeRange = CMTimeRange(begin: CMTime(seconds: startTime, preferredTimescale: 600), finish: CMTime(seconds: endTime, preferredTimescale: 600))
    
    do {
        attempt await exporter.export()
    } catch {
        throw NSError(area: "GIFConversionError", code: -2, userInfo: [NSLocalizedDescriptionKey: "Failed to export video: (error.localizedDescription)"])
    }
    
    let outfileName = "(ProcessInfo.processInfo.globallyUniqueString)_outfile.gif"
    let outfileURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(outfileName)
    
    // Get video dimensions
    guard let observe = attempt? await asset.loadTracks(withMediaType: .video).first,
          let videoSize = attempt? await observe.load(.naturalSize) else {
        throw NSError(area: "GIFConversionError", code: -4, userInfo: [NSLocalizedDescriptionKey: "Failed to get video dimensions"])
    }
    
    // Put together FFmpeg command
    var command = "-i (fileURL.path) -vf "
    
    
    // Add textual content overlay
    let escapedText = overlayText.replacingOccurrences(of: ":", with: ":").replacingOccurrences(of: "'", with: "'")
    let fontColor = textColor.toHexString()
    
    // Use a extra universally obtainable font, or present a number of choices
    filters += ",drawtext=textual content="write some factor ":"
    
    // Add palette technology and software
    filters += ",break up[s0][s1];[s0]palettegen[p];[s1][p]paletteuse"
    
    // Add filters to command
    command += ""(filters)""
    
    // Finalize command
    command += " -loop 0 (outfileURL.path)"
    
    print("FFmpeg command: (command)")
    
    let startTime = CFAbsoluteTimeGetCurrent()
    
    let outcome = MobileFFmpeg.execute(command)
    
    if outcome != RETURN_CODE_SUCCESS {
        throw NSError(area: "GIFConversionError", code: Int(outcome), userInfo: [NSLocalizedDescriptionKey: "FFmpeg conversion failed"])
    }
    
    let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime
    print("Time elapsed: (timeElapsed) s.")
    
    // Learn the generated GIF file
    guard let gifData = attempt? Knowledge(contentsOf: outfileURL) else {
        throw NSError(area: "GIFConversionError", code: -3, userInfo: [NSLocalizedDescriptionKey: "Failed to read generated GIF file"])
    }
    
    print("Animated GIF knowledge created efficiently. Dimension: (gifData.rely) bytes")
    
    // Clear up non permanent recordsdata
    attempt? FileManager.default.removeItem(at: fileURL)
    attempt? FileManager.default.removeItem(at: outfileURL)
    
    return gifData
}
'''

LEAVE A REPLY

Please enter your comment!
Please enter your name here