Skip to content

Commit

Permalink
Initial Commit - Working Version
Browse files Browse the repository at this point in the history
  • Loading branch information
c0der4t committed Feb 10, 2023
1 parent 22c6a6f commit fc32cd4
Show file tree
Hide file tree
Showing 55 changed files with 497 additions and 0 deletions.
Binary file added .vs/ProjectEvaluation/shortsmaker.metadata.v5.2
Binary file not shown.
Binary file added .vs/ProjectEvaluation/shortsmaker.projects.v5.2
Binary file not shown.
Binary file added .vs/ShortsMaker/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file added .vs/ShortsMaker/v17/.futdcache.v2
Binary file not shown.
Binary file added .vs/ShortsMaker/v17/.suo
Binary file not shown.
114 changes: 114 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
using System.Diagnostics;

Console.WriteLine("Path to Video");
string filePath = Console.ReadLine();

Console.WriteLine("How many random clips to generate?");
int amountOfClips = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("If you'd like to append a video to the end, give me it's path:");
string outroPath;
try
{
outroPath = Console.ReadLine();
}
finally
{

}

string outputDirectory = Path.GetDirectoryName(filePath);
string outputPrefix = Path.GetFileNameWithoutExtension(filePath);
string outputExtension = Path.GetExtension(filePath);
int interval = 50;

var rand = new Random();
var startTimes = Enumerable.Range(0, (int)Math.Ceiling(GetVideoDuration(filePath) / interval))
.OrderBy(x => rand.Next())
.Select(x => x * interval)
.ToList();
startTimes.Add(int.MaxValue);

int startIndex = 0;

for (int i = 0; i < startTimes.Count - 1; i++)
{
if (i < amountOfClips)
{
string outputFile = Path.Combine(outputDirectory, $"{startTimes[i] / 60}_{i}{outputExtension}");
SplitVideo(filePath, outputFile, startTimes[i], interval, outroPath);
}
}


static double GetVideoDuration(string filePath)
{
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "ffprobe",
Arguments = $"-v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 \"{filePath}\"",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
}
};
process.Start();
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
return double.Parse(output);
}

static void SplitVideo(string filePath, string outputFile, int startTime, int duration, string outroPath = "")
{
double timeOffset = 0.5;

// Create a process to run ffmpeg
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "ffmpeg",
Arguments = $"-i \"{filePath}\" -ss {startTime} -t {duration} -async 1 -c copy \"{outputFile}\"",
UseShellExecute = false,
CreateNoWindow = true,
}
};

// Start the ffmpeg process and wait for it to finish
process.Start();
process.WaitForExit();

Console.WriteLine($"Created clip - {outputFile}");

// If the outroPath is not empty, concatenate the outro to the split video
if (!string.IsNullOrEmpty(outroPath))
{
// Generate the concat file list
string concatList = $"file '{outputFile}'\nfile '{outroPath}'";
string concatListPath = Path.Combine(Path.GetDirectoryName(outputFile), "concat-list.txt");

// Write the concat file list to a file
File.WriteAllText(concatListPath, concatList);

// Generate the concatenated output file path
string concatenatedOutputPath = Path.Combine(Path.GetDirectoryName(outputFile), Path.GetFileNameWithoutExtension(outputFile) + "-with-outro.mp4");

// Create a process to run ffmpeg to concatenate the split video and outro
var concatProcess = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "ffmpeg",
Arguments = $"-f concat -safe 0 -i \"{concatListPath}\" -async 1 -c copy \"{concatenatedOutputPath}\"",
UseShellExecute = false,
CreateNoWindow = true,
}
};

// Start the ffmpeg concat process and wait for it to finish
concatProcess.Start();
concatProcess.WaitForExit();
}
}
10 changes: 10 additions & 0 deletions ShortsMaker.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
25 changes: 25 additions & 0 deletions ShortsMaker.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShortsMaker", "ShortsMaker.csproj", "{80DCBF14-8DE9-48DE-9853-42ACF9FCD55E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{80DCBF14-8DE9-48DE-9853-42ACF9FCD55E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80DCBF14-8DE9-48DE-9853-42ACF9FCD55E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80DCBF14-8DE9-48DE-9853-42ACF9FCD55E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80DCBF14-8DE9-48DE-9853-42ACF9FCD55E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8DB52F43-F84B-4E5A-84F0-CF0080C64B44}
EndGlobalSection
EndGlobal
Binary file added bin/Release/ShortsMaker.exe
Binary file not shown.
23 changes: 23 additions & 0 deletions bin/Release/net6.0/ShortsMaker.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {
"ShortsMaker/1.0.0": {
"runtime": {
"ShortsMaker.dll": {}
}
}
}
},
"libraries": {
"ShortsMaker/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Binary file added bin/Release/net6.0/ShortsMaker.dll
Binary file not shown.
Binary file added bin/Release/net6.0/ShortsMaker.exe
Binary file not shown.
Binary file added bin/Release/net6.0/ShortsMaker.pdb
Binary file not shown.
12 changes: 12 additions & 0 deletions bin/Release/net6.0/ShortsMaker.runtimeconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net6.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "6.0.0"
},
"configProperties": {
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
23 changes: 23 additions & 0 deletions obj/Debug/net6.0/ShortsMaker.AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("ShortsMaker")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("ShortsMaker")]
[assembly: System.Reflection.AssemblyTitleAttribute("ShortsMaker")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

1 change: 1 addition & 0 deletions obj/Debug/net6.0/ShortsMaker.AssemblyInfoInputs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
307baa7b947ee3d9fcc5e133e32bd7cbe6183386
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
is_global = true
build_property.TargetFramework = net6.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = ShortsMaker
build_property.ProjectDir = C:\Users\monte\Dev\ShortsMaker\
8 changes: 8 additions & 0 deletions obj/Debug/net6.0/ShortsMaker.GlobalUsings.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
Binary file added obj/Debug/net6.0/ShortsMaker.assets.cache
Binary file not shown.
Binary file not shown.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
325530ce015937720220a30314168b1247daa127
15 changes: 15 additions & 0 deletions obj/Debug/net6.0/ShortsMaker.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
C:\Users\monte\Dev\ShortsMaker\bin\Debug\net6.0\ShortsMaker.exe
C:\Users\monte\Dev\ShortsMaker\bin\Debug\net6.0\ShortsMaker.deps.json
C:\Users\monte\Dev\ShortsMaker\bin\Debug\net6.0\ShortsMaker.runtimeconfig.json
C:\Users\monte\Dev\ShortsMaker\bin\Debug\net6.0\ShortsMaker.dll
C:\Users\monte\Dev\ShortsMaker\bin\Debug\net6.0\ShortsMaker.pdb
C:\Users\monte\Dev\ShortsMaker\obj\Debug\net6.0\ShortsMaker.csproj.AssemblyReference.cache
C:\Users\monte\Dev\ShortsMaker\obj\Debug\net6.0\ShortsMaker.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\monte\Dev\ShortsMaker\obj\Debug\net6.0\ShortsMaker.AssemblyInfoInputs.cache
C:\Users\monte\Dev\ShortsMaker\obj\Debug\net6.0\ShortsMaker.AssemblyInfo.cs
C:\Users\monte\Dev\ShortsMaker\obj\Debug\net6.0\ShortsMaker.csproj.CoreCompileInputs.cache
C:\Users\monte\Dev\ShortsMaker\obj\Debug\net6.0\ShortsMaker.dll
C:\Users\monte\Dev\ShortsMaker\obj\Debug\net6.0\refint\ShortsMaker.dll
C:\Users\monte\Dev\ShortsMaker\obj\Debug\net6.0\ShortsMaker.pdb
C:\Users\monte\Dev\ShortsMaker\obj\Debug\net6.0\ShortsMaker.genruntimeconfig.cache
C:\Users\monte\Dev\ShortsMaker\obj\Debug\net6.0\ref\ShortsMaker.dll
Binary file added obj/Debug/net6.0/ShortsMaker.dll
Binary file not shown.
1 change: 1 addition & 0 deletions obj/Debug/net6.0/ShortsMaker.genruntimeconfig.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
264d5ae563c115e930251a381ced6c696efdc959
Binary file added obj/Debug/net6.0/ShortsMaker.pdb
Binary file not shown.
1 change: 1 addition & 0 deletions obj/Debug/net6.0/_IsIncrementalBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj\Debug\net6.0\\_IsIncrementalBuild
Binary file added obj/Debug/net6.0/apphost.exe
Binary file not shown.
Binary file added obj/Debug/net6.0/ref/ShortsMaker.dll
Binary file not shown.
Binary file added obj/Debug/net6.0/refint/ShortsMaker.dll
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
23 changes: 23 additions & 0 deletions obj/Release/net6.0/ShortsMaker.AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("ShortsMaker")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("ShortsMaker")]
[assembly: System.Reflection.AssemblyTitleAttribute("ShortsMaker")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

1 change: 1 addition & 0 deletions obj/Release/net6.0/ShortsMaker.AssemblyInfoInputs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0d2d525e48a9ed5c86589592b09c9513e2cc4d90
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
is_global = true
build_property.TargetFramework = net6.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = ShortsMaker
build_property.ProjectDir = C:\Users\monte\Dev\New folder\ShortsMaker\
8 changes: 8 additions & 0 deletions obj/Release/net6.0/ShortsMaker.GlobalUsings.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
Binary file added obj/Release/net6.0/ShortsMaker.assets.cache
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c6b4155d80292e00e11379947b3899fdd446b4af
30 changes: 30 additions & 0 deletions obj/Release/net6.0/ShortsMaker.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
C:\Users\monte\Dev\ShortsMaker\bin\Release\net6.0\ShortsMaker.exe
C:\Users\monte\Dev\ShortsMaker\bin\Release\net6.0\ShortsMaker.deps.json
C:\Users\monte\Dev\ShortsMaker\bin\Release\net6.0\ShortsMaker.runtimeconfig.json
C:\Users\monte\Dev\ShortsMaker\bin\Release\net6.0\ShortsMaker.dll
C:\Users\monte\Dev\ShortsMaker\bin\Release\net6.0\ShortsMaker.pdb
C:\Users\monte\Dev\ShortsMaker\obj\Release\net6.0\ShortsMaker.csproj.AssemblyReference.cache
C:\Users\monte\Dev\ShortsMaker\obj\Release\net6.0\ShortsMaker.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\monte\Dev\ShortsMaker\obj\Release\net6.0\ShortsMaker.AssemblyInfoInputs.cache
C:\Users\monte\Dev\ShortsMaker\obj\Release\net6.0\ShortsMaker.AssemblyInfo.cs
C:\Users\monte\Dev\ShortsMaker\obj\Release\net6.0\ShortsMaker.csproj.CoreCompileInputs.cache
C:\Users\monte\Dev\ShortsMaker\obj\Release\net6.0\ShortsMaker.dll
C:\Users\monte\Dev\ShortsMaker\obj\Release\net6.0\refint\ShortsMaker.dll
C:\Users\monte\Dev\ShortsMaker\obj\Release\net6.0\ShortsMaker.pdb
C:\Users\monte\Dev\ShortsMaker\obj\Release\net6.0\ShortsMaker.genruntimeconfig.cache
C:\Users\monte\Dev\ShortsMaker\obj\Release\net6.0\ref\ShortsMaker.dll
C:\Users\monte\Dev\New folder\ShortsMaker\bin\Release\net6.0\ShortsMaker.exe
C:\Users\monte\Dev\New folder\ShortsMaker\bin\Release\net6.0\ShortsMaker.deps.json
C:\Users\monte\Dev\New folder\ShortsMaker\bin\Release\net6.0\ShortsMaker.runtimeconfig.json
C:\Users\monte\Dev\New folder\ShortsMaker\bin\Release\net6.0\ShortsMaker.dll
C:\Users\monte\Dev\New folder\ShortsMaker\bin\Release\net6.0\ShortsMaker.pdb
C:\Users\monte\Dev\New folder\ShortsMaker\obj\Release\net6.0\ShortsMaker.csproj.AssemblyReference.cache
C:\Users\monte\Dev\New folder\ShortsMaker\obj\Release\net6.0\ShortsMaker.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\monte\Dev\New folder\ShortsMaker\obj\Release\net6.0\ShortsMaker.AssemblyInfoInputs.cache
C:\Users\monte\Dev\New folder\ShortsMaker\obj\Release\net6.0\ShortsMaker.AssemblyInfo.cs
C:\Users\monte\Dev\New folder\ShortsMaker\obj\Release\net6.0\ShortsMaker.csproj.CoreCompileInputs.cache
C:\Users\monte\Dev\New folder\ShortsMaker\obj\Release\net6.0\ShortsMaker.dll
C:\Users\monte\Dev\New folder\ShortsMaker\obj\Release\net6.0\refint\ShortsMaker.dll
C:\Users\monte\Dev\New folder\ShortsMaker\obj\Release\net6.0\ShortsMaker.pdb
C:\Users\monte\Dev\New folder\ShortsMaker\obj\Release\net6.0\ShortsMaker.genruntimeconfig.cache
C:\Users\monte\Dev\New folder\ShortsMaker\obj\Release\net6.0\ref\ShortsMaker.dll
Binary file added obj/Release/net6.0/ShortsMaker.dll
Binary file not shown.
1 change: 1 addition & 0 deletions obj/Release/net6.0/ShortsMaker.genruntimeconfig.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c96adf2a86903e7d9be2e9931ef812ca038bad61
Binary file added obj/Release/net6.0/ShortsMaker.pdb
Binary file not shown.
1 change: 1 addition & 0 deletions obj/Release/net6.0/_IsIncrementalBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj\Release\net6.0\\_IsIncrementalBuild
Binary file added obj/Release/net6.0/apphost.exe
Binary file not shown.
Binary file added obj/Release/net6.0/ref/ShortsMaker.dll
Binary file not shown.
Binary file added obj/Release/net6.0/refint/ShortsMaker.dll
Binary file not shown.
Loading

0 comments on commit fc32cd4

Please sign in to comment.