BililiveRecorder/BililiveRecorder.Flv/Pipeline/Rules/RemoveFillerDataRule.cs
2022-05-02 00:01:41 +08:00

31 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using BililiveRecorder.Flv.Pipeline.Actions;
namespace BililiveRecorder.Flv.Pipeline.Rules
{
/// <summary>
/// 删除 H.264 Filler Data节省硬盘空间。
/// </summary>
public class RemoveFillerDataRule : ISimpleProcessingRule
{
public void Run(FlvProcessingContext context, Action next)
{
// 先运行下层规则
next();
// 处理下层规则返回的数据
context.Actions.ForEach(action =>
{
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;
}
}
}