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
4
- 1Here is a similar question, please check it stackoverflow.com/questions/21925463/…Sebastian Corradi– Sebastian Corradi2017-09-26 19:49:57 +00:00Commented Sep 26, 2017 at 19:49
- Have u got any solutionR.Anjali– R.Anjali2018-03-03 10:22:23 +00:00Commented Mar 3, 2018 at 10:22
- how can access from Assets FFMPEGVasudev Vyas– Vasudev Vyas2019-08-07 05:00:48 +00:00Commented Aug 7, 2019 at 5:00
- Were you able to figure this out? Having the same issue where the fontfile is not being used to write the font, even though the path is pointing towards the assets folder.Dennis Ashford– Dennis Ashford2022-09-01 14:13:28 +00:00Commented Sep 1, 2022 at 14:13
Add a comment |
1 Answer
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;