public override void OnNextFrame(byte[] buffer, int width, int height)
        {
            if (writer == null)
            {
                return;
            }

            System.Diagnostics.Debug.Assert(buffer.Length == video_frame.Format.Bytes);
            video_frame.Update(buffer);

            lock (this)
            {
                writer.Write(video_frame);
            }

            Log.Debug($"{video_encoder.FullName} ---> ({video_encoder.InputFrames}) {video_encoder.InputTimestamp}");
        }
Exemple #2
0
 unsafe static void Main(string[] args)
 {
     using (var reader = new MediaReader(@"D:\MyDocuments\Music\HEALTH\04 21世紀難民 feat. れをる(from REOL).m4a")) {
         var decoder = reader.Decoders.OfType <AudioDecoder>().First();
         var frame   = new AudioFrame();
         using (var writer = new MediaWriter(@"D:\test.flac").AddAudio(decoder.OutFormat, BitRate.Zero).Initialize()) {
             var enc = writer.Encoders[0] as AudioEncoder;
             while (reader.NextFrame(frame, decoder.StreamIndex))
             {
                 var pos = reader.Position;
                 writer.Write(frame);
                 Console.Write($"\rframes: {enc.InputFrames}, time: {enc.InputTimestamp}");
             }
             writer.Flush();
             Console.WriteLine($"\rframes: {enc.InputFrames}, time: {enc.InputTimestamp}");
         }
     }
 }
Exemple #3
0
 unsafe static void Main(string[] args)
 {
     using (var reader = new MediaReader(@"D:\MyDocuments\Music\夕立のりぼん+inst(NoMastering)_island__201411091428.mp3")) {
         var decoder = reader.Decoders.OfType <AudioDecoder>().First();
         var frame   = new AudioFrame();
         using (var writer = new MediaWriter(@"D:\MyDocuments\Music\夕立のりぼん+inst(NoMastering)_island__201411091428-output.mp3").AddAudio(decoder.OutFormat, BitRate._320Kbps).Initialize()) {
             var enc = writer.Encoders[0] as AudioEncoder;
             while (reader.NextFrame(frame, decoder.StreamIndex))
             {
                 var pos = reader.Position;
                 writer.Write(frame);
                 Console.Write($"\rframes: {enc.InputFrames}, time: {enc.InputTimestamp}");
             }
             writer.Flush();
             Console.WriteLine($"\rframes: {enc.InputFrames}, time: {enc.InputTimestamp}");
         }
     }
 }
Exemple #4
0
        public void SetUp()
        {
            var projection = new Projection <Address>(DisplayFormatting.RawValues);

            projection.Value(x => x.Address1);
            projection.Value(x => x.Address2);
            projection.Value(x => x.City);
            projection.Value(x => x.StateOrProvince).Name("State");

            theXmlMediaOptions = new XmlMediaOptions()
            {
                Root = "Address"
            };
            theDocument = new XmlMediaDocument(theXmlMediaOptions);

            var urls = new StubUrlRegistry();

            var linkSource = new LinksSource <Address>();

            linkSource.ToSubject().Rel("self");
            linkSource.To(a => new AddressAction("change")).Rel("change");
            linkSource.To(a => new AddressAction("delete")).Rel("delete");

            theOutput = new InMemoryOutputWriter();

            var media = new MediaWriter <Address>(theDocument, linkSource, urls, projection, null, theOutput);


            theAddress = new Address()
            {
                Address1        = "22 Cherry Lane",
                Address2        = "Apt A",
                City            = "Austin",
                StateOrProvince = "Texas"
            };



            media.Write("text/plain", theAddress);

            Debug.WriteLine(theOutput);
        }
Exemple #5
0
        unsafe static void Main(string[] args)
        {
            var audioFormat = new AudioFormat(44100, AVChannelLayout.LayoutStereo, AVSampleFormat.FloatPlanar);
            var videoFormat = new VideoFormat(1280, 720, AVPixelFormat.Bgr24);

            using (var writer = new MediaWriter(@"Z:\test.mkv")
                                .AddVideo(videoFormat, new VideoEncoderParameters {
                FrameRate = new Fraction(25)
            })
                                .AddAudio(audioFormat)
                                .Initialize()) {
                var     aframe = new AudioFrame(audioFormat);
                var     vframe = new VideoFrame(videoFormat);
                float[] left   = new float[1024];
                byte[]  bitmap = new byte[videoFormat.Bytes];
                vframe.Update(bitmap);
                for (int j = 0; j < 1000; j++)
                {
                    writer.Write(encoder => {
                        if (encoder is AudioEncoder)
                        {
                            int samples = left.Length;
                            long offset = encoder.InputFrames;
                            for (int i = 0; i < samples; i++)
                            {
                                float value = (float)Math.Sin(440d / 44100 * Math.PI * 2 * (i + offset));
                                left[i]     = value;
                            }
                            aframe.Update <float>(samples, left, left);
                            return(aframe);
                        }
                        else
                        {
                            Console.WriteLine($"{encoder.FullName} ---> ({encoder.InputFrames}) {encoder.InputTimestamp}");
                            return(vframe);
                        }
                    });
                }
            }
        }
        public void SetUp()
        {
            var projection = new Projection<Address>(DisplayFormatting.RawValues);
            projection.Value(x => x.Address1);
            projection.Value(x => x.Address2);
            projection.Value(x => x.City);
            projection.Value(x => x.StateOrProvince).Name("State");

            theXmlMediaOptions = new XmlMediaOptions(){
                Root = "Address"
            };
            theDocument = new XmlMediaDocument(theXmlMediaOptions);

            var urls = new StubUrlRegistry();

            var linkSource = new LinksSource<Address>();
            linkSource.ToSubject().Rel("self");
            linkSource.To(a => new AddressAction("change")).Rel("change");
            linkSource.To(a => new AddressAction("delete")).Rel("delete");

            theOutput = new InMemoryOutputWriter();

            var media = new MediaWriter<Address>(theDocument, linkSource, urls, projection, null, theOutput);


            theAddress = new Address(){
                Address1 = "22 Cherry Lane",
                Address2 = "Apt A",
                City = "Austin",
                StateOrProvince = "Texas"
            };



            media.Write("text/plain", theAddress);

            Debug.WriteLine(theOutput);
        }