Skip to content
This repository was archived by the owner on Apr 1, 2024. It is now read-only.

Commit 1aed6d3

Browse files
committed
Project added
1 parent 617642d commit 1aed6d3

File tree

7 files changed

+230
-0
lines changed

7 files changed

+230
-0
lines changed

BatchEncode.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29102.190
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HandBrakeCLIBatchEncode", "HandBrakeCLIBatchEncode\HandBrakeCLIBatchEncode.csproj", "{ECC4E190-29AB-4864-A08C-409B9CCDAA64}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{ECC4E190-29AB-4864-A08C-409B9CCDAA64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{ECC4E190-29AB-4864-A08C-409B9CCDAA64}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{ECC4E190-29AB-4864-A08C-409B9CCDAA64}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{ECC4E190-29AB-4864-A08C-409B9CCDAA64}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {29583BD1-D70E-4F69-8CFB-F6715CB9B983}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Windows Registry Editor Version 5.00
2+
3+
[HKEY_CLASSES_ROOT\Directory\shell\BatchEncodeMenu]
4+
"MUIVerb"="Batch Encode Videos"
5+
"SubCommands"="tv-kids;tv-mobile"
6+
"icon"="D:\\OneDrive\\Pictures\\Operational\\video-play-4-multi-size.ico"
7+
"Position"="Top"
8+
9+
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\tv-kids]
10+
@="TV Shows - Kids"
11+
12+
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\tv-kids\command]
13+
@="\"C:\\Utilities\\HandBrakeCLI\\BatchEncode.exe\" \"%1\" --preset-import-file \"C:\\Utilities\\HandBrakeCLI\\presets\\tv-kids-preset.json\" \"TV Shows - Kids\" 128"
14+
15+
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\tv-mobile]
16+
@="TV Shows - Mobile"
17+
18+
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\tv-mobile\command]
19+
@="\"C:\\Utilities\\HandBrakeCLI\\BatchEncode.exe\" \"%1\" --preset-import-file \"C:\\Utilities\\HandBrakeCLI\\presets\\tv-mobile-preset.json\" \"TV Shows - Mobile\" 64"

HandBrakeCLIBatchEncode/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{ECC4E190-29AB-4864-A08C-409B9CCDAA64}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>BatchEncode</RootNamespace>
10+
<AssemblyName>BatchEncode</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Program.cs" />
47+
<Compile Include="Properties\AssemblyInfo.cs" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<None Include="App.config" />
51+
</ItemGroup>
52+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
53+
</Project>

HandBrakeCLIBatchEncode/Program.cs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading;
6+
7+
namespace BatchEncode
8+
{
9+
class Program
10+
{
11+
static void Main(string[] args)
12+
{
13+
Console.Out.WriteLine("");
14+
Console.Out.WriteLine(" ____.__________ ");
15+
Console.Out.WriteLine(" | |\\______ \\");
16+
Console.Out.WriteLine(" | | | | _ /");
17+
Console.Out.WriteLine(" /\\__ | | | | \\");
18+
Console.Out.WriteLine(" \\________ | | ______ /");
19+
Console.Out.WriteLine(" \\/");
20+
Console.Out.WriteLine("");
21+
22+
EncodeVideos(args[0], args[1], args[2]);
23+
}
24+
25+
26+
public static void EncodeVideos(string root, string presetPath, string audioByteRate)
27+
{
28+
string[] filesList = Directory.GetFiles(root);
29+
30+
foreach (string file in filesList)
31+
{
32+
FileInfo info = new FileInfo(file);
33+
34+
if (info.Extension.ToLower().In(".mp4", ".avi", ".mov", ".mkv", ".flv", ".wmv", ".mpv", ".mpeg", ".m4v", ".3gp", ".3g2", ".f4v", ".f4a", ".f4b"))
35+
{
36+
string newFileName = info.DirectoryName + "\\" + Path.GetFileNameWithoutExtension(file) + "_" + info.Extension;
37+
38+
File.Move(file, newFileName);
39+
EncodeVideo(newFileName, file, presetPath, audioByteRate);
40+
}
41+
}
42+
}
43+
44+
private static bool EncodeVideo(string inputFile, string outputFile, string presetPath, string audioByteRate)
45+
{
46+
string arguments = @"-i """ + inputFile + @""" -o """ + outputFile + @""" --preset-import-file """ + presetPath + @""" ""TV Shows - Kids"" -B " + audioByteRate;
47+
48+
using (Process proc = new Process())
49+
{
50+
Console.Out.Write("Encoding video: " + outputFile);
51+
52+
proc.StartInfo.FileName = @"C:\Utilities\HandBrakeCLI\HandBrakeCLI.exe";
53+
proc.StartInfo.Arguments = arguments;
54+
proc.StartInfo.UseShellExecute = true;
55+
proc.StartInfo.RedirectStandardOutput = false;
56+
proc.Start();
57+
proc.WaitForExit();
58+
59+
Console.Out.Write(".. Done\n");
60+
}
61+
62+
try
63+
{
64+
File.Delete(inputFile);
65+
}
66+
catch
67+
{
68+
Thread.Sleep(1000);
69+
70+
try
71+
{
72+
File.Delete(inputFile);
73+
}
74+
catch
75+
{
76+
77+
}
78+
}
79+
80+
return true;
81+
}
82+
}
83+
84+
public static class SystemExtensions
85+
{
86+
public static bool In<T>(this T needle, params T[] haystack)
87+
{
88+
return haystack.Contains(needle);
89+
}
90+
}
91+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("BatchEncode")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("BatchEncode")]
13+
[assembly: AssemblyCopyright("Copyright © 2019")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("ecc4e190-29ab-4864-a08c-409b9ccdaa64")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

dist/BatchEncode.exe

7 KB
Binary file not shown.

0 commit comments

Comments
 (0)