Hi guys,

I'm looking for any help in converting image files to video files by reading a full image folder using C# .Net 2.0 onwards.


thanks,
Vishnu Shayan

Dani AI

Generated

— a practical route is to treat an image folder as a numbered image sequence and hand that sequence to a proven encoder (rather than reimplementing codecs). 's suggestion to call an existing converter from C# is the fastest, most robust option: FFmpeg accepts image sequences via its image2 demuxer and can write AVI, MPEG, MP4, etc. (FFmpeg image2 docs). (ffmpeg.org)

A couple of ready-to-run FFmpeg command lines (images must be named in a numeric sequence, e.g. img0001.jpg, img0002.jpg):

ffmpeg -framerate 30 -i img%04d.jpg -c:v libx264 -preset medium -crf 18 -pix_fmt yuv420p output.mp4
ffmpeg -framerate 25 -i frame_%04d.png -c:v mjpeg -q:v 3 output.avi

Use -start_number N if numbering does not begin at 1, or -pattern_type glob for non-numbered file sets. See the image2 notes for details. (ffmpeg.org)

Calling FFmpeg from C# can be as simple as launching the CLI and capturing its output. Example pattern (synchronous read shown for brevity — async read is recommended for long runs):

using System.Diagnostics;

var psi = new ProcessStartInfo {
  FileName = "ffmpeg",
  Arguments = "-framerate 30 -i img%04d.jpg -c:v libx264 -pix_fmt yuv420p out.mp4",
  UseShellExecute = false,
  RedirectStandardError = true,
  RedirectStandardOutput = true,
  CreateNoWindow = true
};

using(var p = Process.Start(psi)) {
  string log = p.StandardError.ReadToEnd();
  p.WaitForExit();
}

Remember to set UseShellExecute = false and redirect the streams when capturing output. (learn.microsoft.com)

If an all-managed library is preferred, options include high-level wrappers like Xabe.FFmpeg, low-level bindings like FFmpeg.AutoGen, or frameworks with VideoWriter support such as Accord.Video.FFMPEG / OpenCvSharp. Licensing and platform details differ (Accord's FFMPEG package is GPL; Xabe documents its terms), so pick according to project constraints. (ffmpeg.xabe.net)

Quick troubleshooting checklist: ensure sequential, zero-padded filenames; identical frame sizes (or apply -vf scale,pad); set -pix_fmt yuv420p for broad player compatibility; handle EXIF rotations before encoding; and make sure FFmpeg binaries are available on PATH or bundled. The FFmpeg image2 docs and VideoWriter docs cover these common pitfalls. (ffmpeg.org)

Recommended Answers

All 3 Replies

That kind of conversions are usually made between image formats or video formats, seldom from images to video. There are plenty of free conversion applications and you'll find them with a little googling.

If you find an application that converts a bunch of images to some video file, check if it supports commandline or batch conversion. Then you could call that converter from your C# application. That's the easiest way.

HTH

Thanks HTH ill check tat, but i'm still not sure if i can find such a converter.. i have googled about it wit no luck till now...

Vishnu Shayan

First googling and two pretty good results. Both are jpeg to avi converters:
, freeware for Windows
JPEG to MJPEG-AVI converter, open source, hasn't been developed for a few years, source code available (C-code for unix I guess), could be possibly ported to C#.

HTH

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.