diff --git a/TwitchDownloaderCore/VideoDownloader.cs b/TwitchDownloaderCore/VideoDownloader.cs index 5f8cf72f..3069c08b 100644 --- a/TwitchDownloaderCore/VideoDownloader.cs +++ b/TwitchDownloaderCore/VideoDownloader.cs @@ -119,7 +119,7 @@ await FfmpegMetadata.SerializeAsync(metadataPath, videoInfo.owner.displayName, d var ffmpegRetries = 0; do { - ffmpegExitCode = await RunFfmpegVideoCopy(downloadFolder, outputFileInfo, concatListPath, metadataPath, startOffset, endDuration, videoLength, cancellationToken); + ffmpegExitCode = await RunFfmpegVideoCopy(downloadFolder, outputFileInfo, concatListPath, metadataPath, startOffset, endDuration, videoLength, ffmpegRetries > 0, cancellationToken); if (ffmpegExitCode != 0) { _progress.LogError($"Failed to finalize video (code {ffmpegExitCode}), retrying in 10 seconds..."); @@ -317,7 +317,7 @@ private async Task VerifyDownloadedParts(ICollection playlist, Rang } } - private async Task RunFfmpegVideoCopy(string tempFolder, FileInfo outputFile, string concatListPath, string metadataPath, decimal startOffset, decimal endDuration, TimeSpan videoLength, CancellationToken cancellationToken) + private async Task RunFfmpegVideoCopy(string tempFolder, FileInfo outputFile, string concatListPath, string metadataPath, decimal startOffset, decimal endDuration, TimeSpan videoLength, bool disableAudioCopy, CancellationToken cancellationToken) { using var process = new Process { @@ -344,10 +344,16 @@ private async Task RunFfmpegVideoCopy(string tempFolder, FileInfo outputFil "-i", concatListPath, "-i", metadataPath, "-map_metadata", "1", - "-c", "copy", + (disableAudioCopy ? "-c:v" : "-c"), "copy", outputFile.FullName }; + if (disableAudioCopy) + { + // Some VODs have bad audio data which FFmpeg doesn't like in copy mode. See lay295#1121 for more info + _progress.LogVerbose("Running with audio copy disabled."); + } + if (endDuration > 0) { args.Insert(0, "-t");