BililiveRecorder/BililiveRecorder.Flv/Pipeline/Rules/RemoveFillerDataRule.cs

31 lines
1.0 KiB
C#
Raw Normal View History

2021-02-08 16:51:19 +08:00
using System;
using BililiveRecorder.Flv.Pipeline.Actions;
2021-02-08 16:51:19 +08:00
namespace BililiveRecorder.Flv.Pipeline.Rules
{
/// <summary>
2022-05-02 00:01:41 +08:00
/// 删除 H.264 Filler Data节省硬盘空间。
2021-02-08 16:51:19 +08:00
/// </summary>
public class RemoveFillerDataRule : ISimpleProcessingRule
{
2021-03-09 00:50:13 +08:00
public void Run(FlvProcessingContext context, Action next)
2021-02-08 16:51:19 +08:00
{
// 先运行下层规则
2021-03-09 00:50:13 +08:00
next();
2021-02-08 16:51:19 +08:00
// 处理下层规则返回的数据
2021-03-09 00:50:13 +08:00
context.Actions.ForEach(action =>
2021-02-08 16:51:19 +08:00
{
if (action is PipelineDataAction dataAction)
foreach (var tag in dataAction.Tags)
if (tag.Nalus != null)
// 虽然这里处理的是 Output 但是因为与 Input 共享同一个 object 所以会把 Input 一起改掉
// tag.Nalus = tag.Nalus.Where(x => x.Type != H264NaluType.FillerData).ToList();
tag.Nalus.RemoveAll(x => x.Type == H264NaluType.FillerData);
});
return;
}
}
}