TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vaithi shwari
NA
1
4.1k
how to create a thumbnail from video in window form c#
Sep 21 2016 6:12 AM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
namespace Sample_Thumbnail
{
public partial class Form : System.Windows.Forms.Form
{
private Image imgThumb;
public Form()
{
InitializeComponent();
}
public static string generateThumb(string file)
{
string thumb = "";
try
{
FileInfo fi = new FileInfo(file);
string filename = Path.GetFileNameWithoutExtension(fi.Name);
Random random = new Random();
int rand = random.Next(1, 9999999);
string newfilename = "C:\\Users\\user\\Desktop\\Preethi\\Sample_Thumbnail\\Sample_Thumbnail\\bin\\Debug\\" + filename + "___(" + rand.ToString() + ").jpg";
var processInfo = new ProcessStartInfo();
processInfo.FileName = @"C:\Users\user\Desktop\Preethi\Sample_Thumbnail\Sample_Thumbnail\bin\Debug\ffmpeg.exe";
processInfo.Arguments = string.Format("-ss {0} -i {1} -f image2 -vframes 1 -y {2}", 5, "\"" + file + "\"", "\"" + newfilename + "\"");
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
using (var process = new Process())
{
process.StartInfo = processInfo;
process.Start();
process.WaitForExit();
thumb = newfilename;
}
}
catch (Exception ex)
{
string error = ex.Message;
}
return thumb;
}
private void Generate_Click(object sender, EventArgs e)
{
string thumb = "";
Image image = null;
// Check if textbox has a value
if (txtFileNm.Text != String.Empty)
thumb = generateThumb(txtFileNm.Text);
image = Image.FromFile(thumb.ToString());
if (image != null)
{
imgThumb = image.GetThumbnailImage(100, 100, null, new IntPtr());
// Refresh();
}
pictureBox1.Image = imgThumb;
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
if (imgThumb != null)
e.Graphics.DrawImage(imgThumb, 30, 20, imgThumb.Width, imgThumb.Height);
}
private void button1_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
txtFileNm.Text = openFileDialog1.FileName;
}
}
}
}
Reply
Answers (
3
)
How to create a web setup project in Visual Studio 2013 ?
Visual Studio Setup Program Custom User input to Registry ?