mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-12-27 12:35:35 +08:00
93781b2a56
(I guess)
37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using System;
|
|
using BililiveRecorder.Flv.Pipeline.Actions;
|
|
|
|
namespace BililiveRecorder.Flv.Pipeline.Rules
|
|
{
|
|
/// <summary>
|
|
/// 删除 H.264 Filler Data
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// 部分直播码率瞎填的主播的直播数据中存在大量无用的 Filler Data<br/>
|
|
/// 录制这些主播时删除这些数据可以节省硬盘空间<br/>
|
|
/// <br/>
|
|
/// 本规则应该放在一般规则前面
|
|
/// </remarks>
|
|
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;
|
|
}
|
|
}
|
|
}
|