Encript extern Video Stream SWF and not FLV

.NET Edition of the F-IN-BOX
simplicio
Posts: 10
Joined: Tue Nov 23, 2010 2:10 pm

Encript extern Video Stream SWF and not FLV

Postby simplicio » Fri Dec 03, 2010 10:50 pm

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


Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Tue Dec 07, 2010 12:57 pm

Hello,

So you encrypt SWF, not FLV?

Thank you.
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html

simplicio
Posts: 10
Joined: Tue Nov 23, 2010 2:10 pm

Encript SWF

Postby simplicio » Fri Dec 10, 2010 9:54 pm

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

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Tue Dec 21, 2010 4:07 pm

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.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

simplicio
Posts: 10
Joined: Tue Nov 23, 2010 2:10 pm

encripty a video in swf

Postby simplicio » Thu Feb 10, 2011 11:16 am

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]

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Re: encripty a video in swf

Postby Softanics » Thu Feb 10, 2011 12:01 pm

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.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

simplicio
Posts: 10
Joined: Tue Nov 23, 2010 2:10 pm

Postby simplicio » Thu Feb 10, 2011 2:25 pm

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


Return to “.NET Edition”

Who is online

Users browsing this forum: No registered users and 13 guests

cron