예제 #1
0
 unsafe private static extern int AVISaveOptions(
   IntPtr hwnd, UInt32 flags, int nStreams, IntPtr* ptr_ptr_avi, AVICOMPRESSOPTIONS** ao );
예제 #2
0
 private static extern int AVIMakeCompressedStream(
   out IntPtr ppsCompressed, IntPtr aviStream, ref AVICOMPRESSOPTIONS ao, int dummy );
예제 #3
0
        unsafe private bool SetOptions( IntPtr hwnd ) {
            // VIDEO
            AVICOMPRESSOPTIONS opts = new AVICOMPRESSOPTIONS();
            opts.fccType = 0;
            opts.fccHandler = 0;
            opts.dwKeyFrameEvery = 0;
            opts.dwQuality = 0;
            opts.dwFlags = 0;
            opts.dwBytesPerSecond = 0;
            opts.lpFormat = new IntPtr( 0 );
            opts.cbFormat = 0;
            opts.lpParms = new IntPtr( 0 );
            opts.cbParms = 0;
            opts.dwInterleaveEvery = 0;

            AVICOMPRESSOPTIONS* p = &opts;
            AVICOMPRESSOPTIONS** pp;
            pp = &p;
            IntPtr x = m_video;
            IntPtr* ptr_ps;
            ptr_ps = &x;
            if ( AVISaveOptions( hwnd, 0, 1, ptr_ps, pp ) == 0 ) {
                return false;
            }
            int hr = AVIMakeCompressedStream( out m_video_compressed, m_video, ref opts, 0 );
            if ( hr != 0 ) {
                throw new AviException( "AVIMakeCompressedStream; Video" );
            }
            m_strh_fcc = opts.fccHandler;
#if DEBUG
            Console.WriteLine( "AviWriterVfw+SetOptions" );
            Console.WriteLine( "    opts.fccHandler=" + opts.fccHandler );
#endif

            // TODO: AVISaveOptionsFree(...)
            BITMAPINFO bi = new BITMAPINFO();
            bi.bmiHeader.biSize = 40;
            bi.bmiHeader.biWidth = (Int32)m_width;
            bi.bmiHeader.biHeight = (Int32)m_height;
            bi.bmiHeader.biPlanes = 1;
            bi.bmiHeader.biBitCount = 24;
            bi.bmiHeader.biCompression =  0;
            bi.bmiHeader.biSizeImage = m_stride * m_height;
            bi.bmiHeader.biXPelsPerMeter = 0;
            bi.bmiHeader.biYPelsPerMeter = 0;
            bi.bmiHeader.biClrUsed = 0;
            bi.bmiHeader.biClrImportant = 0;

            hr = AVIStreamSetFormat( m_video_compressed, 0, ref bi, sizeof( BITMAPINFO ) );
            if ( hr != 0 ) {
                throw new AviException( "AVIStreamSetFormat", hr );
            }
#if DEBUG
            Console.WriteLine( "    bi.bmiHeader.biCompression=" + bi.bmiHeader.biCompression );
#endif
            return true;
        }
예제 #4
0
        /// <summary>
        /// オーディオ圧縮の設定ダイアログを表示し、オーディオ圧縮の設定を取得します
        /// </summary>
        /// <returns></returns>
        unsafe public static AVICOMPRESSOPTIONS RequireAudioCompressOption() {
            string temp_file = Path.GetTempFileName();
            byte[] buf = new byte[] {
                82, 73, 70, 70, 94, 0, 0, 0, 87, 65, 86, 69, 102, 109, 116, 32, 16, 0, 0, 0, 1,
                0, 1, 0, 64, 31, 0, 0, 64, 31, 0, 0, 1, 0, 8, 0, 100, 97, 116, 97, 58, 0, 0, 0,
                128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
                128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
                128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
                128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
            };
            using ( FileStream fs = new FileStream( temp_file, FileMode.Create ) ) {
                fs.Write( buf, 0, buf.Length );
            }

            AVIFileInit();
            //MessageBox.Show( "AVIFileInit ok" );
            IntPtr audio;
            int hr = AVIStreamOpenFromFileW( out audio, temp_file, _STREAM_TYPE_AUDIO, 0, OF_READ, 0 );
            //MessageBox.Show( "AVIStreamOpenFromFileW ok" );

            AVICOMPRESSOPTIONS opts = new AVICOMPRESSOPTIONS();
            opts.fccType = _STREAM_TYPE_AUDIO; //fccType_;
            opts.fccHandler = 0;//fccHandler_;
            opts.dwKeyFrameEvery = 0;
            opts.dwQuality = 0;  // 0 .. 10000
            opts.dwFlags = 0;  // AVICOMRPESSF_KEYFRAMES = 4
            opts.dwBytesPerSecond = 0;
            opts.lpFormat = new IntPtr( 0 );
            opts.cbFormat = 0;
            opts.lpParms = new IntPtr( 0 );
            opts.cbParms = 0;
            opts.dwInterleaveEvery = 0;
            AVICOMPRESSOPTIONS* p = &opts;
            AVICOMPRESSOPTIONS** pp = &p;
            IntPtr x = audio;
            IntPtr* ptr_ps = &x;
            AVISaveOptions( IntPtr.Zero, 0, 1, ptr_ps, pp );
            //MessageBox.Show( "AVISaveOptions ok" );
            AVICOMPRESSOPTIONS copied = new AVICOMPRESSOPTIONS();
            copied = opts;
            AVIStreamRelease( audio );
            //MessageBox.Show( "AVIStreamRelease(audio) ok" );

            AVIFileExit();
            //MessageBox.Show( "AVIFileExit ok" );
            File.Delete( temp_file );
            return copied;
        }
예제 #5
0
        unsafe public static AVICOMPRESSOPTIONS RequireVideoCompressOption( AVICOMPRESSOPTIONS current_option ) {
            AviWriterVfw temp = new AviWriterVfw();
            temp.m_scale = 1000;
            temp.m_rate = 30 * temp.m_scale;
            int width = 10, height = 10;
            temp.m_width = (UInt32)width;
            temp.m_height = (UInt32)height;
            using ( Bitmap bmp = new Bitmap( width, height, PixelFormat.Format24bppRgb ) ) {
                BitmapData bmpDat = bmp.LockBits( new Rectangle( 0, 0, width, height ), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb );
                temp.m_stride = (UInt32)bmpDat.Stride;
                bmp.UnlockBits( bmpDat );
            }
            AVIFileInit();
            string temp_file = Path.GetTempFileName() + ".avi";// .aviを付けないと、AVIFileOpenWが失敗する
            int hr = AVIFileOpenW( ref temp.m_file_handle, temp_file, OF_WRITE | OF_CREATE, 0 );
            if ( hr != 0 ) {
                throw new AviException( "error for AVIFileOpenW" );
            }

            temp.CreateStream();

            AVICOMPRESSOPTIONS opts = new AVICOMPRESSOPTIONS();
            opts.fccType = 0; //fccType_;
            opts.fccHandler = 0;//fccHandler_;
            opts.dwKeyFrameEvery = 0;
            opts.dwQuality = 0;  // 0 .. 10000
            opts.dwFlags = 0;  // AVICOMRPESSF_KEYFRAMES = 4
            opts.dwBytesPerSecond = 0;
            opts.lpFormat = new IntPtr( 0 );
            opts.cbFormat = 0;
            opts.lpParms = new IntPtr( 0 );
            opts.cbParms = 0;
            opts.dwInterleaveEvery = 0;

            opts = current_option;
            AVICOMPRESSOPTIONS* p = &opts;
            AVICOMPRESSOPTIONS** pp = &p;
            IntPtr x = temp.m_video;
            IntPtr* ptr_ps = &x;
            AVISaveOptions( IntPtr.Zero, 0, 1, ptr_ps, pp );
            //MessageBox.Show( "AVISaveOptions ok" );
            AVICOMPRESSOPTIONS copied = new AVICOMPRESSOPTIONS();
            copied = opts;
            AVIStreamRelease( temp.m_video );
            //MessageBox.Show( "AVIStreamRelease(temp.m_video) ok" );

            AVIFileRelease( temp.m_file_handle );
            //MessageBox.Show( "AVIFileRelease ok" );
            AVIFileExit();
            //MessageBox.Show( "AVIFileExit ok" );
            File.Delete( temp_file );
            //MessageBox.Show( "File.Delete(fileName) ok" );
            return copied;
        }
예제 #6
0
 public static extern int AVIMakeCompressedStream(
     out IntPtr ppsCompressed, IntPtr aviStream, ref AVICOMPRESSOPTIONS ao, int dummy);