Example #1
0
        public Video(String input, String password)
        {
            Password = ToPasswordSeed(password);

            reader = new AVIReader();

            reader.Open(input);
            ResetReadByte();

            ExtractHeader();
        }
Example #2
0
        public Video(String input, String output, int length, String extension, int LSB, String password)
        {
            Length = length;
            Extension = extension;
            this.LSB = LSB;
            Password = ToPasswordSeed(password);
            SumPNSRFrame = 0;
            SumPNSR = 0;
            PNSR = 0;

            reader = new AVIReader();
            writer = new AVIWriter();

            reader.Open(input);
            writer.Open(output, reader.Width, reader.Height);
            ResetWriteByte();

            HideHeader();
        }
Example #3
0
        static void Main()
        {
            AVIWriter writer = new AVIWriter("xvid");
            // instantiate AVI reader
            AVIReader reader = new AVIReader();
            // open video file
            reader.Open("test2.avi");
            // create new AVI file and open it
            writer.Open("testOut2.avi", reader.Width, reader.Height);

            //WebClient webClient = new WebClient();
            //webClient.DownloadFile("http://maps.googleapis.com/maps/api/staticmap?center=-15.800513,-47.91378&zoom=11&size=200x200&sensor=false", @"C:\Users\GaliaTodorova\Dropbox\Telerik_wf\OOP\TeamWork\test.png");



            //Bitmap flag = new Bitmap(@"C:\Users\GaliaTodorova\Dropbox\Telerik_wf\OOP\TeamWork\test.png");  //galia
            //Bitmap toFrame = new Bitmap(flag, new Size(reader.Width, reader.Height));
            //toFrame.MakeTransparent();
            // read the video file
            while (reader.Position - reader.Start < reader.Length)
            {
                // get next frame
                Bitmap image = reader.GetNextFrame();
                for (int t = 0; t < reader.Position - reader.Start; t++)
                {
                    /*using (Graphics grfx = Graphics.FromImage(image))
                    {
                     grfx.DrawImage(flag, 0, 0);
                    }*/
                    if (t >= reader.Width)
                        break;
                    int y = (int)(reader.Height / 2 + Math.Sin(((float)t) / 50) * reader.Height / 3);
                    image.SetPixel(t, y - 1, Color.Red);
                    image.SetPixel(t, y, Color.Red);
                    image.SetPixel(t, y + 1, Color.Red);
                }
                writer.AddFrame(image);
            }
            reader.Close();
            writer.Close();
        }
        /// <summary>
        /// Worker thread.
        /// </summary>
        /// 
        private void WorkerThread( )
		{
            ReasonToFinishPlaying reasonToStop = ReasonToFinishPlaying.StoppedByUser;
            // AVI reader
			AVIReader aviReader = new AVIReader( );

			try
			{
				// open file
				aviReader.Open( source );

                // stop positions
                int stopPosition = aviReader.Start + aviReader.Length;

                // frame interval
                int interval = ( frameIntervalFromSource ) ? (int) ( 1000 / aviReader.FrameRate ) : frameInterval;

                while ( !stopEvent.WaitOne( 0, false ) )
				{
					// start time
					DateTime start = DateTime.Now;

					// get next frame
					Bitmap bitmap = aviReader.GetNextFrame( );

					framesReceived++;

					if ( NewFrame != null )
						NewFrame( this, new NewFrameEventArgs( bitmap ) );

					// free image
					bitmap.Dispose( );

                    // check current position
                    if ( aviReader.Position >= stopPosition )
                    {
                        reasonToStop = ReasonToFinishPlaying.EndOfStreamReached;
                        break;
                    }

                    // wait for a while ?
                    if ( interval > 0 )
                    {
                        // get frame extract duration
                        TimeSpan span = DateTime.Now.Subtract( start );

                        // miliseconds to sleep
                        int msec = interval - (int) span.TotalMilliseconds;

                        while ( ( msec > 0 ) && ( stopEvent.WaitOne( 0, true ) == false ) )
                        {
                            // sleeping ...
                            Thread.Sleep( ( msec < 100 ) ? msec : 100 );
                            msec -= 100;
                        }
                    }
				}
			}
			catch ( Exception exception )
			{
                // provide information to clients
                if ( VideoSourceError != null )
                {
                    VideoSourceError( this, new VideoSourceErrorEventArgs( exception.Message ) );
                }
			}

			aviReader.Dispose( );
			aviReader = null;

            if ( PlayingFinished != null )
            {
                PlayingFinished( this, reasonToStop );
            } 
		}
Example #5
0
        /// <summary>
        /// Worker thread.
        /// </summary>
        ///
        private void WorkerThread( )
        {
            ReasonToFinishPlaying reasonToStop = ReasonToFinishPlaying.StoppedByUser;
            // AVI reader
            AVIReader aviReader = new AVIReader( );

            try
            {
                // open file
                aviReader.Open(source);

                // stop positions
                int stopPosition = aviReader.Start + aviReader.Length;

                // frame interval
                int interval = (frameIntervalFromSource) ? (int)(1000 / aviReader.FrameRate) : frameInterval;

                while (!stopEvent.WaitOne(0, false))
                {
                    // start time
                    DateTime start = DateTime.Now;

                    // get next frame
                    Bitmap bitmap = aviReader.GetNextFrame( );

                    framesReceived++;
                    bytesReceived += bitmap.Width * bitmap.Height *
                                     (Bitmap.GetPixelFormatSize(bitmap.PixelFormat) >> 3);

                    if (NewFrame != null)
                    {
                        NewFrame(this, new NewFrameEventArgs(bitmap));
                    }

                    // free image
                    bitmap.Dispose( );

                    // check current position
                    if (aviReader.Position >= stopPosition)
                    {
                        reasonToStop = ReasonToFinishPlaying.EndOfStreamReached;
                        break;
                    }

                    // wait for a while ?
                    if (interval > 0)
                    {
                        // get frame extract duration
                        TimeSpan span = DateTime.Now.Subtract(start);

                        // miliseconds to sleep
                        int msec = interval - (int)span.TotalMilliseconds;

                        if ((msec > 0) && (stopEvent.WaitOne(msec, false)))
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                // provide information to clients
                if (VideoSourceError != null)
                {
                    VideoSourceError(this, new VideoSourceErrorEventArgs(exception.Message));
                }
            }

            aviReader.Dispose( );
            aviReader = null;

            if (PlayingFinished != null)
            {
                PlayingFinished(this, reasonToStop);
            }
        }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AVIFileVideoSource"/> class.
 /// </summary>
 /// 
 /// <param name="source">Video file name.</param>
 /// 
 public AVIFileExVideoSource(string source)
 {
     this.aviReader = new AVIReader();
     this.source = source;
 }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AVIFileVideoSource"/> class.
 /// </summary>
 /// 
 public AVIFileExVideoSource()
 {
     this.aviReader = new AVIReader();
 }