Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 135,951 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 2,657 people online right now. Registration is fast and FREE... Join Now!




Video splitter

 
Reply to this topicStart new topic

Video splitter

hiphop_13
24 May, 2008 - 05:13 AM
Post #1

New D.I.C Head
*

Joined: 4 Jun, 2007
Posts: 36



Thanked: 1 times
My Contributions
hello
This program(attached) should split the video into segments,but an eror occurs every time I run it which is

"Retrieving the COM class factory for component with CLSID {9571D958-9BCF-4E19-A374-FC2F321C8F61} failed due to the following error: 80040154."

Note : where can I download (Windows Media Components\Encoder\Profiles\scmeda.prx) because I don't have it & the program needs it.
thanks


Attached File(s)
Attached File  split_a_file.zip ( 645.12k ) Number of downloads: 51
User is offlineProfile CardPM
+Quote Post

rgfirefly24
RE: Video Splitter
24 May, 2008 - 05:43 AM
Post #2

D.I.C Regular
Group Icon

Joined: 7 Apr, 2008
Posts: 330



Thanked: 5 times
Dream Kudos: 150
My Contributions
QUOTE(hiphop_13 @ 24 May, 2008 - 06:13 AM) *

hello
This program(attached) should split the video into segments,but an eror occurs every time I run it which is

"Retrieving the COM class factory for component with CLSID {9571D958-9BCF-4E19-A374-FC2F321C8F61} failed due to the following error: 80040154."

Note : where can I download (Windows Media Components\Encoder\Profiles\scmeda.prx) because I don't have it & the program needs it.
thanks


Welcome, and i'd like to take the opertunity to let you know that we typically do not download items from people we do not know(attachments) if you can please edit the post with the code posted in the actual post like so:

[*code]Your code here[*/code] (remove astriks)
User is offlineProfile CardPM
+Quote Post

hiphop_13
RE: Video Splitter
25 May, 2008 - 07:10 AM
Post #3

New D.I.C Head
*

Joined: 4 Jun, 2007
Posts: 36



Thanked: 1 times
My Contributions
Hello
Please don't forget to tell me were can i download Windows Media Components\Encoder\Profiles\scmeda.prx


Form1.cs
CODE

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using WMEncoderLib;
using WMPREVIEWLib;
using System.IO;

namespace SplitFile
{
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    
        public static string profileName = @"C:\Program Files\Windows Media Components\Encoder\Profiles\scmeda.prx";
        public static string movie_source1 =Environment.CurrentDirectory + "\\source1.avi";
        //public static string movie_source2     = Environment.CurrentDirectory +"\\source2.avi";
        public static int movie_pieces = 5;
        public static string movie_dest = Environment.CurrentDirectory +"\\splitFile";
        public static string movie_ext = ".wmv";    
        WMEncBasicEdit BasicEdit = new WMEncBasicEdit();

        bool glbboolStartNext= false;
        
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            //
            // Form1
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(292, 266);
            this.Enabled = false;
            this.Name = "Form1";
            this.Opacity = 0;
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);

        }
        #endregion

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            if ( args.Length >0 && !"".Equals(args[0]) )
                movie_source1 =args[0];
            if ( args.Length >0 && !"".Equals(args[1]) )
                movie_pieces =Convert.ToInt32(args[1]);
            if (args.Length >2 && !"".Equals(args[2]) )
            {
                string dest = args[2];
                movie_dest =dest.Substring(0,dest.Length -4);
                movie_ext = dest.Substring(dest.Length -4);
            }

            Application.Run(new Form1());
        }

        private void Form1_Load(object sender, System.EventArgs e)
        {
            this.Visible = false;
            EncodeFromConsole();
            this.Visible = false;
            
        }
        
        private bool sEncodeFile(string source1,int pieces ,string destination)
        {
            try
            {
                // Specify the input and output files.
                BasicEdit.MediaFile = source1;
                BasicEdit.Index = true;
                Decimal duration = BasicEdit.Duration;
                Decimal sizeOfPiece = duration/pieces;
                for (int i = 0; i < pieces; i ++ )
                {
                    
                    BasicEdit.OutputFile = destination + i+movie_ext;

                    // Add indexing to the file.
                

                    // Trim 5 seconds from the beginning and end of the file.
                    BasicEdit.MarkIn = sizeOfPiece * i;
                    BasicEdit.MarkOut = (i+1) * sizeOfPiece;
                    // Start editing.
                    BasicEdit.Start();

                    while (BasicEdit.RunState != WMENC_BASICEDIT_STATE.WMENC_BASICEDIT_STOPPED)
                    {
                        Application.DoEvents ();
                    }
                }
            }
            catch (Exception e)
            {
                // TODO: Handle exceptions.
            }
        
            return true;
        }

        public void EncodeFromConsole()
        {
            BasicEdit = new WMEncBasicEdit();
            //glbEncoder.OnStateChange+=new _IWMEncoderEvents_OnStateChangeEventHandler(this.Encoder_OnStateChange);
            Console.WriteLine("Spliting File, "+movie_source1+" ..........");
            bool boolEncodeStart = sEncodeFile(movie_source1, movie_pieces ,movie_dest );
                
            Console.WriteLine  ("Finished Spliting- Files ");
            Application.Exit ();
        }


        
        
    }

    
}



User is offlineProfile CardPM
+Quote Post

thor78
RE: Video Splitter
25 May, 2008 - 06:11 PM
Post #4

D.I.C Head
Group Icon

Joined: 6 May, 2008
Posts: 106


Dream Kudos: 50
My Contributions
You google for it. You should do some folder/file searching before you start the movie splitting.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 09:10AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month