public override void Start() { Pipe inp = new Pipe(PipeOut.Token); Pipe outp = new Pipe(PipeOut.Token); NodeToBits bitNode = new NodeToBits(inp, outp); //NodeBitsToBlock blockNode = new NodeBitsToBlock(opt, outp, Output); }
public void EncodeFile(string path, OptionsStruct opt) { _tokenSource = new CancellationTokenSource(); token.token = false; /* * OptionsStruct opt = new OptionsStruct(0); * opt.encodingPreset = EncodingPreset.medium; * opt.cellCount = 1; * opt.density = 4; * opt.isEncodingCRF = true; * opt.videoQuality = 20; * opt.pxlFmtIn = PixelFormat.YUV420P; * opt.pxlFmtOut = PixelFormat.YUV420P; * opt.resolution = ResolutionsEnum.p720; */ Monitor.CurrentWork = 0; string filename = Path.GetDirectoryName(path) + @"\" + Path.GetFileName(path) + @".mp4"; OptionsStruct headopt = opt; headopt.density = 1; headopt.cellCount = 1; List <ChainNode> nodes = new List <ChainNode>(); Pipe pipein = new Pipe(_tokenSource.Token); ChainNode node; node = new NodeReader(path, pipein, Monitor); nodes.Add(node); Pipe pipeout = pipein; pipein = new Pipe(_tokenSource.Token); node = new NodeECCEncoder(pipeout, pipein); nodes.Add(node); pipeout = pipein; pipein = new Pipe(_tokenSource.Token); node = new NodeToBits(pipeout, pipein); nodes.Add(node); pipeout = pipein; pipein = new Pipe(_tokenSource.Token); node = new NodeBitsToBlock(opt, pipeout, pipein, token); nodes.Add(node); Pipe pipebody = pipein; //HEADER START pipein = new Pipe(_tokenSource.Token); DataHeader.ToPipe(path, opt, pipein); pipeout = pipein; pipein = new Pipe(_tokenSource.Token); node = new NodeToBits(pipeout, pipein); nodes.Add(node); pipeout = pipein; pipein = new Pipe(_tokenSource.Token); node = new NodeBitsToBlock(headopt, pipeout, pipein, token); Pipe pipeheader = pipein; nodes.Add(node); //HEADER END var plist = new List <Pipe>(); plist.Add(pipeheader); plist.Add(pipebody); IPipe pipejoiner = new PipeJoiner(_tokenSource.Token, plist); pipein = new Pipe(_tokenSource.Token); node = new NodeBlocksToFrame(opt, pipejoiner, pipein); nodes.Add(node); pipeout = pipein; pipein = new Pipe(_tokenSource.Token); node = new NodeFrameToMP4(filename, opt, pipeout); //node = new NodeDebugRawStorage(pipeout, null); nodes.Add(node); Task.Run(() => { Parallel.ForEach(nodes, (n) => n.Start()); Monitor.Add(1); } , _tokenSource.Token ); }