feat(core): add option to omit stream metadata

This commit is contained in:
genteure 2023-02-01 19:14:53 +08:00
parent 7640a865e3
commit 6376c9ac4f
7 changed files with 57 additions and 1 deletions

View File

@ -26,6 +26,7 @@ namespace BililiveRecorder.Cli.Configure
RecordingQuality,
FileNameRecordTemplate,
FlvProcessorSplitOnScriptTag,
FlvWriteMetadata,
WebHookUrls,
WebHookUrlsV2,
WpfShowTitleAndArea,
@ -82,6 +83,7 @@ namespace BililiveRecorder.Cli.Configure
GlobalConfig.Add(GlobalConfigProperties.RecordingQuality, new ConfigInstruction<GlobalConfig, string>(config => config.HasRecordingQuality = false, (config, value) => config.RecordingQuality = value) { Name = "RecordingQuality", CanBeOptional = true });
GlobalConfig.Add(GlobalConfigProperties.FileNameRecordTemplate, new ConfigInstruction<GlobalConfig, string>(config => config.HasFileNameRecordTemplate = false, (config, value) => config.FileNameRecordTemplate = value) { Name = "FileNameRecordTemplate", CanBeOptional = true });
GlobalConfig.Add(GlobalConfigProperties.FlvProcessorSplitOnScriptTag, new ConfigInstruction<GlobalConfig, bool>(config => config.HasFlvProcessorSplitOnScriptTag = false, (config, value) => config.FlvProcessorSplitOnScriptTag = value) { Name = "FlvProcessorSplitOnScriptTag", CanBeOptional = true });
GlobalConfig.Add(GlobalConfigProperties.FlvWriteMetadata, new ConfigInstruction<GlobalConfig, bool>(config => config.HasFlvWriteMetadata = false, (config, value) => config.FlvWriteMetadata = value) { Name = "FlvWriteMetadata", CanBeOptional = true });
GlobalConfig.Add(GlobalConfigProperties.WebHookUrls, new ConfigInstruction<GlobalConfig, string>(config => config.HasWebHookUrls = false, (config, value) => config.WebHookUrls = value) { Name = "WebHookUrls", CanBeOptional = true });
GlobalConfig.Add(GlobalConfigProperties.WebHookUrlsV2, new ConfigInstruction<GlobalConfig, string>(config => config.HasWebHookUrlsV2 = false, (config, value) => config.WebHookUrlsV2 = value) { Name = "WebHookUrlsV2", CanBeOptional = true });
GlobalConfig.Add(GlobalConfigProperties.WpfShowTitleAndArea, new ConfigInstruction<GlobalConfig, bool>(config => config.HasWpfShowTitleAndArea = false, (config, value) => config.WpfShowTitleAndArea = value) { Name = "WpfShowTitleAndArea", CanBeOptional = true });

View File

@ -122,6 +122,11 @@ namespace BililiveRecorder.Core.Config.V3
/// </summary>
public string? FileNameRecordTemplate => this.GetPropertyValue<string>();
/// <summary>
/// 是否在视频文件写入直播信息 metadata
/// </summary>
public bool FlvWriteMetadata => this.GetPropertyValue<bool>();
/// <summary>
/// WebhookV1
/// </summary>
@ -313,6 +318,14 @@ namespace BililiveRecorder.Core.Config.V3
[JsonProperty(nameof(FlvProcessorSplitOnScriptTag)), EditorBrowsable(EditorBrowsableState.Never)]
public Optional<bool> OptionalFlvProcessorSplitOnScriptTag { get => this.GetPropertyValueOptional<bool>(nameof(this.FlvProcessorSplitOnScriptTag)); set => this.SetPropertyValueOptional(value, nameof(this.FlvProcessorSplitOnScriptTag)); }
/// <summary>
/// 是否在视频文件写入直播信息 metadata
/// </summary>
public bool FlvWriteMetadata { get => this.GetPropertyValue<bool>(); set => this.SetPropertyValue(value); }
public bool HasFlvWriteMetadata { get => this.GetPropertyHasValue(nameof(this.FlvWriteMetadata)); set => this.SetPropertyHasValue<bool>(value, nameof(this.FlvWriteMetadata)); }
[JsonProperty(nameof(FlvWriteMetadata)), EditorBrowsable(EditorBrowsableState.Never)]
public Optional<bool> OptionalFlvWriteMetadata { get => this.GetPropertyValueOptional<bool>(nameof(this.FlvWriteMetadata)); set => this.SetPropertyValueOptional(value, nameof(this.FlvWriteMetadata)); }
/// <summary>
/// WebhookV1
/// </summary>
@ -488,6 +501,8 @@ namespace BililiveRecorder.Core.Config.V3
public bool FlvProcessorSplitOnScriptTag => false;
public bool FlvWriteMetadata => true;
public string WebHookUrls => @"";
public string WebHookUrlsV2 => @"";

View File

@ -229,6 +229,9 @@ namespace BililiveRecorder.Core.Recording
private void Writer_BeforeScriptTagWrite(ScriptTagBody scriptTagBody)
{
if (!this.room.RoomConfig.FlvWriteMetadata)
return;
if (scriptTagBody.Values.Count == 2 && scriptTagBody.Values[1] is ScriptDataEcmaArray value)
{
var now = DateTimeOffset.Now;

View File

@ -15,7 +15,7 @@
xmlns:configv3="clr-namespace:BililiveRecorder.Core.Config.V3;assembly=BililiveRecorder.Core"
xmlns:model="clr-namespace:BililiveRecorder.WPF.Models"
mc:Ignorable="d"
d:DesignHeight="1500" d:DesignWidth="500"
d:DesignHeight="2500" d:DesignWidth="500"
DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:RootPage},Path=DataContext.Recorder.Config.Global}"
Title="SettingsPage">
<ui:Page.Resources>
@ -75,6 +75,13 @@
</StackPanel>
</c:SettingWithDefault>
</GroupBox>
<GroupBox Header="录制">
<ui:SimpleStackPanel Spacing="10">
<c:SettingWithDefault IsSettingNotUsingDefault="{Binding HasFlvWriteMetadata}">
<ui:ToggleSwitch IsOn="{Binding FlvWriteMetadata}" OnContent="在视频文件写入直播信息 metadata" OffContent="在视频文件写入直播信息 metadata"/>
</c:SettingWithDefault>
</ui:SimpleStackPanel>
</GroupBox>
<GroupBox Header="Network">
<StackPanel>
<CheckBox IsChecked="{Binding Path=NetworkTransportUseSystemProxy}" Content="使用系统代理"/>

View File

@ -56,6 +56,7 @@ namespace BililiveRecorder.Web.Models
public Optional<string?>? OptionalRecordingQuality { get; set; }
public Optional<string?>? OptionalFileNameRecordTemplate { get; set; }
public Optional<bool>? OptionalFlvProcessorSplitOnScriptTag { get; set; }
public Optional<bool>? OptionalFlvWriteMetadata { get; set; }
public Optional<string?>? OptionalWebHookUrls { get; set; }
public Optional<string?>? OptionalWebHookUrlsV2 { get; set; }
public Optional<bool>? OptionalWpfShowTitleAndArea { get; set; }
@ -89,6 +90,7 @@ namespace BililiveRecorder.Web.Models
if (this.OptionalRecordingQuality.HasValue) config.OptionalRecordingQuality = this.OptionalRecordingQuality.Value;
if (this.OptionalFileNameRecordTemplate.HasValue) config.OptionalFileNameRecordTemplate = this.OptionalFileNameRecordTemplate.Value;
if (this.OptionalFlvProcessorSplitOnScriptTag.HasValue) config.OptionalFlvProcessorSplitOnScriptTag = this.OptionalFlvProcessorSplitOnScriptTag.Value;
if (this.OptionalFlvWriteMetadata.HasValue) config.OptionalFlvWriteMetadata = this.OptionalFlvWriteMetadata.Value;
if (this.OptionalWebHookUrls.HasValue) config.OptionalWebHookUrls = this.OptionalWebHookUrls.Value;
if (this.OptionalWebHookUrlsV2.HasValue) config.OptionalWebHookUrlsV2 = this.OptionalWebHookUrlsV2.Value;
if (this.OptionalWpfShowTitleAndArea.HasValue) config.OptionalWpfShowTitleAndArea = this.OptionalWpfShowTitleAndArea.Value;
@ -144,6 +146,7 @@ namespace BililiveRecorder.Web.Models.Rest
public Optional<string?> OptionalRecordingQuality { get; set; }
public Optional<string?> OptionalFileNameRecordTemplate { get; set; }
public Optional<bool> OptionalFlvProcessorSplitOnScriptTag { get; set; }
public Optional<bool> OptionalFlvWriteMetadata { get; set; }
public Optional<string?> OptionalWebHookUrls { get; set; }
public Optional<string?> OptionalWebHookUrlsV2 { get; set; }
public Optional<bool> OptionalWpfShowTitleAndArea { get; set; }
@ -204,6 +207,7 @@ namespace BililiveRecorder.Web.Models.Graphql
this.Field(x => x.OptionalRecordingQuality, type: typeof(HierarchicalOptionalType<string>));
this.Field(x => x.OptionalFileNameRecordTemplate, type: typeof(HierarchicalOptionalType<string>));
this.Field(x => x.OptionalFlvProcessorSplitOnScriptTag, type: typeof(HierarchicalOptionalType<bool>));
this.Field(x => x.OptionalFlvWriteMetadata, type: typeof(HierarchicalOptionalType<bool>));
this.Field(x => x.OptionalWebHookUrls, type: typeof(HierarchicalOptionalType<string>));
this.Field(x => x.OptionalWebHookUrlsV2, type: typeof(HierarchicalOptionalType<string>));
this.Field(x => x.OptionalWpfShowTitleAndArea, type: typeof(HierarchicalOptionalType<bool>));
@ -241,6 +245,7 @@ namespace BililiveRecorder.Web.Models.Graphql
this.Field(x => x.RecordingQuality);
this.Field(x => x.FileNameRecordTemplate);
this.Field(x => x.FlvProcessorSplitOnScriptTag);
this.Field(x => x.FlvWriteMetadata);
this.Field(x => x.WebHookUrls);
this.Field(x => x.WebHookUrlsV2);
this.Field(x => x.WpfShowTitleAndArea);
@ -297,6 +302,7 @@ namespace BililiveRecorder.Web.Models.Graphql
this.Field(x => x.OptionalRecordingQuality, nullable: true, type: typeof(HierarchicalOptionalInputType<string>));
this.Field(x => x.OptionalFileNameRecordTemplate, nullable: true, type: typeof(HierarchicalOptionalInputType<string>));
this.Field(x => x.OptionalFlvProcessorSplitOnScriptTag, nullable: true, type: typeof(HierarchicalOptionalInputType<bool>));
this.Field(x => x.OptionalFlvWriteMetadata, nullable: true, type: typeof(HierarchicalOptionalInputType<bool>));
this.Field(x => x.OptionalWebHookUrls, nullable: true, type: typeof(HierarchicalOptionalInputType<string>));
this.Field(x => x.OptionalWebHookUrlsV2, nullable: true, type: typeof(HierarchicalOptionalInputType<string>));
this.Field(x => x.OptionalWpfShowTitleAndArea, nullable: true, type: typeof(HierarchicalOptionalInputType<bool>));

View File

@ -22,6 +22,22 @@
}
}
},
"FlvWriteMetadata": {
"description": "是否在视频文件写入直播信息 metadata\n默认: true",
"markdownDescription": "是否在视频文件写入直播信息 metadata \n默认: `true `\n\n",
"type": "object",
"additionalProperties": false,
"properties": {
"HasValue": {
"type": "boolean",
"default": true
},
"Value": {
"type": "boolean",
"default": true
}
}
},
"WebHookUrls": {
"description": "WebhookV1\n默认: ",
"markdownDescription": "WebhookV1 \n默认: ` `\n\n",

View File

@ -100,6 +100,13 @@ export const data: Array<ConfigEntry> = [
configType: "room",
default: false
},
{
id: "FlvWriteMetadata",
name: "是否在视频文件写入直播信息 metadata",
type: "bool",
configType: "globalOnly",
default: true
},
{
id: "WebHookUrls",
name: "WebhookV1",