add_text.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //创建文字内容
  2. const { v4: uuidv4 } = require('uuid');
  3. //增加一个文字轨道 ,返回内容和轨道ID
  4. // type 值 text 文字
  5. // video 视频
  6. // effect 特效
  7. // audio 音频
  8. // 返回新的草稿内容和轨道ID
  9. async function add_text(draft_content,content){
  10. let text = {
  11. "add_type": 2,
  12. "alignment": 1,
  13. "background_alpha": 1.0,
  14. "background_color": "",
  15. "background_height": 0.14,
  16. "background_horizontal_offset": 0.0,
  17. "background_round_radius": 0.0,
  18. "background_style": 0,
  19. "background_vertical_offset": 0.0,
  20. "background_width": 0.14,
  21. "base_content": "",
  22. "bold_width": 0.0,
  23. "border_alpha": 1.0,
  24. "border_color": "",
  25. "border_width": 0.08,
  26. "caption_template_info": {
  27. "category_id": "",
  28. "category_name": "",
  29. "effect_id": "",
  30. "is_new": false,
  31. "path": "",
  32. "request_id": "",
  33. "resource_id": "",
  34. "resource_name": "",
  35. "source_platform": 0
  36. },
  37. "check_flag": 7,
  38. "combo_info": {
  39. "text_templates": []
  40. },
  41. "content": "<useLetterColor><size=15><color=(1,1,1,1)>[" + content + "]</color></size></useLetterColor>" ,
  42. "fixed_height": -1.0,
  43. "fixed_width": -1.0,
  44. "font_category_id": "",
  45. "font_category_name": "",
  46. "font_id": "",
  47. "font_name": "",
  48. "font_path": "/Applications/VideoFusion-macOS.app/Contents/Resources/Font/SystemFont/zh-hans.ttf",
  49. "font_resource_id": "",
  50. "font_size": 15.0,
  51. "font_source_platform": 0,
  52. "font_team_id": "",
  53. "font_title": "none",
  54. "font_url": "",
  55. "fonts": [],
  56. "force_apply_line_max_width": false,
  57. "global_alpha": 1.0,
  58. "group_id": "",
  59. "has_shadow": false,
  60. "id": uuidv4(),
  61. "initial_scale": 1.0,
  62. "inner_padding": -1.0,
  63. "is_rich_text": true,
  64. "italic_degree": 0,
  65. "ktv_color": "",
  66. "language": "",
  67. "layer_weight": 1,
  68. "letter_spacing": 0.0,
  69. "line_feed": 1,
  70. "line_max_width": 0.82,
  71. "line_spacing": 0.02,
  72. "multi_language_current": "none",
  73. "name": "",
  74. "original_size": [],
  75. "preset_category": "",
  76. "preset_category_id": "",
  77. "preset_has_set_alignment": false,
  78. "preset_id": "",
  79. "preset_index": 0,
  80. "preset_name": "",
  81. "recognize_task_id": "",
  82. "recognize_type": 0,
  83. "relevance_segment": [],
  84. "shadow_alpha": 0.9,
  85. "shadow_angle": -45.0,
  86. "shadow_color": "",
  87. "shadow_distance": 5.0,
  88. "shadow_point": {
  89. "x": 0.6363961030678928,
  90. "y": -0.6363961030678927
  91. },
  92. "shadow_smoothing": 0.45,
  93. "shape_clip_x": false,
  94. "shape_clip_y": false,
  95. "source_from": "",
  96. "style_name": "",
  97. "sub_type": 0,
  98. "subtitle_keywords": null,
  99. "subtitle_template_original_fontsize": 0.0,
  100. "text_alpha": 1.0,
  101. "text_color": "#ffde00",
  102. "text_curve": null,
  103. "text_preset_resource_id": "",
  104. "text_size": 30,
  105. "text_to_audio_ids": [],
  106. "tts_auto_update": false,
  107. "type": "subtitle",
  108. "typesetting": 0,
  109. "underline": false,
  110. "underline_offset": 0.22,
  111. "underline_width": 0.05,
  112. "use_effect_default_color": false,
  113. "words": {
  114. "end_time": [],
  115. "start_time": [],
  116. "text": []
  117. }
  118. };
  119. draft_content.materials.texts.push(text);
  120. return text
  121. }
  122. module.exports = { add_text };