1.1.5 • Published 2 years ago

compoze-media v1.1.5

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

基于FFCreatorLite库做了资源合成

  • 合成文字
  • 合成图片
  • 合成视频
  • 三种资源可以互相合成

Useage

npm i compoze-media
const MEDIAS: IMedia[] = [
    {
        type: IMediaType.TEXT,
        path: path.join(process.cwd(), "./assets/font/scsf.ttf"),
        text: "compoze text"
    },
    {
        type: IMediaType.VIDEO,
        path: path.join(process.cwd(), "./assets/video/video1.mp4"),
        config: {
            y: 30,
            audio: true
        }
    },
    {
        type: IMediaType.VIDEO,
        path: path.join(process.cwd(), "./assets/video/video2.mp4"),
        config: {
            y: 300,
            audio: false
        }
    }
]
new Compoze(MOCK_CREATOR_CONFIG, MEDIAS)

Description

  • Compoze的构造函数第一个参数为creator的配置,第二个参数是媒体资源数组
  • 有多个媒体资源,因此资源是个数组形式
  • CREATOR_CONFIG的所有配置
  • IMedia资源类型
export interface ICreatorConfig {
  width?: number // 宽
  height?: number // 高
  cacheDir?: string // 缓存的路径
  outputDir?: string //  输出资源的路径
  output?: string // 输出地址可以为直播流地址
  bgColor?: string // 背景颜色
}

export interface IMedia {
  type: IMediaType // 资源类型
  path?: string // 路径,文字为字体文件路径
  text?: string // 文字
  config?: IMediaConfig // 三种资源的独立配置
}

export enum IMediaType {
  TEXT = "text",
  IMAGE = "image",
  VIDEO = "video"
}

export interface IMediaConfig {
  w?: number // 图片宽
  h?: number // 图片高

  x?: number // 距离左上角的x轴坐标
  y?: number // 距离左上角的y轴坐标

  scale?: number //  图片视频的缩放比例

  color?: string // 文字颜色
  audio?: boolean // 视频资源是否播放声音(多个视频一般设置一个为true)
  animation?: { // 动画
    type: string // 动画方式(moveInRight)
    time: number // 动画时常
    delay: number // 延迟时间
  }
}
1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago