MediaMaker 1.0.4
dotnet add package MediaMaker --version 1.0.4
NuGet\Install-Package MediaMaker -Version 1.0.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MediaMaker" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MediaMaker" Version="1.0.4" />
<PackageReference Include="MediaMaker" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MediaMaker --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MediaMaker, 1.0.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=MediaMaker&version=1.0.4
#tool nuget:?package=MediaMaker&version=1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
使用示例代码
using MediaMaker;
using System.Drawing;
//获取视频信息
var info1 = VideoMaker.MediaInfo(@"D:\Tencent\WeMeet\3.16.3.425\resources\raw\ringing_short.mp3");
var info2 = VideoMaker.MediaInfo(@"C:\Users\葛杰\Desktop\MediaTest\MediaTest\bin\Debug\net6.0\video.mp4", @"C:\Users\葛杰\Desktop\MediaTest\MediaTest\bin\Debug\net6.0\abdefa.jpg");
//获取字体信息
var fonts = VideoMaker.Fonts;
//定义模板
var template = new Template();
#region 添加图层
template.Pieces.Add(new PieceColor() { Width = 880, Height = 660, X = "150", Y = "100", Color = ColorTranslator.ToHtml(Color.Red) });
template.Pieces.Add(new PieceVideo() { Width = 1080 / 2, Height = 1920 / 2, X = "50", Y = "50", Url = @"E:\DATA\Resource\0\1_7401864882821369129_media_00.mp4", Alpha = 60, BoxBlur_LR = 2, BoxBlur_LP = 2, Hflip = true, Vflip = true, CropX = 500, CropY = 1000, CropWidth = 400, CropHeight = 800, Rotate = 20, CutOffset = 9, Offset = 7, Duration = 2, Volume = 10, InstanceID = "视频", });
template.Pieces.Add(new PieceImage() { Width = 800, Height = 600, X = "50", Y = "50", Alpha = 40, Url = @"C:\Users\葛杰\Desktop\data\Article\UploadFiles\202202\W020220215577858189643.jpg", InstanceID = "背景图片", Offset = 1f, Duration = 2, Effects = new List<IPieceEffect> { new Effect_FlyIn { Direction = FlyDirection.Up }, new Effect_FlyOut { Direction = FlyDirection.Down }, new Effect_FadeIn { Duration = 3 }, new Effect_FadeOut { Duration = 3 }, } });
//template.Pieces.Add(new PieceImage() { X = "20", Y = "0", Alpha = 40, Url = "1.gif", Offset = 7.5f, Duration = 15, Hflip = true, Vflip = true, BoxBlur_LR = 2, BoxBlur_LP = 2, Rotate = 45, CropX = 400, CropY = 200, CropWidth = 400, CropHeight = 200, Width = 300, Height = 250, InstanceID = "图片", });
template.Pieces.Add(new PieceColor() { Width = 600, Height = 200, X = "50", Y = "50", Alpha = 80, Color = ColorTranslator.ToHtml(Color.Green), Offset = 15, Duration = 12, BorderColor = ColorTranslator.ToHtml(Color.DarkGreen), BorderWidth = 2, InstanceID = "色块", });
template.Pieces.Add(new PieceText() { Width = 200, Height = 400, X = "200", Y = "400", Alpha = 100, Content = "深知每个人的生活需求都是独特的,因此生成模型注重用户体验和个性化定制.您可以根据自己的喜好和需求,自定义设置豆包的功能和界面,让它更符合您的个人风格", ForeColor = ColorTranslator.ToHtml(Color.OrangeRed), FontSize = 44, FontName = "幼圆", BackColor = ColorTranslator.ToHtml(Color.DarkRed), FontStyle = FontStyle.Underline, Offset = 3, Duration = 2, ShadowX = 5, ShadowY = 10, ShadowColor = ColorTranslator.ToHtml(Color.Green), BorderColor = ColorTranslator.ToHtml(Color.White), BorderWidth = 1, TextAlign = 10, BackWidth = 0, FontAlign = 1, LineSpacing = 0, InstanceID = "文字" });
template.Pieces.Add(new PieceAudio() { Url = @"D:\Tencent\WeMeet\3.16.3.425\resources\raw\ringing_short.mp3", Volume = 20, CutOffset = 1, Offset = 3, Duration = 2, InstanceID = "音频", Loop = -1 });
template.Pieces.Add(new PieceHtml() { X = "200", Y = "0", Alpha = 40, Url = "PieceHtml/index.html", Hflip = true, Vflip = true, BoxBlur_LR = 2, BoxBlur_LP = 2, Rotate = 45, CropX = 20, CropY = 10, CropWidth = 300, CropHeight = 500, Width = 300, Height = 250, InstanceID = "HTML", MethodName = "setrealtime", /*DataJson= "[{name: '站名',area: '大连',value: 35.9,unit: '℃',}]", OptionsJson= "{sort: 'dsc',key: 'value'}" */});
template.Pieces.Add(new PieceHtml() { X = "0", Y = "200", Alpha = 80, Url = "PieceHtml/index.html", Width = 300, Height = 250, InstanceID = "HTML", ApiUrl = "/api/test/dddd", MethodName = "setranking", DataJson = "[{name: '站名',area: '大连',value: 35.9,unit: '℃',}]", OptionsJson = "{sort: 'dsc',key: 'value'}" });
template.Pieces.Add(new PieceHtml() { X = "0", Y = "0", Alpha = 100, Url = "PieceHtml/index.html", Width = 300, Height = 300, InstanceID = "HTML", ApiUrl = "/api/test/dddd", MethodName = "serecharts", DataJson = null, OptionsJson = "{gifWidth: 300,gifHeight: 300}" });
template.Pieces.Add(new PieceGroup() { X = "600", Y = "600", Alpha = 100, Width = 600, Height = 600, TemplateID = "123", Offset = 1, Duration = 10, InstanceID = "Group", });
#endregion
//JSON解析与反解析
var json = template.ToJson();
var obj = Template.FromJson(json);
//应用模板并生成
var o = VideoMaker.Init()
.RootPath(string.Empty)
.SetReadTemplateFun(async id =>
{
//1、从数据库中读取模板内容为文本
//2、在此方法中需要对模板里的气象标签等变量进行处理
//if (json.Contains("$")) json = json.ApplyLabel();
//3、反序列化返回实体类
//以下为测试代码
var t = Template.FromJson(json);
t.Pieces.RemoveAll(d => d.Type == 9);
return t;
})
.ApplyTemplate(template)
.Output("test.mp4")
.Render();
Console.WriteLine(o.Arguments);
#模板定义
模板中定义的层共分为7种,分别是:
颜色0/文本1/图片2/音频3/视频4/HTML5/组件9
HTML类型的层,可参看nuget包内的PieceHtml
文件夹下的示例文件。
/*此文件为视频生成组件所使用的配置文件示例*/
{
//配置文件模板ID,可不填
"ID": 0,
//模板种类:0普通模板,1组件模板
"Type": 0,
//总时长。-1表示不限制
"Duration": -1,
//块配置,数组中自上而下为每个元素层,类似于PS中的图层,按索引越大越在上层
"Pieces": [
//色块图层:Type=0
{
/*层通用配置*/
//所属组件实例ID,可手动命名
"InstanceID": "色块",
//类型颜色0/文本1/图片2/音频3/视频4/HTML5/组件9,类型必须匹配
"Type": 0,
//X,距离左上角
"X": "150",
//Y,距离左上角
"Y": "100",
//宽
"Width": 880,
//高
"Height": 660,
//整体透明度
"Alpha": 100,
//时长偏移,默认不偏移,偏移只计算正向
"Offset": 0,
//时长,默认-1不考虑时长
"Duration": -1,
/*以下为该类型层独有的配置*/
//底色,默认透明
"Color": "Red",
//边框颜色,默认透明
"BorderColor": "Transparent",
//边框宽度,默认0
"BorderWidth": 0
},
//视频图层:Type=4
{
/*层通用配置*/
//所属组件实例ID,可手动命名
"InstanceID": "视频",
//类型颜色0/文本1/图片2/音频3/视频4/HTML5/组件9,类型必须匹配
"Type": 4,
//X,距离左上角
"X": "50",
//Y,距离左上角
"Y": "50",
//宽
"Width": 540,
//高
"Height": 960,
//整体透明度
"Alpha": 60,
//时长偏移,默认不偏移,偏移只计算正向
"Offset": 7,
//时长,默认-1不考虑时长
"Duration": 2,
/*以下为该类型层独有的配置*/
//文件路径,支持在线路径
"Url": "E:\\DATA\\Resource\\0\\1_7401864882821369129_media_00.mp4",
//裁剪左上角X
"CropX": 500,
//裁剪左上角Y
"CropY": 1000,
//裁剪宽度
"CropWidth": 400,
//裁剪高度
"CropHeight": 800,
//模糊半径
"BoxBlur_LR": 2,
//模糊次数
"BoxBlur_LP": 2,
//顺时针旋转角度
"Rotate": 20,
//水平反转
"Hflip": true,
//垂直反转
"Vflip": true,
//视频文件截取开始时间
"CutOffset": 9,
//视频文件截取时长
"CutDuration": -1,
//音量,默认100
"Volume": 10,
//循环次数:-1无限循环、0不循环、n循环次数
"Loop": 0,
//抠图颜色,默认为空表示不抠图
"ChromaKeyColor": null,
//抠图容差,默认0.01,最大1。
"ChromaKeySimilarity": 0.01
},
//图片图层:Type=2
{
/*层通用配置*/
//所属组件实例ID,可手动命名
"InstanceID": "图片",
//类型颜色0/文本1/图片2/音频3/视频4/HTML5/组件9,类型必须匹配
"Type": 2,
//X,距离左上角
"X": "50",
//Y,距离左上角
"Y": "50",
//宽
"Width": 800,
//高
"Height": 600,
//整体透明度
"Alpha": 40,
//时长偏移,默认不偏移,偏移只计算正向
"Offset": 1,
//时长,默认-1不考虑时长
"Duration": 2,
/*以下为该类型层独有的配置*/
//文件路径或BASE64,支持在线路径
"Url": "C:\\Users\\葛杰\\Desktop\\data\\Article\\UploadFiles\\202202\\W020220215577858189643.jpg",
//裁剪左上角X
"CropX": 0,
//裁剪左上角Y
"CropY": 0,
//裁剪宽度
"CropWidth": 0,
//裁剪高度
"CropHeight": 0,
//模糊半径
"BoxBlur_LR": 0,
//模糊次数
"BoxBlur_LP": 0,
//顺时针旋转角度
"Rotate": 0,
//水平反转
"Hflip": false,
//垂直反转
"Vflip": false,
//效果,目前支持图片图层及视频图层,可多个
"Effects": [
{
//效果名称:飞入
"Name": "FlyIn",
//效果时长
"Duration": 0.5,
//独有属性:飞入方向,支持Up\Down\Left\Right
"Direction": "Up"
},
{
"Duration": 0.5,
"Direction": "Down",
"Name": "FlyOut"
},
{
"Duration": 3,
"Name": "FadeIn"
},
{
"Duration": 3,
"Name": "FadeOut"
},
{
// 强调开始时间,以图层开始时间为起点,默认0
"Offset": 0,
"Duration": 3,
//强调类型,默认颤抖,支持ChanDou、TanHuang、TanRu、TiaoDong、YaoBai、YaoHuang、YuShuaLeft、YuShuaRight
//分别代表颤抖、弹簧、弹入、跳动、摇摆、摇晃、雨刷左、雨刷右
"Type": "",
"Name": "EM"
}
]
},
{
"Type": 0,
"Color": "Green",
"BorderColor": "DarkGreen",
"BorderWidth": 2,
"InstanceID": "色块",
"X": "50",
"Y": "50",
"Width": 600,
"Height": 200,
"Alpha": 80,
"Offset": 15,
"Duration": 12
},
//文字图层:Type=1
{
/*层通用配置*/
//所属组件实例ID,可手动命名
"InstanceID": "文字",
//类型颜色0/文本1/图片2/音频3/视频4/HTML5/组件9,类型必须匹配
"Type": 1,
//X,距离左上角
"X": "200",
//Y,距离左上角
"Y": "400",
//宽
"Width": 200,
//高
"Height": 400,
//整体透明度
"Alpha": 30,
//时长偏移,默认不偏移,偏移只计算正向
"Offset": 3,
//时长,默认-1不考虑时长
"Duration": 2,
/*以下为该类型层独有的配置*/
//底色,默认透明
"BackColor": "DarkRed",
//底色外扩宽度,默认0
"BackWidth": 0,
//字色,默认黑色
"ForeColor": "OrangeRed",
//文本内容
"Content": "深知每个人的生活需求都是独特的,因此生成模型注重用户体验和个性化定制.您可以根据自己的喜好和需求,自定义设置豆包的功能和界面,让它更符合您的个人风格",
//字体名或字体文件名,默认仿宋
"FontName": "幼圆",
//字体大小,默认16
"FontSize": 22,
//字体样式,暂不支持
"FontStyle": 4,
//文字包边/衬底宽度,默认为0
"BorderWidth": 1,
//文字包边/衬底颜色,默认透明
"BorderColor": "White",
//阴影偏移X,默认为0
"ShadowX": 5,
//阴影偏移Y,默认为0
"ShadowY": 10,
//阴影颜色,默认透明
"ShadowColor": "Green",
//文字布局:文字布局,LEFT = 1,RIGHT = 2,TOP = 4,BOTTOM = 8, CENTER = 3,MIDDLE = 12;默认-1
"TextAlign": 10,
//行间距,默认为0
"LineSpacing": 0,
//文字基线,0 text,1 baseline,2 font,默认-1
"FontAlign": 1,
// 文字换行模式,默认Standard。
// 0=Standard:【单词保持】默认行中断规则;
// 1=BreakAll:【中英文都截断】在任何两个字符间插入中断;
// 2=KeepAll:【中英文都保持,会溢出】中日韩不使用单词中断,其他与Standard相同;
// 3=BreakWord:【英文保持中文截断】按顺序使用Standard和BreakAll规则组合。
"WordBreak": 0,
},
//音频图层:Type=3
{
/*层通用配置*/
//所属组件实例ID,可手动命名
"InstanceID": "音频",
//类型颜色0/文本1/图片2/音频3/视频4/HTML5/组件9,类型必须匹配
"Type": 3,
//X,距离左上角
"X": "0",
//Y,距离左上角
"Y": "0",
//宽
"Width": 0,
//高
"Height": 0,
//整体透明度
"Alpha": 100,
//时长偏移,默认不偏移,偏移只计算正向
"Offset": 3,
//时长,默认-1不考虑时长
"Duration": 2,
/*以下为该类型层独有的配置*/
//文件路径,支持在线路径
"Url": "D:\\Tencent\\WeMeet\\3.16.3.425\\resources\\raw\\ringing_short.mp3",
//音频文件截取开始时间
"CutOffset": 1,
//音频文件截取时长
"CutDuration": -1,
//音量,默认100
"Volume": 20,
//循环次数:-1无限循环、0不循环、n循环次数,默认不循环
"Loop": -1
},
//HTML图层:Type=5
{
/*层通用配置*/
//所属组件实例ID,可手动命名
"InstanceID": "HTML",
//类型颜色0/文本1/图片2/音频3/视频4/HTML5/组件9,类型必须匹配
"Type": 5,
//X,距离左上角
"X": "200",
//Y,距离左上角
"Y": "0",
//宽
"Width": 300,
//高
"Height": 250,
//整体透明度
"Alpha": 40,
//时长偏移,默认不偏移,偏移只计算正向
"Offset": 0,
//时长,默认-1不考虑时长
"Duration": -1,
/*以下为该类型继承图片层独有的配置*/
//文件路径或BASE64,支持在线路径
//"Url": "PieceHtml/index.html",
//裁剪左上角X
"CropX": 20,
//裁剪左上角Y
"CropY": 10,
//裁剪宽度
"CropWidth": 300,
//裁剪高度
"CropHeight": 500,
//模糊半径
"BoxBlur_LR": 2,
//模糊次数
"BoxBlur_LP": 2,
//顺时针旋转角度
"Rotate": 45,
//水平反转
"Hflip": true,
//垂直反转
"Vflip": true,
/*以下为该类型层独有的配置*/
//HTML脚本文件地址
"Url": "PieceHtml/index.html",
//需要访问API的主机域名,如http://10.86.24.80
"ApiHost": null,
//需要访问API的地址,如:/api/Check
"ApiUrl": null,
//获取图片base64的JS方法
"MethodName": "setrealtime",
//需要传送的配置json
"OptionsJson": null,
//需要传送的数据
"DataJson": null
},
{
"Type": 5,
"ApiHost": null,
"ApiUrl": "/api/test/dddd",
"MethodName": "setranking",
"OptionsJson": "{sort: 'dsc',key: 'value'}",
"DataJson": "[{name: '站名',area: '大连',value: 35.9,unit: '℃',}]",
"Url": "PieceHtml/index.html",
"CropX": 0,
"CropY": 0,
"CropWidth": 0,
"CropHeight": 0,
"BoxBlur_LR": 0,
"BoxBlur_LP": 0,
"Rotate": 0,
"Hflip": false,
"Vflip": false,
"InstanceID": "HTML",
"X": "0",
"Y": "200",
"Width": 300,
"Height": 250,
"Alpha": 80,
"Offset": 0,
"Duration": -1
},
{
"Type": 5,
"ApiHost": null,
"ApiUrl": "/api/test/dddd",
"MethodName": "serecharts",
"OptionsJson": "{gifWidth: 300,gifHeight: 300}",
"DataJson": null,
"Url": "PieceHtml/index.html",
"CropX": 0,
"CropY": 0,
"CropWidth": 0,
"CropHeight": 0,
"BoxBlur_LR": 0,
"BoxBlur_LP": 0,
"Rotate": 0,
"Hflip": false,
"Vflip": false,
"InstanceID": "HTML",
"X": "0",
"Y": "0",
"Width": 300,
"Height": 300,
"Alpha": 100,
"Offset": 0,
"Duration": -1
},
//组件图层:Type=9
{
/*层通用配置*/
//所属组件实例ID,可手动命名
"InstanceID": "组件",
//类型颜色0/文本1/图片2/音频3/视频4/HTML5/组件9,类型必须匹配
"Type": 9,
//X,距离左上角
"X": "0",
//Y,距离左上角
"Y": "0",
//宽,默认为-1,表示不限制/缩放
"Width": 300,
//高,默认为-1,表示不限制/缩放
"Height": 300,
//整体透明度
"Alpha": 90,
//时长偏移,默认不偏移,偏移只计算正向
"Offset": 1,
//时长,默认-1不考虑时长
"Duration": 3,
/*以下为该类型层独有的配置*/
//所属组件ID
"TemplateID": "1"
}
]
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- FFmpegArgs (>= 2.0.0)
- FFmpegArgs.Executes (>= 2.0.2)
- FFmpegArgs.Filters (>= 2.0.1)
- FFmpegArgs.Filters.Common (>= 2.0.0)
- FFmpegArgs.Filters.Generated (>= 2.0.0)
- FFmpegArgs.Inputs (>= 2.0.0)
- FFmpegArgs.Outputs (>= 2.0.0)
- MediaMaker.FFmpeg.Bin (>= 1.0.3)
- PuppeteerSharp (>= 20.1.3)
- SixLabors.Fonts (>= 2.1.2)
- System.Drawing.Common (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.