Example #1
0
        /// <summary>
        /// マルチスレッドで分割処理を実施する
        /// </summary>
        /// <param name="inputFile"></param>
        /// <param name="duration"></param>
        /// <param name="num"></param>
        private static void MultiTrim(string inputFile, string profileName, int duration, int num)
        {
            List <Thread> tlist = new List <Thread>(num);

            for (int i = 0; i < num; i++)
            {
                MediaTrimer trim = new MediaTrimer(inputFile, profileName);
                trim.MarkIn   = (duration * i) / num;
                trim.MarkOut  = (duration * (i + 1) / num) - (duration / num / 5);
                trim.DestFile = new FileInfo(string.Format("dest{0}.wmv", i)).FullName;

                Thread th = new Thread(delegate()
                {
                    Console.WriteLine("encode start : {0}", trim.GetHashCode());

                    try
                    {
                        trim.Start();

                        Console.WriteLine("encode stop : {0}", trim.GetHashCode());
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    finally
                    {
                        trim.Dispose();
                    }
                });

                tlist.Add(th);
            }

            foreach (Thread th in tlist)
            {
                th.Start();
            }

            foreach (Thread th in tlist)
            {
                th.Join();
            }
        }
Example #2
0
        /// <summary>
        /// �}���`�X���b�h�����������{����
        /// </summary>
        /// <param name="inputFile"></param>
        /// <param name="duration"></param>
        /// <param name="num"></param>
        private static void MultiTrim(string inputFile, string profileName, int duration, int num)
        {
            List<Thread> tlist = new List<Thread>(num);

            for (int i = 0; i < num; i++)
            {
                MediaTrimer trim = new MediaTrimer(inputFile, profileName);
                trim.MarkIn = (duration * i) / num;
                trim.MarkOut = (duration * (i + 1) / num) - (duration / num / 5);
                trim.DestFile = new FileInfo(string.Format("dest{0}.wmv", i)).FullName;

                Thread th = new Thread(delegate()
                {
                    Console.WriteLine("encode start : {0}", trim.GetHashCode());

                    try
                    {
                        trim.Start();

                        Console.WriteLine("encode stop : {0}", trim.GetHashCode());
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    finally
                    {
                        trim.Dispose();
                    }
                });

                tlist.Add(th);
            }

            foreach (Thread th in tlist)
            {
                th.Start();
            }

            foreach (Thread th in tlist)
            {
                th.Join();
            }
        }