I want to generate thumbnail from a video URL in C#. I have searched a lot to find a neat way but no success. I have used Nreco
and MediaToolKit
but none of them extract thumbnail image. using ffmpeg also has mumbo jumbos which didn't worked!
using NReco:
var ffMpeg = new NReco.VideoConverter.FFMpegConverter();
string thumbnailJPEGpath = "http://localhost:81882/content/hashem.jpeg";
ffMpeg.GetVideoThumbnail(videoUrl,thumbnailJPEGpath);
using ffmpeg:
try
{
System.Diagnostics.Process ffmpeg;
string video;
string thumb;
video = Server.MapPath("~/Content/Movies/bye.mp4");
thumb = Server.MapPath("~/Content/frame.jpg");
ffmpeg = new System.Diagnostics.Process();
ffmpeg.StartInfo.Arguments = " -i " + video + " -ss 00:00:07 -vframes 1 -f image2 -vcodec mjpeg " + thumb;
ffmpeg.StartInfo.FileName = Server.MapPath("~/Content/ffmpeg.exe");
ffmpeg.Start();
ffmpeg.WaitForExit();
ffmpeg.Close();
}
catch (Exception ex)
{
Response.Write("Error: " + ex.Message);
}
to consider video files are not local and I have only a direct link to the file:
e.g.:http://phytonord.com/Film-Series/hana/26.mp4
does anyone has any solution? any sample code that works?