コード例 #1
0
ファイル: FFMpeg.cs プロジェクト: regeszter/MPExtended
        public virtual void BuildPipeline()
        {
            // add input
            bool doInputReader = Context.NeedsInputReaderUnit;

            if (doInputReader)
            {
                Context.Pipeline.AddDataUnit(Context.GetInputReaderUnit(), 1);
            }

            string arguments = GenerateArguments();

            // fix input thing
            if (!doInputReader)
            {
                arguments = arguments.Replace("#IN#", Context.Source.GetPath());
            }

            // add unit
            EncoderUnit.TransportMethod input = doInputReader ? EncoderUnit.TransportMethod.NamedPipe : EncoderUnit.TransportMethod.Other;
            EncoderUnit unit = new EncoderUnit(Configuration.StreamingProfiles.FFMpegPath, arguments, input, ReadOutputStream ? EncoderUnit.TransportMethod.NamedPipe : EncoderUnit.TransportMethod.Other, EncoderUnit.LogStream.StandardError, Context);

            unit.DebugOutput = false; // change this for debugging
            Context.Pipeline.AddDataUnit(unit, 5);

            // setup output parsing
            var einfo = new Reference <WebTranscodingInfo>(() => Context.TranscodingInfo, x => { Context.TranscodingInfo = x; });
            FFMpegLogParsingUnit logunit = new FFMpegLogParsingUnit(Context.Identifier, einfo, Context.StartPosition);

            logunit.LogMessages = true;
            logunit.LogProgress = true;
            Context.Pipeline.AddLogUnit(logunit, 6);
        }
コード例 #2
0
ファイル: FFMpeg.cs プロジェクト: bjarkimg/MPExtended
        public void BuildPipeline(StreamContext context)
        {
            // add input
            bool doInputReader = context.Source.NeedsInputReaderUnit;

            if (doInputReader)
            {
                context.Pipeline.AddDataUnit(context.Source.GetInputReaderUnit(), 1);
            }

            // calculate stream mappings (no way I'm going to add subtitle support; it's just broken)
            string mappings = "";

            if (context.AudioTrackId != null)
            {
                mappings = String.Format("-map v:0 -map a:{0}", context.MediaInfo.AudioStreams.First(x => x.ID == context.AudioTrackId).Index);
            }

            // calculate full argument string
            string arguments;

            if (context.Profile.HasVideoStream)
            {
                arguments = String.Format(
                    "-y {0} -i \"#IN#\" -s {1} -aspect {2}:{3} {4} {5} \"#OUT#\"",
                    context.StartPosition != 0 ? "-ss " + (context.StartPosition / 1000) : "",
                    context.OutputSize, context.OutputSize.Width, context.OutputSize.Height,
                    mappings, context.Profile.CodecParameters["codecParameters"]
                    );
            }
            else
            {
                arguments = String.Format(
                    "-y {0} -i \"#IN#\" {1} {2} \"#OUT#\"",
                    context.StartPosition != 0 ? "-ss " + (context.StartPosition / 1000) : "",
                    mappings, context.Profile.CodecParameters["codecParameters"]
                    );
            }

            // fix input thing
            if (!doInputReader)
            {
                arguments = arguments.Replace("#IN#", context.Source.GetPath());
            }

            // add unit
            EncoderUnit.TransportMethod input = doInputReader ? EncoderUnit.TransportMethod.NamedPipe : EncoderUnit.TransportMethod.Other;
            EncoderUnit unit = new EncoderUnit(Configuration.Streaming.FFMpegPath, arguments, input, EncoderUnit.TransportMethod.NamedPipe, EncoderUnit.LogStream.StandardError);

            unit.DebugOutput = false; // change this for debugging
            context.Pipeline.AddDataUnit(unit, 5);

            // setup output parsing
            var einfo = new Reference <WebTranscodingInfo>(() => context.TranscodingInfo, x => { context.TranscodingInfo = x; });
            FFMpegLogParsingUnit logunit = new FFMpegLogParsingUnit(einfo, context.StartPosition);

            logunit.LogMessages = true;
            logunit.LogProgress = true;
            context.Pipeline.AddLogUnit(logunit, 6);
        }