简体   繁体   中英

How to set Fontfile From assets folder in ffmpeg (android studio)

I want to set font file in ffmpegn from assets folder in android. Can someone suggest me how can i do that. Following is my drawtext command :- drawtext=fontsize=60:fontfile=/system/fonts/DroidSans.ttf:fontcolor=green:text=Post:x=150:y=150

Write file by loading asset data as bytes

final filename = 'font.ttf';
var bytes = await rootBundle
    .load("packages/flutter_video_editor/assets/font/aller.ttf");

String dir = (await getApplicationDocumentsDirectory()).path;
final path = '$dir/$filename';

final buffer = bytes.buffer;
await File(path).writeAsBytes(
    buffer.asUint8List(bytes.offsetInBytes, bytes.lengthInBytes));

File file = File('$dir/$filename');

print('Loaded file ${file.path}');
_flutterFFmpegConfig.setFontDirectory(file.path, null);

return file.path;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM