Converting a set of images to video using c#

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

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

#16 tlhIn`toq  Icon User is online

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

Reputation: 5578
  • View blog
  • Posts: 11,918
  • Joined: 02-June 10

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

Posted 08 January 2013 - 11:53 AM

Now all of a sudden the hardcoded path has changed.

Quote

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

There's a new .STRINGNET to the username?
Missing spaces in New Folder and video capture.
There is a reason I said to use the specialfolders enum and even provided a link to it.

Honestly, I think you just have no idea where your folders are or what the real path is.
You also don't seem to want to take the time to go through the debugging tutorials and learn how to check the values of variables at run time. If you had, you could quickly check if "files" ever gained any paths.

This is all just a bunch of guesswork on your part. And there is no way we can guess from here.

It seems you're just throwing a bunch of mysterious code in and hoping it somehow magically starts working. You can't just grab a bunch of code from the internet and think its going to automatically fit together like Lego blocks when you have no comprehension of what C# is or what you're doing.

For now, just work on learning C#. Do tutorials. Read self-learning books. But stop trying to design a program from scratch until you learn more.


My standard beginner resources post - Updated DEC 2012

You can try to learn C# by dismantling snippets and googling terms - basically you can take a hit-n-miss, shotgun approach. Or you could just follow a proper training program whether it be a couple intro books, school, on-line course or series of tutorials like the ones we offer. I'll tell you from experience that just fumbling around in the dark and trying to teach yourself with no guidance doesn't work. Its like stumbling across a Harrier Jump Jet and trying to teach yourself how to fly with no background in piloting: You simply lack any groundwork to start from. How can you lay out your own training course if you don't already know the material? Would you go to a university where the teacher says "I don't know any of this but we'll fumble through it together?"

We have a tutorials section and a learning C# series of articles.

First learn the language by working 2-5 "Learn C# in 30 days" type books cover to cover. Do a couple hundred on-line tutorial projects where you build what you're told to build, the way you are told to build it WITH AN EXPLANATION OF WHY so you can learn.

There are three routes people seem to take when learning programming.
  • Just start trying to create programs
  • Start taking apart other programs and try to figure out the language by reverse engineering
  • Follow a guided learning course (school or self-teaching books)


For the life of me I can't figure out why people try 1 & 2. I strongly suggest taking the guided learning approach. Those book authors go in a certain order for a reason: They know what they're doing and they know the best order to learn the materials.

Quote

Where do I start?


You start by learning a coding language FIRST.
Learn to plan before you type.
THEN you start designing software with a purpose.


If this sounds like you

Newbie/Rookie said:

I have a little programming experience but I need to write ...
read this section
Spoiler


Otherwise, you can just jump to the resources here:
Some of the tutorials below are for C# or Java not C, C++, VB.NET [...]. But the conceptual stuff of classes, object oriented design, events etc. are not language specific and should give you enough guidance in theory of program development for you to be able to look-up specific code example in your chosen coding language.



Resources, references and suggestions for new programmers. - Updated Oct 2012
Spoiler

Was This Post Helpful? 0
  • +
  • -

#17 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3621
  • View blog
  • Posts: 11,278
  • Joined: 05-May 12

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

Posted 08 January 2013 - 12:31 PM

While tlhIn`toq focuses on the angle where .GetFiles() is failing, let me take a stab at the WMEncoder class not instantiating properly:

Did you download and install WMEncoder from Microsoft, or did you get your binary from somebody else?
http://www.microsoft...&displaylang=en

Are you running on a 64-bit system? If so, I believe that WMEncoder is 32-bit only based on the fact that the supposed supported OSes on that link points only to XP and Server 2000. To fix your issue, you'll have to ensure that your program is compiling with x86 as the target instead of AnyCPU or x64.
Was This Post Helpful? 0
  • +
  • -

#18 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 - 01:04 PM

View PostSkydiver, on 08 January 2013 - 12:31 PM, said:

While tlhIn`toq focuses on the angle where .GetFiles() is failing, let me take a stab at the WMEncoder class not instantiating properly:

Did you download and install WMEncoder from Microsoft, or did you get your binary from somebody else?
http://www.microsoft...&displaylang=en

Are you running on a 64-bit system? If so, I believe that WMEncoder is 32-bit only based on the fact that the supposed supported OSes on that link points only to XP and Server 2000. To fix your issue, you'll have to ensure that your program is compiling with x86 as the target instead of AnyCPU or x64.



I duly apologize for the path mistake
the correct path is as before, just i add '\' in the last.

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

yes i had download the encoder from the microsoft website the same link you gave me and i am using Windows 7 32 Bit OS, with VS 2010.

Still the error is same ..
Was This Post Helpful? 0
  • +
  • -

#19 tlhIn`toq  Icon User is online

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

Reputation: 5578
  • View blog
  • Posts: 11,918
  • Joined: 02-June 10

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

Posted 08 January 2013 - 01:54 PM

View PostGaurav Chhabra, on 08 January 2013 - 02:04 PM, said:

the correct path is as before, just i add '\' in the last.

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


Something screwy is going on with the OP's project or intent. I don't think that path including a domain just miraculously happened. I'm starting to wonder if the OP is trying to gain access to images on the desktop of a different user or PC. Either their intent is something I don't want to be a part of helping, or their skill is something that simply can't be helped without more education and willingingness to use the tips, links and tutorials provided. Either way I think I've reached my limit.

I'm going to bow out of this thread now.

This post has been edited by tlhIn`toq: 08 January 2013 - 01:55 PM

Was This Post Helpful? 0
  • +
  • -

#20 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 - 02:06 PM

View PosttlhIn`toq, on 08 January 2013 - 01:54 PM, said:

View PostGaurav Chhabra, on 08 January 2013 - 02:04 PM, said:

the correct path is as before, just i add '\' in the last.

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


Something screwy is going on with the OP's project or intent. I don't think that path including a domain just miraculously happened. I'm starting to wonder if the OP is trying to gain access to images on the desktop of a different user or PC. Either their intent is something I don't want to be a part of helping, or their skill is something that simply can't be helped without more education and willingingness to use the tips, links and tutorials provided. Either way I think I've reached my limit.

I'm going to bow out of this thread now.


Its the same user man, actually there is one more PC with another user account and i am so puzzle and i copied that path before..i duly apologize for that.. but now as i told u its the same as before path and now the only problem is coming that Vshost32.exe ended work not anything else, i tried using foreach for printing the values of Files array but still before doing that the vshost32 exits.

please help me if you can please

View PosttlhIn`toq, on 08 January 2013 - 01:54 PM, said:

View PostGaurav Chhabra, on 08 January 2013 - 02:04 PM, said:

the correct path is as before, just i add '\' in the last.

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


Something screwy is going on with the OP's project or intent. I don't think that path including a domain just miraculously happened. I'm starting to wonder if the OP is trying to gain access to images on the desktop of a different user or PC. Either their intent is something I don't want to be a part of helping, or their skill is something that simply can't be helped without more education and willingingness to use the tips, links and tutorials provided. Either way I think I've reached my limit.

I'm going to bow out of this thread now.



when i am using the foreach for printing the value for files using debug.print its exhibiting the two statements in Output window.

'video capture.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\gaurav\Desktop\New folder\video capture\video capture\bin\Debug\WebCam_Capture.dll'
The thread '<No Name>' (0x53c) has exited with code 0 (0x0).
The program '[4252] video capture.vshost.exe: Managed (v4.0.30319)' has exited with code 255 (0xff).
Was This Post Helpful? 0
  • +
  • -

#21 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3621
  • View blog
  • Posts: 11,278
  • Joined: 05-May 12

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

Posted 08 January 2013 - 03:09 PM

View PostGaurav Chhabra, on 08 January 2013 - 04:06 PM, said:

when i am using the foreach for printing the value for files using debug.print its exhibiting the two statements in Output window.

'video capture.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\gaurav\Desktop\New folder\video capture\video capture\bin\Debug\WebCam_Capture.dll'
The thread '<No Name>' (0x53c) has exited with code 0 (0x0).
The program '[4252] video capture.vshost.exe: Managed (v4.0.30319)' has exited with code 255 (0xff).


What code with the Debug.print? You never posted any code with Debug.print. Perhaps it is your printing code that is crashing, and not the .GetFiles()?

Anyway in your Program.cs, can you please put the following lines of code, and step through them. If the program doesn't crash, then it's some other bit of code that is causing the problem.

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

    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());
}



If the program crashes on line 4, then there is somekind of permissions issue. If not, then the crash is not happening on the .GetFiles(). In instantiating WMEncoder(), perhaps?
Was This Post Helpful? 0
  • +
  • -

#22 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 - 03:30 PM

View PostSkydiver, on 08 January 2013 - 03:09 PM, said:

View PostGaurav Chhabra, on 08 January 2013 - 04:06 PM, said:

when i am using the foreach for printing the value for files using debug.print its exhibiting the two statements in Output window.

'video capture.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\gaurav\Desktop\New folder\video capture\video capture\bin\Debug\WebCam_Capture.dll'
The thread '<No Name>' (0x53c) has exited with code 0 (0x0).
The program '[4252] video capture.vshost.exe: Managed (v4.0.30319)' has exited with code 255 (0xff).


What code with the Debug.print? You never posted any code with Debug.print. Perhaps it is your printing code that is crashing, and not the .GetFiles()?

Anyway in your Program.cs, can you please put the following lines of code, and step through them. If the program doesn't crash, then it's some other bit of code that is causing the problem.

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

    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());
}



If the program crashes on line 4, then there is somekind of permissions issue. If not, then the crash is not happening on the .GetFiles(). In instantiating WMEncoder(), perhaps?



Man i just use debug.print to display in output window nothing else and even i add the declaration and initializing statement for files as you gave me and even i put the breakpoint there to check and the error occurs after traversing from the statement " Application.Run(new Form1()); " but still its same issue...
Was This Post Helpful? 0
  • +
  • -

#23 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3621
  • View blog
  • Posts: 11,278
  • Joined: 05-May 12

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

Posted 08 January 2013 - 04:34 PM

Okay, that means that the crash is not from the .GetFiles().

So if you set the breakpoint on your line that says:
WMEncoder encoder = new WMEncoder();


Does the program crash before or after this line?
Was This Post Helpful? 0
  • +
  • -

#24 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 09 January 2013 - 06:56 AM

View PostSkydiver, on 08 January 2013 - 04:34 PM, said:

Okay, that means that the crash is not from the .GetFiles().

So if you set the breakpoint on your line that says:
WMEncoder encoder = new WMEncoder();


Does the program crash before or after this line?



yes when i put breakpoint and when i traverse on this statement its fine and when i press again F10 for traversing to another statement the crash occurs..

Do you have any idea why and solution for that ???
Was This Post Helpful? 0
  • +
  • -

#25 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3621
  • View blog
  • Posts: 11,278
  • Joined: 05-May 12

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

Posted 09 January 2013 - 07:27 AM

My first guess would have been 32-bit running in a 64-bit environment incompatibility, but you said that you are running on a 32-bit OS.

Did you turn on unmanaged code debugging as stated in post #12? Can you get a callstack with that enabled?
Was This Post Helpful? 0
  • +
  • -

#26 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 09 January 2013 - 08:50 AM

View PostSkydiver, on 09 January 2013 - 07:27 AM, said:

My first guess would have been 32-bit running in a 64-bit environment incompatibility, but you said that you are running on a 32-bit OS.

Did you turn on unmanaged code debugging as stated in post #12? Can you get a callstack with that enabled?



if i am enabling the unmanaged code debugging then even i am not getting option to select my cameras as i am using 4 cameras and also it never execute the statements for conversion the images into video just exhibit an error as " Unhandled exception at 0x05954218 in video capture.exe: 0xC0000005: Access violation. "
Was This Post Helpful? 0
  • +
  • -

#27 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3621
  • View blog
  • Posts: 11,278
  • Joined: 05-May 12

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

Posted 09 January 2013 - 09:41 AM

And that would explain why your program is eventually crashing. All those interim access violations is probably corrupting your program memory to the point that it eventually crashes.
Was This Post Helpful? 0
  • +
  • -

#28 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 09 January 2013 - 09:48 AM

View PostSkydiver, on 09 January 2013 - 09:41 AM, said:

And that would explain why your program is eventually crashing. All those interim access violations is probably corrupting your program memory to the point that it eventually crashes.


So now do you have any idea or recommendation by which i fix this bug..
Was This Post Helpful? 0
  • +
  • -

#29 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3621
  • View blog
  • Posts: 11,278
  • Joined: 05-May 12

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

Posted 09 January 2013 - 09:52 AM

Yes. Pass good memory addresses so that memory access violations don't occur.
Was This Post Helpful? 0
  • +
  • -

#30 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 09 January 2013 - 10:09 AM

View PostSkydiver, on 09 January 2013 - 09:52 AM, said:

Yes. Pass good memory addresses so that memory access violations don't occur.


for which memory location you are suggesting this .. ?? because i have mention the memory locations in many statements.
Was This Post Helpful? 0
  • +
  • -

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