短视频常用功能

本文介绍用智能媒体生产ICE合成短视频常见特效。

以下为智能媒体生产的基础能力,用户可以将多个效果组合使用。

每种示例只提供了Timeline,调用提交剪辑合成作业接口,传入Timeline合成自己的视频。

更多Timeline配置,参考Timeline配置说明

更多Timeline示例,参考多视频混剪TimeLine配置示例

本文档中用到的视频素材:20220321145102

视频横转竖-补充上下黑边

时间线中的素材为横屏视频,在提交合成任务时设置成片视频为竖屏尺寸,ICE即可根据素材和成片的尺寸,将素材居中展示。设置成片视频尺寸参考OutputMediaConfig 参数示例

效果

时间线

{
  "VideoTracks": [{
    "VideoTrackClips": [{
      "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video1.mp4"
    },{
      "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video2.mp4"
    },{
      "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video3.mp4"
    }]
  }]
}

视频横转竖-补充上下模糊区域

时间线中的素材为横屏视频,在提交合成任务时设置成片视频为竖屏尺寸,按照下面Timeline设置Pad效果,ICE即可根据素材和成片的尺寸,将素材居中展示,不足部分补充模糊效果。设置成片视频尺寸参考OutputMediaConfig 参数示例

效果

时间线

{
 "VideoTracks": [{
  "VideoTrackClips": [{
   "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video1.mp4",
   "Effects": [{
    "Type": "Background",
    "SubType": "Blur",
    "Radius": 0.1
   }]
  }, {
   "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video2.mp4",
   "Effects": [{
    "Type": "Background",
    "SubType": "Blur",
    "Radius": 0.1
   }]
  }, {
   "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video3.mp4",
   "Effects": [{
    "Type": "Background",
    "SubType": "Blur",
    "Radius": 0.1
   }]
  }]
 }]
}

添加字幕

当TimelineIn、TimelineOut未设置时,默认字幕从第0秒展示到视频结束,可用来设置全局字幕效果。

Timeline

{
 "VideoTracks": [{
  "VideoTrackClips": [{
   "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video1.mp4"
  }, {
   "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video2.mp4"
  }, {
   "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video3.mp4"
  }]
 }],
 "SubtitleTracks": [{
  "SubtitleTrackClips": [{
    "Type": "Text",
    "X": 0,
    "Y": 200,
    "Font": "AlibabaPuHuiTi",
    "Content": "这里是标题",
    "Alignment": "TopCenter",
    "FontSize": 80,
    "FontColorOpacity": 1,
    "FontColor": "#ffffff",
    "FontFace": {
     "Bold": true,
     "Italic": false,
     "Underline": false
    }
   },
   {
    "Type": "Text",
    "X": 0,
    "Y": 320,
    "Font": "KaiTi",
    "Content": "这里是副标题",
    "Alignment": "TopCenter",
    "FontSize": 45,
    "FontColor": "#ffffff",
    "FontFace": {
     "Bold": false,
     "Italic": true,
     "Underline": true
    }
   },
   {
    "Type": "Text",
    "X": 50,
    "Y": 740,
    "Font": "AlibabaPuHuiTi",
    "Content": "角度旋转",
    "FontColor": "#FFD700",
    "Outline": 4,
    "Angle": 350,
    "OutlineColour": "#000000",
    "FontSize": 60,
    "FontFace": {
     "Bold": true,
     "Italic": false,
     "Underline": false
    }
   },
   {
    "Type": "Text",
    "X": 0,
    "Y": 900,
    "Font": "AlibabaPuHuiTi",
    "Content": "这里是横幅字幕\n可以加换行符进行多行展示",
    "Alignment": "TopCenter",
    "FontSize": 40,
    "FontColor": "#ffffff",
    "FontFace": {
     "Bold": true,
     "Italic": false,
     "Underline": false
    }
   },
   {
    "Type": "Text",
    "X": 0,
    "Y": 1000,
    "Font": "KaiTi",
    "Content": "设置字幕出入场时间",
    "Alignment": "TopCenter",
    "FontSize": 40,
    "FontColor": "#ffffff",
    "TimelineIn": 5,
    "TimelineOut": 25,
    "FontFace": {
     "Bold": false,
     "Italic": true,
     "Underline": false
    }
   }
  ]
 }]
}

字幕添加描边、阴影效果

更多字幕参数设置,参考SubtitleTrackClip

效果

Timeline

{
  "VideoTracks": [{
    "VideoTrackClips": [{
      "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video4.mp4"
    }]
  }],
  "SubtitleTracks":[
    {
      "SubtitleTrackClips":[
        {
          "Type":"Text",
          "X": 0,
          "Y": 210,
          "Font": "WenQuanYi Zen Hei Mono",
          "Content": "这里是副标题",
          "Alignment": "TopCenter",
          "FontSize": 50,
          "FontColor": "#000000",
          "TimelineIn": 0,
          "TimelineOut": 10,
          "OutlineColour": "#ffffff",
          "Outline": 2,
          "FontFace": {
            "Bold": false,
            "Italic": false,
            "Underline": false
          }
        },
        {
          "Type":"Text",
          "X": 0,
          "Y": 270,
          "Font": "WenQuanYi Zen Hei Mono",
          "Content": "这里是标题",
          "Alignment": "TopCenter",
          "OutlineColour": "#000000",
          "Outline": 3,
          "FontSize": 70,
          "TimelineIn": 0,
          "TimelineOut": 10,
          "FontColor": "#ffffff",
          "FontFace": {
            "Bold": true,
            "Italic": false,
            "Underline": false
          }
        },
        {
          "Type": "Text",
          "Y": 750,
          "Font": "AlibabaPuHuiTi",
          "Content": "这里是大标题",
          "Alignment": "TopCenter",
          "FontSize": 100,
          "FontColor": "#FFD700",
          "Outline": 4,
          "OutlineColour": "#000000",
          "TimelineIn": 0,
          "TimelineOut": 10,
          "FontFace": {
            "Bold": true,
            "Italic": false,
            "Underline": false
          }
        },
        {
          "Type": "Text",
          "Y": 850,
          "Content": "自定义字体文件",
          "Font": "KaiTi",
          "FontSize": 42,
          "Outline": 2,
          "OutlineColour": "#ee00ff",
          "FontUrl":"https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_font.ttf",
          "TimelineIn": 0,
          "TimelineOut": 10,
          "Alignment": "TopCenter",
          "FontColor": "#000000",
          "FontFace": {
            "Bold": false,
            "Italic": false,
            "Underline": false
          }
        },
        {
          "Type": "Text",
          "Y": 900,
          "Font": "WenQuanYi Zen Hei Mono",
          "Content": "阴影效果",
          "FontColor": "#ffffff",
          "FontSize": 40,
          "Outline": 2,
          "OutlineColour": "#DB7093",
          "Shadow": 3,
          "BackColour": "#FFF0F5",
          "TimelineIn": 0,
          "TimelineOut": 10,
          "Alignment": "TopCenter",
          "FontFace": {
            "Bold": false,
            "Italic": false,
            "Underline": false
          }
        },
        {
          "Type": "Text",
          "Y": 980,
          "Font": "WenQuanYi Zen Hei Mono",
          "Content": "添加字幕动画",
          "FontColor": "#ffffff",
          "FontSize": 50,
          "TimelineIn": 0,
          "TimelineOut": 10,
          "Alignment": "TopCenter",
          "AaiMotionLoopEffect": "rollleft_display",
          "FontFace": {
            "Bold": true,
            "Italic": false,
            "Underline": false
          }
        }
      ]
    }
  ]
}

添加Gif贴纸

目前使用Gif贴纸还需设置DyncFrames,为动图的帧率。

效果

Timeline

{
  "VideoTracks": [{
    "VideoTrackClips": [{
      "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video1.mp4"
    },{
      "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video2.mp4"
    },{
      "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video3.mp4"
    }]
  },{
    "VideoTrackClips": [{
      "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_sticker1.gif",
      "Type": "image",
      "Duration": 10,
      "TimelineIn": 0,
      "DyncFrames": 10,
      "X": 50,
      "Y": 1300,
      "Effects": [{
        "Type": "Scale",
        "Width": 200,
        "Height": 200
      }]
    },{
      "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_sticker2.gif",
      "Type": "image",
      "Duration": 10,
      "TimelineIn": 10,
      "DyncFrames": 10,
      "X": 800,
      "Y": 400,
      "Effects": [{
        "Type": "Scale",
        "Width": 200,
        "Height": 200
      }]
    },{
      "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_sticker3.gif",
      "Type": "image",
      "Duration": 10,
      "TimelineIn": 20,
      "DyncFrames": 10,
      "X": 100,
      "Y": 400,
      "Effects": [{
        "Type": "Scale",
        "Width": 200,
        "Height": 200
      }]
    }]
  }]
}

对视频进行语音识别,并将字幕合成到视频中

AI_ASR作用在一个片段中,可根据业务需求对时间线中的多个视频片段进行语音识别。

也可给音频轨添加AI_ASR效果, 同步设置字幕的样式,如字体、颜色等,参数详见Effect Type:AI_ASR

{
  "VideoTracks": [{
    "VideoTrackClips": [{
      "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video7.mp4",
      "Effects": [{
        "Type": "AI_ASR",
        "Font": "AlibabaPuHuiTi",
        "Alignment": "TopCenter",
        "Y": 910,
        "Outline": 10,
        "OutlineColour": "#ffffff",
        "FontSize": 60,
        "FontColor": "#000079",
        "FontFace": {
          "Bold": true,
          "Italic": false,
          "Underline": false
        }
      }]
    }]
  }]
}

文字转语音,并合成到视频中

添加音频片段,设置Type为AI_TTS,Content为要转化的文字,即可进行文字转语音,并合成到视频中。

可以设置Voice、SpeechRate、PitchRate、Format等,参数详见音频轨素材直接由文字转化生成

可与AI_ASR共用,将生成的语音转换为字幕,合成到视频中。

{
  "VideoTracks": [{
    "VideoTrackClips": [{
      "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video3.mp4",
      "Effects": [{
        "Type":"Volume",
        "Gain":0
      }]
    }]
  }],
  "AudioTracks": [{
    "AudioTrackClips": [{
      "Type": "AI_TTS",
      "Content": "君不见黄河之水天上来,奔流到海不复回。君不见高堂明镜悲白发,朝如青丝暮成雪。",
      "Voice": "sicheng",
      "Effects": [{
        "Type": "AI_ASR",
        "Font": "AlibabaPuHuiTi",
        "Alignment": "TopCenter",
        "Y": 900,
        "FontSize": 80,
        "FontColor": "#ffffff",
        "FontFace": {
          "Bold": true,
          "Italic": false,
          "Underline": false
        }
      },{
        "Type":"Volume",
        "Gain":10
      }]
    }]
  }]
}

全局特效、滤镜

当需要为整个成片添加滤镜、特效时,可以在EffectTrack中添加一个特效,无需设置TimelineIn、TimelineOut,合成时会将特效从第0秒渲染至视频结束,方便配置一些全局特效。

Timeline

{
 "VideoTracks": [{
  "VideoTrackClips": [{
   "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video1.mp4"
  }, {
   "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video2.mp4"
  }, {
   "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_video3.mp4"
  }]
 }],
 "EffectTracks": [{
  "EffectTrackItems": [{
   "Type": "Filter",
   "SubType": "PL2"
  }]
 }]
}
阿里云首页 智能媒体服务 相关技术圈