I am looking for a way to convert all of the jpeg images in a particular folder to a video file. Either via coding or a control. any ideas?
Loading
I am looking for a way to convert all of the jpeg images in a particular folder to a video file. Either via coding or a control. any ideas?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
ALEX-GRIM2 reputationPosted Jan 19, 2006, 3:15 PM EST
Marvin ReidRank #1,963 · 746 reputationPosted May 1, 2023, 4:55 PM EDT
You can convert all your images to a video programatically by leveraging the ConvertCtrl class. Here is a snippet of code that highlights this based on the below tutorial:
static void Generate() { // Create sample source object SampleSource smpsrc = new SampleSource(); ConvertCtrl convertCtrl = new ConvertCtrl(true); // Create a new media type wrapper MediaType mt = new MediaType(); string sourceDirectory = @"C:\LEADTOOLS22\Resources\Images"; string outputFile = @"C:\LEADTOOLS22\Resources\Images\Video-Result.avi"; double fps = 5.0; //frames per second Bitmap bmp = new Bitmap(800, 600, PixelFormat.Format24bppRgb); double AvgTimePerFrame = (10000000 / fps); string[] files = Directory.GetFiles(sourceDirectory, "*.jpg"); // Set the type to 24-bit RGB video mt.Type = Constants.MEDIATYPE_Video; mt.SubType = Constants.MEDIASUBTYPE_RGB24; // Set the format mt.FormatType = Constants.FORMAT_VideoInfo; VideoInfoHeader vih = new VideoInfoHeader(); int bmpSize = GetBitmapSize(bmp); // Setup the video info header vih.bmiHeader.biCompression = 0; // BI_RGB vih.bmiHeader.biBitCount = 24; vih.bmiHeader.biWidth = 800; vih.bmiHeader.biHeight = 600; vih.bmiHeader.biPlanes = 1; vih.bmiHeader.biSizeImage = bmpSize; vih.bmiHeader.biClrImportant = 0; vih.AvgTimePerFrame.lowpart = (int)AvgTimePerFrame; vih.dwBitRate = (int)(bmpSize * 8 * fps); mt.SetVideoFormatData(vih, null, 0); // Set fixed size samples matching the bitmap size mt.SampleSize = bmpSize; mt.FixedSizeSamples = true; // Assign the source media type smpsrc.SetMediaType(mt); // Do NOT set a compressor convertCtrl.VideoCompressors.MCmpMJpeg.Selected = true; // Assign the converter source convertCtrl.SourceObject = smpsrc; // Set the output file name convertCtrl.TargetFile = outputFile; convertCtrl.TargetFormat = TargetFormatType.AVI; convertCtrl.StartConvert(); }https://www.leadtools.com/help/sdk/tutorials/dotnet-fx-console-create-a-video-from-still-images.html