Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I read a video that has 1000 frames then, I want to save these frames from number 0000 to 1000. I did my code but save the frames from 1,2,3,....1000
how to make all of them have 4 digits, I mean starting with 0001,0002,0003,....1000
Can anyone give me an idea because I don't find anything about my situation?
thanks

What I have tried:

FileName1 = "D:\\Cameras\\VideoCamera1\\output1.mp4";
_capture1 = new VideoCapture(FileName1);
Readframe1 = new Mat();
Readframe1 = _capture1.QueryFrame();
 double framenumber = _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES);
Readframe1.Save("D:\\cam1\\" + framenumber.ToString() + ".jpg");
Posted
Updated 29-Nov-19 8:52am

1 solution

You could try
C#
framenumber.ToString("0000")
Custom numeric format strings[^]
 
Share this answer
 
Comments
Richard Deeming 29-Nov-19 14:53pm    
Or framenumber.ToString("D4")
Standard Numeric Format Strings | Microsoft Docs[^]
:)
phil.o 29-Nov-19 14:58pm    
Right :)
RickZeeland 29-Nov-19 15:20pm    
Or framenumber.ToString().PadLeft(4, '0')
https://docs.microsoft.com/en-us/dotnet/api/system.string.padleft?view=netframework-4.8
phil.o 29-Nov-19 15:29pm    
You should provide this as an alternative answer :)
RickZeeland 29-Nov-19 15:36pm    
I wouldn't dare, after being accused of being a 'rep hunter' last week :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900