Skip to content

Commit

Permalink
Added feature to merge videos and upload to YouTube with "chapters" i…
Browse files Browse the repository at this point in the history
…n the description
  • Loading branch information
maxim-zhao committed Sep 16, 2021
1 parent f936f0f commit f8085a3
Show file tree
Hide file tree
Showing 3 changed files with 325 additions and 98 deletions.
33 changes: 25 additions & 8 deletions LibSidWiz/ProcessWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ public class ProcessWrapper: IDisposable
private readonly Process _process;
private readonly BlockingCollection<string> _lines = new BlockingCollection<string>(new ConcurrentQueue<string>());
private readonly CancellationTokenSource _cancellationTokenSource;
private int _streamCount;

public ProcessWrapper(string filename, string arguments, bool captureStdErr = false)
public ProcessWrapper(string filename, string arguments, bool captureStdErr = false, bool captureStdOut = true, bool showConsole = false)
{
_cancellationTokenSource = new CancellationTokenSource();

Expand All @@ -22,27 +23,38 @@ public ProcessWrapper(string filename, string arguments, bool captureStdErr = fa
{
FileName = filename,
Arguments = arguments,
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardOutput = captureStdOut,
RedirectStandardError = captureStdErr,
UseShellExecute = false,
CreateNoWindow = true
CreateNoWindow = !showConsole
},
EnableRaisingEvents = true
};
if (_process == null)
{
throw new Exception($"Error running {filename} {arguments}");
}
_process.OutputDataReceived += OnText;

if (captureStdOut)
{
_process.OutputDataReceived += OnText;
}
if (captureStdErr)
{
_process.ErrorDataReceived += OnText;
}

_process.Start();
_process.BeginOutputReadLine();

if (captureStdOut)
{
_process.BeginOutputReadLine();
++_streamCount;
}
if (captureStdErr)
{
_process.BeginErrorReadLine();
++_streamCount;
}
}

Expand Down Expand Up @@ -82,8 +94,13 @@ public IEnumerable<string> Lines()

if (line == null)
{
// We see a null to indicate the end of the stream
yield break;
if (--_streamCount == 0)
{
// We see a null to indicate the end of each stream. We break on the last one.
yield break;
}
// Else drop it
continue;
}

yield return line;
Expand Down
11 changes: 10 additions & 1 deletion LibVgm/VgmFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,16 @@ public VgmFile()
Gd3Tag = new Gd3Tag();
}

public void LoadFromFile(string filename)
public VgmFile(string filename)
{
_stream = new MemoryStream();
Header = new VgmHeader();
Gd3Tag = new Gd3Tag();

LoadFromFile(filename);
}

private void LoadFromFile(string filename)
{
// We copy all the data into a memory stream to allow seeking
using (var s = new OptionalGzipStream(filename))
Expand Down
Loading

0 comments on commit f8085a3

Please sign in to comment.