Converting a set of images to video using c#

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

31 Replies - 6266 Views - Last Post: 15 January 2013 - 03:16 PM Rate Topic: -----

#1 Gaurav Chhabra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 07-January 13

Converting a set of images to video using c#

Posted 07 January 2013 - 03:58 PM

Guys i want convert the set of images into video using C# coding, so kindly help me guys and please give only the solutions that are working fine.

and i tried to attach my code but i couldnīt, and there the main form contains 4 picture boxes for 4 cameras and ryt now i can take images and save them, but i want convert them into a video file and there


i have a button labeled as test and when i click on that button there and error comes " vshost32.exe " stopped working.

the block of code of that test button is --> ( i am already using the windows encoder library and headerfile.)
string[] files = System.IO.Directory.GetFiles(@"C:\Users\gaurav\Desktop\New folder\video capture\video capture\bin\Debug\img");

            WMEncoder encoder = new WMEncoder();


            //profile for each frame

            IWMEncProfile2 pro = new WMEncProfile2();
            pro.LoadFromFile(
            @"C:\Users\gaurav\test.prx");


            //build up the collection of frames

            IWMEncSourceGroup2 frameSourceGroup;

            foreach (string filename in files)
            {
                frameSourceGroup = (
                IWMEncSourceGroup2)encoder.SourceGroupCollection.Add(filename);
                frameSourceGroup.set_Profile(pro);
                //odd to have to do it this way instead of via property

                IWMEncVideoSource2 sourceVideo = (IWMEncVideoSource2)frameSourceGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
                sourceVideo.SetInput(filename,
                "", "");
            }

            encoder.File.LocalFileName =
            @"C:\Users\gaurav\output.wmv";
            encoder.PrepareToEncode(
            true);


kindly help me guys...

I need your support asap
Thanks in advance

This post has been edited by tlhIn`toq: 08 January 2013 - 08:38 AM
Reason for edit:: Please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: Converting a set of images to video using c#

#2 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3652
  • View blog
  • Posts: 11,421
  • Joined: 05-May 12

Re: Converting a set of images to video using c#

Posted 07 January 2013 - 06:43 PM

If you run your code by pressing F5 instead of Ctrl-F5, you'll have a better chance of letting the debugger catching exceptions thrown by your code and/or WIC. With the callstack information, we will be in a better position to help you diagnose what is happening.
Was This Post Helpful? 0
  • +
  • -

#3 Gaurav Chhabra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 07-January 13

Re: Converting a set of images to video using c#

Posted 08 January 2013 - 07:07 AM

hey, i am already executing my code using F5 key, but still its same error that vshost32.exe stopped working
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3652
  • View blog
  • Posts: 11,421
  • Joined: 05-May 12

Re: Converting a set of images to video using c#

Posted 08 January 2013 - 07:48 AM

That's too bad. Have you tried setting a breakpoint in your Test button click handler and single stepping? Which line is the failure happening on?
Was This Post Helpful? 0
  • +
  • -

#5 Gaurav Chhabra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 07-January 13

Re: Converting a set of images to video using c#

Posted 08 January 2013 - 08:18 AM

i did brother, still same error, can you send me your email may be i can send you the code, because i am trying to attach here but server is returning an error.

i will wait for your answer, please friend its really urgent.
Thanks
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9497
  • View blog
  • Posts: 35,844
  • Joined: 12-June 08

Re: Converting a set of images to video using c#

Posted 08 January 2013 - 08:19 AM

Please keep the help on the thread so others may benefit from it later.
Was This Post Helpful? 0
  • +
  • -

#7 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5632
  • View blog
  • Posts: 12,078
  • Joined: 02-June 10

Re: Converting a set of images to video using c#

Posted 08 January 2013 - 08:33 AM

Gaurav Chhabra: What this shows us is that you aren't familiar with breakpoints and how to debug your own code.


tlhIn`toq's FAQ list

Learning to debug one's own code is an essential skill. Sadly, one that apparently few college courses teach. Silly if you ask me.

Placing breakpoints and walking through the code line by line allows you to actually WATCH it execute.

Visualizing what your code does will let you see why it behaves the way it does.

It would be well worth your time to do the tutorials on FAQ 2. A couple hours learning this skill will save you hundreds of hours of confusion in one project alone.


TOP most asked:
What does this error message mean?
FAQ 2: How do I debug
FAQ 3: How do I make Class1/Form1 talk to Class2/Form2


FAQ (Frequently Asked Questions - Updated DEC 2012
Spoiler



This post has been edited by tlhIn`toq: 08 January 2013 - 08:34 AM

Was This Post Helpful? 0
  • +
  • -

#8 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5632
  • View blog
  • Posts: 12,078
  • Joined: 02-June 10

Re: Converting a set of images to video using c#

Posted 08 January 2013 - 08:47 AM

After marking down your post to just the relevant info your question really comes down to
"I get an error - Please debug my code for me". That's why I posted all the tips on how to debug your own code. Learning how to do this is an important part of becoming a programmer. We simply don't have the time nor interest in debugging every project for a couple million rookies that don't want to take the time to learn how.

A couple things that would help you:
1 - Stop hardcoding your paths. Use the SpecialFolders enum to get paths to the user desktop and so on.
2 - Make use of Try...Catch constructs so you can see the error message.
Was This Post Helpful? 0
  • +
  • -

#9 Gaurav Chhabra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 07-January 13

Re: Converting a set of images to video using c#

Posted 08 January 2013 - 09:41 AM

View PosttlhIn`toq, on 08 January 2013 - 08:47 AM, said:

After marking down your post to just the relevant info your question really comes down to
"I get an error - Please debug my code for me". That's why I posted all the tips on how to debug your own code. Learning how to do this is an important part of becoming a programmer. We simply don't have the time nor interest in debugging every project for a couple million rookies that don't want to take the time to learn how.

A couple things that would help you:
1 - Stop hardcoding your paths. Use the SpecialFolders enum to get paths to the user desktop and so on.
2 - Make use of Try...Catch constructs so you can see the error message.



I went down through all of my code and finally i recognize the lines that is generating that error.. the lines are

//-- coding statements

string[] files = System.IO.Directory.GetFiles(@"C:\Users\gaurav\Desktop\New folder\video capture\video capture\bin\Debug\img");

WMEncoder encoder = new WMEncoder();

//-- end

Guys kindly help me to remove the error for vshost32.exe that is generated due to these two lines.
Was This Post Helpful? 0
  • +
  • -

#10 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9497
  • View blog
  • Posts: 35,844
  • Joined: 12-June 08

Re: Converting a set of images to video using c#

Posted 08 January 2013 - 09:45 AM

How about throwing a try/catch around there and inspecting the exception?
Was This Post Helpful? 0
  • +
  • -

#11 Gaurav Chhabra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 07-January 13

Re: Converting a set of images to video using c#

Posted 08 January 2013 - 10:05 AM

View Postmodi123_1, on 08 January 2013 - 09:45 AM, said:

How about throwing a try/catch around there and inspecting the exception?


even i did that friend, still no exception, i think problem is coming in the initialization of the files array..Can you support me for that.._??
Was This Post Helpful? 0
  • +
  • -

#12 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9497
  • View blog
  • Posts: 35,844
  • Joined: 12-June 08

Re: Converting a set of images to video using c#

Posted 08 January 2013 - 10:12 AM

try this.. right click on your project -> properties -> debug tab -> enable unmanaged code debugging.
Was This Post Helpful? 0
  • +
  • -

#13 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5632
  • View blog
  • Posts: 12,078
  • Joined: 02-June 10

Re: Converting a set of images to video using c#

Posted 08 January 2013 - 10:42 AM

"C:\Users\gaurav\Desktop\New folder\video capture\video capture\bin\Debug\img"

Look at that path really carefully. I have a hard time beleiving it.
Do you really have this structure:
  • Desktop
    • New folder
      • video capture
        • video capture
          • bin
            • Debug


Not to mention if this is being used for a .GetFiles() method then it needs to be a FOLDER meaning the path needs to end with a '\'

This is the path to a file named 'img'
"C:\Users\gaurav\Desktop\New folder\video capture\video capture\bin\Debug\img"

This is a folder
"C:\Users\gaurav\Desktop\New folder\video capture\video capture\bin\Debug\img\"

This post has been edited by tlhIn`toq: 08 January 2013 - 10:47 AM

Was This Post Helpful? 0
  • +
  • -

#14 Gaurav Chhabra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 07-January 13

Re: Converting a set of images to video using c#

Posted 08 January 2013 - 11:22 AM

Yes sorry i correct that but still i am having the same error
.. i even modify the code and the current code for that block is

string[] files = { Convert.ToString(0) };

try
{
  files = System.IO.Directory.GetFiles(@"C:\Users\gaurav.STRINGNET\Desktop\Newfolder\videocapture\videocapture\bin\Debug\img\");
}

catch (Exception ex)
{
  MessageBox.Show(ex.Message);
}


Still its not catching any exception nothing, just comes the error vshost32.exe not working.

This post has been edited by tlhIn`toq: 08 January 2013 - 11:38 AM
Reason for edit:: code tags added

Was This Post Helpful? 0
  • +
  • -

#15 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5632
  • View blog
  • Posts: 12,078
  • Joined: 02-June 10

Re: Converting a set of images to video using c#

Posted 08 January 2013 - 11:39 AM

The try needs to be around the entire method, not just the string assignment.
The string assignment won't fail.
But trying to access a folder that doesn't exist will.

What the heck is this?
string[] files = { Convert.ToString(0) };

Have you done any programming in C# before? Is this your first program?
Are you trying to learn C# at the same time as trying to build this application?

Please use proper code tags
:code:/>
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3