Change screenshots wording to thumbnails

This commit is contained in:
Michael Delpach 2015-08-06 22:26:30 +08:00
parent 1e524be67e
commit 7f20b7c1ab
7 changed files with 69 additions and 52 deletions

View file

@ -56,6 +56,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\QrCode.Net.0.4.0.0\lib\net40\Gma.QrCodeNet.Encoding.dll</HintPath>
</Reference>
<Reference Include="MegaApiClient, Version=1.1.1.44, Culture=neutral, PublicKeyToken=0480d311efbeb4e2, processorArchitecture=MSIL">
<HintPath>..\..\TDMaker\packages\MegaApiClient.1.1.1\lib\net40\MegaApiClient.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
@ -906,6 +910,7 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Resources\Icon.png" />
</ItemGroup>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net40" />
<package id="QrCode.Net" version="0.4.0.0" targetFramework="net40" />
<package id="SevenZipSharp" version="0.64" targetFramework="net40" />
<package id="MegaApiClient" version="1.1.1" targetFramework="net4" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net4" />
<package id="QrCode.Net" version="0.4.0.0" targetFramework="net4" />
<package id="SevenZipSharp" version="0.64" targetFramework="net4" />
</packages>

View file

@ -58,7 +58,7 @@ private void btnStart_Click(object sender, EventArgs e)
Options.LastVideoPath = mediaPath;
pbProgress.Value = 0;
pbProgress.Maximum = Options.ScreenshotCount;
pbProgress.Maximum = Options.ThumbnailCount;
pbProgress.Visible = true;
btnStart.Visible = false;

View file

@ -1,7 +1,7 @@
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
ShareX - A program that allows you to take thumbnails and share any file type
Copyright © 2007-2015 ShareX Developers
This program is free software; you can redistribute it and/or
@ -31,58 +31,58 @@ namespace ShareX.MediaLib
{
public class VideoThumbnailOptions
{
[Category("Screenshots"), DefaultValue(ThumbnailLocationType.DefaultFolder), Description("Create screenshots in default screenshot folder, same folder as the media file or in a custom folder.")]
[Category("Thumbnails"), DefaultValue(ThumbnailLocationType.DefaultFolder), Description("Create thumbnails in default screenshot folder, same folder as the media file or in a custom folder.")]
public ThumbnailLocationType OutputLocation { get; set; }
[Category("Screenshots"), DefaultValue(""), Description("Output folder where screenshots will get saved."), Editor(typeof(DirectoryNameEditor), typeof(UITypeEditor))]
[Category("Thumbnails"), DefaultValue(""), Description("Output folder where thumbnails will get saved."), Editor(typeof(DirectoryNameEditor), typeof(UITypeEditor))]
public string CustomOutputDirectory { get; set; }
[Category("Screenshots"), DefaultValue(EImageFormat.PNG), Description("Thumbnail image format to save.")]
[Category("Thumbnails"), DefaultValue(EImageFormat.PNG), Description("Thumbnail image format to save.")]
public EImageFormat ImageFormat { get; set; }
[Category("Screenshots"), DefaultValue(9), Description("Total number of screenshots to take.")]
public int ScreenshotCount { get; set; }
[Category("Thumbnails"), DefaultValue(9), Description("Total number of thumbnails to take.")]
public int ThumbnailCount { get; set; }
[Category("Screenshots"), DefaultValue("_Thumbnail"), Description("Suffix to append to the screenshot filename.")]
[Category("Thumbnails"), DefaultValue("_Thumbnail"), Description("Suffix to append to the thumbnail filename.")]
public string FilenameSuffix { get; set; }
[Category("Screenshots"), DefaultValue(false), Description("Choose random frame each time a media file is processed.")]
[Category("Thumbnails"), DefaultValue(false), Description("Choose random frame each time a media file is processed.")]
public bool RandomFrame { get; set; }
[Category("Screenshots"), DefaultValue(true), Description("Upload screenshots.")]
public bool UploadScreenshots { get; set; }
[Category("Thumbnails"), DefaultValue(true), Description("Upload thumbnails.")]
public bool UploadThumbnails { get; set; }
[Category("Screenshots"), DefaultValue(false), Description("After combine screenshots keep single image files.")]
[Category("Thumbnails"), DefaultValue(false), Description("After combine thumbnails keep single image files.")]
public bool KeepScreenshots { get; set; }
[Category("Screenshots"), DefaultValue(false), Description("After all screenshots taken open output directory automatically.")]
[Category("Thumbnails"), DefaultValue(false), Description("After all thumbnails taken open output directory automatically.")]
public bool OpenDirectory { get; set; }
[Category("Screenshots"), DefaultValue(512), Description("Maximum thumbnail width size, 0 means don't resize.")]
[Category("Thumbnails"), DefaultValue(512), Description("Maximum thumbnail width size, 0 means don't resize.")]
public int MaxThumbnailWidth { get; set; }
[Category("Screenshots / Combined"), DefaultValue(true), Description("Combine all screenshots to one large screenshot.")]
[Category("Thumbnails / Combined"), DefaultValue(true), Description("Combine all thumbnails to one large thumbnail.")]
public bool CombineScreenshots { get; set; }
[Category("Screenshots / Combined"), DefaultValue(10), Description("Space between border and content as pixel.")]
[Category("Thumbnails / Combined"), DefaultValue(10), Description("Space between border and content as pixel.")]
public int Padding { get; set; }
[Category("Screenshots / Combined"), DefaultValue(10), Description("Space between screenshots as pixel.")]
[Category("Thumbnails / Combined"), DefaultValue(10), Description("Space between thumbnails as pixel.")]
public int Spacing { get; set; }
[Category("Screenshots / Combined"), DefaultValue(3), Description("Number of screenshots per row.")]
[Category("Thumbnails / Combined"), DefaultValue(3), Description("Number of thumbnails per row.")]
public int ColumnCount { get; set; }
[Category("Screenshots / Combined"), DefaultValue(true), Description("Add video information to the combined screenshot.")]
[Category("Thumbnails / Combined"), DefaultValue(true), Description("Add video information to the combined thumbnail.")]
public bool AddVideoInfo { get; set; }
[Category("Screenshots / Combined"), DefaultValue(true), Description("Add timestamp of screenshot at corner of image.")]
[Category("Thumbnails / Combined"), DefaultValue(true), Description("Add timestamp of thumbnail at corner of image.")]
public bool AddTimestamp { get; set; }
[Category("Screenshots / Combined"), DefaultValue(true), Description("Draw rectangle shadow behind thumbnails.")]
[Category("Thumbnails / Combined"), DefaultValue(true), Description("Draw rectangle shadow behind thumbnails.")]
public bool DrawShadow { get; set; }
[Category("Screenshots / Combined"), DefaultValue(true), Description("Draw border around thumbnails.")]
[Category("Thumbnails / Combined"), DefaultValue(true), Description("Draw border around thumbnails.")]
public bool DrawBorder { get; set; }
public string DefaultOutputDirectory, LastVideoPath;

View file

@ -57,9 +57,9 @@ public VideoThumbnailer(string mediaPath, string ffmpegPath, VideoThumbnailOptio
public List<VideoThumbnailInfo> TakeThumbnails()
{
List<VideoThumbnailInfo> tempScreenshots = new List<VideoThumbnailInfo>();
List<VideoThumbnailInfo> tempThumbnails = new List<VideoThumbnailInfo>();
for (int i = 0; i < Options.ScreenshotCount; i++)
for (int i = 0; i < Options.ThumbnailCount; i++)
{
string mediaFileName = Path.GetFileNameWithoutExtension(MediaPath);
@ -71,70 +71,70 @@ public List<VideoThumbnailInfo> TakeThumbnails()
}
else
{
timeSliceElapsed = GetTimeSlice(Options.ScreenshotCount) * (i + 1);
timeSliceElapsed = GetTimeSlice(Options.ThumbnailCount) * (i + 1);
}
string filename = string.Format("{0}-{1}.{2}", mediaFileName, timeSliceElapsed, Options.ImageFormat.GetDescription());
string tempScreenshotPath = Path.Combine(GetOutputDirectory(), filename);
string tempThumbnailPath = Path.Combine(GetOutputDirectory(), filename);
using (Process p = new Process())
{
ProcessStartInfo psi = new ProcessStartInfo(FFmpegPath);
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.Arguments = string.Format("-ss {0} -i \"{1}\" -f image2 -vframes 1 -y \"{2}\"", timeSliceElapsed, MediaPath, tempScreenshotPath);
psi.Arguments = string.Format("-ss {0} -i \"{1}\" -f image2 -vframes 1 -y \"{2}\"", timeSliceElapsed, MediaPath, tempThumbnailPath);
p.StartInfo = psi;
p.Start();
p.WaitForExit(1000 * 30);
}
if (File.Exists(tempScreenshotPath))
if (File.Exists(tempThumbnailPath))
{
VideoThumbnailInfo screenshotInfo = new VideoThumbnailInfo(tempScreenshotPath)
VideoThumbnailInfo screenshotInfo = new VideoThumbnailInfo(tempThumbnailPath)
{
Timestamp = TimeSpan.FromSeconds(timeSliceElapsed)
};
tempScreenshots.Add(screenshotInfo);
tempThumbnails.Add(screenshotInfo);
}
OnProgressChanged(i + 1, Options.ScreenshotCount);
OnProgressChanged(i + 1, Options.ThumbnailCount);
}
return Finish(tempScreenshots);
return Finish(tempThumbnails);
}
private List<VideoThumbnailInfo> Finish(List<VideoThumbnailInfo> tempScreenshots)
private List<VideoThumbnailInfo> Finish(List<VideoThumbnailInfo> tempThumbnails)
{
List<VideoThumbnailInfo> screenshots = new List<VideoThumbnailInfo>();
List<VideoThumbnailInfo> thumbnails = new List<VideoThumbnailInfo>();
if (tempScreenshots != null && tempScreenshots.Count > 0)
if (tempThumbnails != null && tempThumbnails.Count > 0)
{
if (Options.CombineScreenshots)
{
using (Image img = CombineScreenshots(tempScreenshots))
using (Image img = CombineScreenshots(tempThumbnails))
{
string tempFilepath = Path.Combine(GetOutputDirectory(), Path.GetFileNameWithoutExtension(MediaPath) + Options.FilenameSuffix + "." + Options.ImageFormat.GetDescription());
ImageHelpers.SaveImage(img, tempFilepath);
screenshots.Add(new VideoThumbnailInfo(tempFilepath));
thumbnails.Add(new VideoThumbnailInfo(tempFilepath));
}
if (!Options.KeepScreenshots)
{
tempScreenshots.ForEach(x => File.Delete(x.Filepath));
tempThumbnails.ForEach(x => File.Delete(x.Filepath));
}
}
else
{
screenshots.AddRange(tempScreenshots);
thumbnails.AddRange(tempThumbnails);
}
if (Options.OpenDirectory && screenshots.Count > 0)
if (Options.OpenDirectory && thumbnails.Count > 0)
{
Helpers.OpenFolderWithFile(screenshots[0].Filepath);
Helpers.OpenFolderWithFile(thumbnails[0].Filepath);
}
}
return screenshots;
return thumbnails;
}
protected void OnProgressChanged(int current, int length)
@ -168,16 +168,16 @@ private int GetRandomTimeSlice(int start)
{
List<int> mediaSeekTimes = new List<int>();
for (int i = 1; i < Options.ScreenshotCount + 2; i++)
for (int i = 1; i < Options.ThumbnailCount + 2; i++)
{
mediaSeekTimes.Add(GetTimeSlice(Options.ScreenshotCount + 2) * i);
mediaSeekTimes.Add(GetTimeSlice(Options.ThumbnailCount + 2) * i);
}
Random random = new Random();
return (int)(random.NextDouble() * (mediaSeekTimes[start + 1] - mediaSeekTimes[start]) + mediaSeekTimes[start]);
}
private Image CombineScreenshots(List<VideoThumbnailInfo> screenshots)
private Image CombineScreenshots(List<VideoThumbnailInfo> thumbnails)
{
List<Image> images = new List<Image>();
Image finalImage = null;
@ -197,9 +197,9 @@ private Image CombineScreenshots(List<VideoThumbnailInfo> screenshots)
}
}
foreach (VideoThumbnailInfo screenshot in screenshots)
foreach (VideoThumbnailInfo thumbnail in thumbnails)
{
Image img = Image.FromFile(screenshot.Filepath);
Image img = Image.FromFile(thumbnail.Filepath);
if (Options.MaxThumbnailWidth > 0 && img.Width > Options.MaxThumbnailWidth)
{
@ -273,7 +273,7 @@ private Image CombineScreenshots(List<VideoThumbnailInfo> screenshots)
using (Font font = new Font("Arial", 10, FontStyle.Bold))
{
ImageHelpers.DrawTextWithShadow(g, screenshots[i].Timestamp.ToString(),
ImageHelpers.DrawTextWithShadow(g, thumbnails[i].Timestamp.ToString(),
new Point(offsetX + timestampOffset, offsetY + timestampOffset), font, Color.White, Color.Black);
}
}

View file

@ -630,7 +630,7 @@ public static void OpenVideoThumbnailer(TaskSettings taskSettings = null)
VideoThumbnailerForm thumbnailerForm = new VideoThumbnailerForm(taskSettings.CaptureSettings.FFmpegOptions.CLIPath, Program.Settings.VideoThumbnailOptions);
thumbnailerForm.ThumbnailsTaken += thumbnails =>
{
if (Program.Settings.VideoThumbnailOptions.UploadScreenshots)
if (Program.Settings.VideoThumbnailOptions.UploadThumbnails)
{
foreach (VideoThumbnailInfo thumbnailInfo in thumbnails)
{