Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
- Error if no ffmpeg in youtubemerged mode
- Avoid duplicate tags which make YouTube reject the video
- Make video globbing work with no dir in youtubemerged mode
- Increase thread queue parameter, fixes #86
  • Loading branch information
maxim-zhao committed Apr 9, 2024
1 parent 73f4ebf commit 56f1eae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
5 changes: 2 additions & 3 deletions LibSidWiz/Outputs/FfmpegOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ public FfmpegOutput(string pathToExe, string filename, int width, int height, in
// Audio part
if (File.Exists(masterAudioFilename))
{
arguments += $" -i \"{masterAudioFilename}\"";
arguments += " -acodec aac";
arguments += $" -i \"{masterAudioFilename}\" -acodec flac";
}

// Video part
arguments += $" -f rawvideo -pixel_format bgr0 -video_size {width}x{height} -framerate {fps} -i pipe: -movflags +faststart";
arguments += $" -f rawvideo -pixel_format bgr0 -video_size {width}x{height} -framerate {fps} -thread_queue_size 4096 -i pipe: -movflags +faststart";

// Extra args
arguments += $" {extraArgs} \"{filename}\"";
Expand Down
17 changes: 14 additions & 3 deletions SidWizPlus/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private class Settings
[Option("ffmpeg", Required = false, HelpText = "Path to FFMPEG. If not given, no output is produced.")]
public string FfMpegPath { get; set; }
// ReSharper disable once StringLiteralTypo
[Option("ffmpegoptions", Required = false, HelpText = "Extra commandline options for FFMPEG, e.g. to set the output format", DefaultValue = "")]
[Option("ffmpegoptions", Required = false, HelpText = "Extra commandline options for FFMPEG, e.g. to set the output format. Surround value with quotes and start with a space, e.g. \" -acodec flac\", to avoid conflicts with other parameters.", DefaultValue = "")]
public string FfMpegExtraOptions { get; set; }

// ReSharper disable once StringLiteralTypo
Expand Down Expand Up @@ -880,12 +880,13 @@ private static async Task<string> UploadToYouTube(Settings settings)

if (settings.YouTubeTagsFromGd3 && gd3 != null)
{
// We have a VGM file
tags.Add(gd3.Game.English);
tags.Add(gd3.System.English);
tags.AddRange(gd3.Composer.English.Split(';'));
}

video.Snippet.Tags = tags.Where(t => !string.IsNullOrEmpty(t)).Select(t => t.Trim()).ToList();
video.Snippet.Tags = tags.Distinct().Where(t => !string.IsNullOrEmpty(t)).Select(t => t.Trim()).ToList();

if (settings.YouTubeCategory != null)
{
Expand Down Expand Up @@ -1087,10 +1088,20 @@ private static async Task<YouTubeService> GetYouTubeService(Settings settings)

private static async Task UploadMergedToYouTube(Settings settings)
{
if (!File.Exists(settings.FfMpegPath))
{
throw new Exception("FFMPEG path is required");
}

// First we look for the videos and collect some metadata
var outputPath = Path.GetFullPath(settings.OutputFile);
var directoryName = Path.GetDirectoryName(settings.YouTubeMerge);
if (string.IsNullOrEmpty(directoryName))
{
directoryName = ".";
}
var files = Directory.EnumerateFiles(
Path.GetDirectoryName(settings.YouTubeMerge) ?? ".",
directoryName,
Path.GetFileName(settings.YouTubeMerge))
.AsParallel()
.Select(Path.GetFullPath)
Expand Down

0 comments on commit 56f1eae

Please sign in to comment.