Page 1 of 1

Encript extern Video Stream SWF and not FLV

Posted: Fri Dec 03, 2010 10:50 pm
by simplicio
I'm trying to encrypt a video in the swf format function below:

Code: Select all


   private void Main()
        {
            const int nSize = 64 * 1024;
            byte[] buffer = new byte[nSize];

            while (true)
            {
                int nReadBytes = EncryptedStream.Read(buffer, 0, nSize);

                //// Simple decryption
                for (int i = 0; i < nSize; i++)
                {
                    buffer[i] ^= 0x35;     //MY ENCRIPT
                }

                if (0 == nReadBytes)
                    break;

                try
                {
                    OutputStream.Write(buffer, 0, nReadBytes);
                }
                catch (System.IO.IOException)
                {
                    // Loading is interrupted
                    break;
                }
            }

            EncryptedStream.Close();
            OutputStream.Close();
        }
    }


In sample_11 i can load external video in swf format but this video does not work.

I need decripty video in format swf and not in FLV.

Help me please.

Simplicio


Posted: Tue Dec 07, 2010 12:57 pm
by Softanics
Hello,

So you encrypt SWF, not FLV?

Thank you.

Encript SWF

Posted: Fri Dec 10, 2010 9:54 pm
by simplicio
my video lessons are recorded in camtasia studio. Normally my videos saved in SWF format. I am developing an encryption system using f-in-box with encrypted video. The Sample_11 encrypts video in FLV and not SWF format . I would like to use both formats: SWF and FLV in my program.

Simplicio

Posted: Tue Dec 21, 2010 4:07 pm
by Softanics
I'm sorry for the delay.

You can use the same method. Just add the same handler OnLoadExternalResourceByFullPath, check passed URL and start almost the same DecryptStreamAndWriteToStream.

Thank you.

encripty a video in swf

Posted: Thu Feb 10, 2011 11:16 am
by simplicio
I still can not encripty a video in swf format, could you help me?


Code: Select all

             private void OnLoadExternalResourceByFullPath(object sender, String URL, System.IO.Stream Stream, ref bool Handled)
      {
         if (URL == "http://FLV/FlashVideo.flv")
         {
                System.IO.Stream EncryptedFLVStream = System.IO.File.OpenRead(EncryptedFLVPath);

                DecryptStreamAndWriteToStream DecryptStreamAndWriteToStream = new DecryptStreamAndWriteToStream(EncryptedFLVStream, Stream);

                Handled = true;
         }
      }


Code: Select all


private void Main()
        {
            const int nSize = 64 * 1024;
            byte[] buffer = new byte[nSize];

            while (true)
            {
                int nReadBytes = EncryptedStream.Read(buffer, 0, nSize);

                //// Simple decryption
                for (int i = 0; i < nSize; i++)
                {
                    buffer[i] ^= 0x35;     //MY ENCRIPT
                }

                if (0 == nReadBytes)
                    break;

                try
                {
                    OutputStream.Write(buffer, 0, nReadBytes);
                }
                catch (System.IO.IOException)
                {
                    // Loading is interrupted
                    break;
                }
            }

            EncryptedStream.Close();
            OutputStream.Close();
        }
    }



Code: Select all

private void abrirVideoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            webBrowser1.Visible = false;
            HabilitarRecursos();

            if (openFileDialogEncyptedFLV.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                EncryptedFLVPath = openFileDialogEncyptedFLV.FileName;
                PlaySource("flv", "http://FLV/FlashVideo.flv");
            }
        }
[/quote]

Re: encripty a video in swf

Posted: Thu Feb 10, 2011 12:01 pm
by Softanics
Hello,

simplicio wrote:I still can not encripty a video in swf format, could you help me?


Is it correct that you compare URL with "http://FLV/FlashVideo.flv" in OnLoadExternalResourceByFullPath?

You have encrypted SWF file, right? And the video is embedded into this file, correct?

Thank you.

Posted: Thu Feb 10, 2011 2:25 pm
by simplicio
I believe the problem is this function because I'm getting the swf in resorce. The video swf that I want to use is in folder c: \ video.

Code: Select all


        private void PlaySource(string TypeVideo,  string URL)
        {
            f_in_box__control1.FlashProperty_FlashVars = BuildFlashVars(TypeVideo, URL, !CheckBoxEnableSounds.Checked, trackBarSoundVolume.Value, checkBoxPlayAutomatically.Checked, checkBoxShowControls.Checked);
            f_in_box__control1.PutMovieFromStream(this.GetType().Assembly.GetManifestResourceStream("WindowsForm.res.FlashVideoPlayer.swf"));
       
         
        }



Code: Select all

 private static string BuildFlashVars(string TypeVideo, string URL, bool Mute, int AudioVolume, bool AutoPlay, bool ShowControls)
        {
            string strFlashVars = "type_video=" + TypeVideo;

            strFlashVars += "&url=" + System.Web.HttpUtility.HtmlEncode(URL);

            strFlashVars += "&auto_play=" + (AutoPlay ? "true" : "false");

            // Specify mute=1 to disable audio, don't specify mute at all to enable audio
            if (Mute) strFlashVars += "&mute=1";

            strFlashVars = strFlashVars + "&volume=" + AudioVolume.ToString();

            strFlashVars += "&auto_play=" + (AutoPlay ? "true" : "false");
            strFlashVars += "&hide_control=" + (ShowControls ? "false" : "true");

            return strFlashVars;
        }



>>Is it correct that you compare URL with "http://FLV/FlashVideo.flv" in OnLoadExternalResourceByFullPath?

I believe that I must keep it because I want the program to work with video in FLV and SWF format

>>You have encrypted SWF file, right?

yes, encrypt SWF and FLV


>>And the video is embedded into this file, correct?
No, the videos SWF and FLV will be open through "FileDialog" ( external directory c: \ video).

Fernando